diff --git a/.copr/Makefile b/.copr/Makefile index 657a95f..1385029 100644 --- a/.copr/Makefile +++ b/.copr/Makefile @@ -16,11 +16,12 @@ $(info Launching COPR build from directory: $(COPR_CURRENT_SUBDIRECTORY)) # # This Makefile is currently invoked twice: # 1) from "collector" subdirectory; test by running -# cd /home/fmontorsi/git/cmonitor/collector -# make -f /home/fmontorsi/git/cmonitor/.copr/Makefile srpm outdir=/tmp/cmonitor-collector-rpm +# export BASE_DIR=/home/fmontorsi/git (adjust to your case) +# cd ${BASEDIR}/cmonitor/collector +# make -f ${BASEDIR}/cmonitor/.copr/Makefile srpm outdir=/tmp/cmonitor-collector-rpm # 2) from "tools" subdirectory; test by running -# cd /home/fmontorsi/git/cmonitor/tools -# make -f /home/fmontorsi/git/cmonitor/.copr/Makefile srpm outdir=/tmp/cmonitor-tools-rpm +# cd ${BASEDIR}/cmonitor/tools +# make -f ${BASEDIR}/cmonitor/.copr/Makefile srpm outdir=/tmp/cmonitor-tools-rpm # # NOTE: # see https://docs.pagure.org/copr.copr/user_documentation.html#how-long-do-you-keep-the-builds diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2015317..5a70903 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,16 +15,14 @@ jobs: - uses: actions/checkout@v4 - name: install debian-packaged dependencies run: sudo apt install -y libgtest-dev libbenchmark-dev libfmt-dev tidy git python3 python3-dateutil python3-pip - - # NOTE: prometheus-cpp & its dependencies wants at least Conan 1.51.0 - name: install pypi-packaged dependencies - run: sudo pip3 install pytest 'black==22.8.0' 'conan==1.60.2' + run: sudo pip3 install pytest 'black==22.8.0' 'conan==2.9.1' # NOTE: since we later run "make" using the normal "builder" user, we must use Conan using that same user (so avoid the "sudo"!!) - name: install Conan-packaged dependencies run: | - conan profile new default --detect - conan profile update settings.compiler.libcxx=libstdc++11 default + conan profile detect --force + conan remote update conancenter --url https://center2.conan.io conan install conanfile.txt --build=missing # build & test diff --git a/.gitignore b/.gitignore index 0b9ae5a..a739a21 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,11 @@ conanbuildinfo.txt conaninfo.txt graph_info.json +# files created by Conan v2 install +conanbuild.sh +conanbuildenv-release-x86_64.sh +conandeps.mk +conanrun.sh +conanrunenv-release-x86_64.sh +deactivate_conanbuild.sh +deactivate_conanrun.sh diff --git a/Makefile b/Makefile index 56aeedc..5e31f57 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # # Main makefile for cmonitor project # https://github.com/f18m/cmonitor -# Francesco Montorsi (c) 2019 +# Francesco Montorsi (c) 2019-2024 # # constants diff --git a/Prometheus-Support.mk b/Prometheus-Support.mk index c21410b..2e028c2 100644 --- a/Prometheus-Support.mk +++ b/Prometheus-Support.mk @@ -8,15 +8,15 @@ ifeq ($(PROMETHEUS_SUPPORT),1) $(info INFO: Prometheus support is ENABLED) -ifeq ($(wildcard $(ROOT_DIR)/conanbuildinfo.mak),) +ifeq ($(wildcard $(ROOT_DIR)/conandeps.mk),) $(error Please run 'conan install . --build=missing' first) endif # include prometheus-cpp depedency through the GNU make variables provided by Conan at install time # NOTE: for some reason "dl pthread" libraries must be explicitly listed -include $(ROOT_DIR)/conanbuildinfo.mak +include $(ROOT_DIR)/conandeps.mk LIBS += $(foreach libdir,$(CONAN_LIB_DIRS),-L$(libdir)) $(foreach lib,$(CONAN_LIBS),-l$(lib)) -ldl -lpthread -CXXFLAGS += $(CONAN_CXXFLAGS) -I$(CONAN_INCLUDE_DIRS_PROMETHEUS-CPP) +CXXFLAGS += $(CONAN_CXXFLAGS) -I$(CONAN_INCLUDE_DIRS_PROMETHEUS_CPP) DEFS += -DPROMETHEUS_SUPPORT=1 else diff --git a/collector/spec/collector.spec b/collector/spec/collector.spec index f635e2b..310ede6 100644 --- a/collector/spec/collector.spec +++ b/collector/spec/collector.spec @@ -43,13 +43,13 @@ echo "[Inside RPM prep] running setup" %build # first of all install in the buildroot the Conan package manager, which we use to fetch # prometheus-cpp, since that library is not, unfortunately, packaged by Fedora/COPR -# NOTE: prometheus-cpp & its dependencies wants at least Conan 1.51.0 +# NOTE: prometheus-cpp & its dependencies want at least Conan 1.51.0... but versions below 1.64 fail to +# install properly in Fedora >= 39 echo "[Inside RPM build] installing Conan" -pip3 install --user 'conan==1.60.2' +pip3 install --user 'conan==2.9.1' echo "[Inside RPM build] bootstrapping Conan" export PATH="$HOME/.local/bin:$PATH" -conan profile new %{buildroot}/cmonitor_rpmbuild --detect -conan profile update settings.compiler.libcxx=libstdc++11 %{buildroot}/cmonitor_rpmbuild +conan profile detect --force conan remote list # secondly, Conan is used to fetch prometheus-cpp library, building it with cmake when needed: @@ -59,8 +59,9 @@ echo "[Inside RPM build] installing prometheus-cpp" mkdir -p %{buildroot}/bin ln -sf /usr/bin/cmake3 %{buildroot}/bin/cmake export PATH="%{buildroot}/bin:$PATH" + echo "[Inside RPM build] the PATH adjusted to contain a cmake3->cmake symlink is: $PATH" -conan install conanfile.txt --build=missing --profile %{buildroot}/cmonitor_rpmbuild +conan install conanfile.txt --build=missing # finally, this command invokes the root Makefile of cmonitor repo, from inside the source tarball # produced by COPR; that root Makefile will pass all the options listed here to collector/Makefile diff --git a/collector/src/Makefile b/collector/src/Makefile index d4595cd..9f69b97 100644 --- a/collector/src/Makefile +++ b/collector/src/Makefile @@ -7,11 +7,9 @@ ROOT_DIR:=$(shell readlink -f $(THIS_DIR)/../..) include $(ROOT_DIR)/Constants.mk include $(ROOT_DIR)/Prometheus-Support.mk -# IMPORTANT: Centos7 which is one of the oldest-supported distributions provides gcc 4.8.5; -# GCC 4.8.x is able to build C++11 but not e.g. C++14/17/20 yet... so we will stay with C++11 -# till Centos7 has to be supported... + # IMPORTANT#2: -fPIC is required to build on fedora-rawhide -CXXFLAGS += -Wall -Werror -Wno-switch-bool -std=c++11 -fPIC $(DEFS) +CXXFLAGS += -Wall -Werror -Wno-switch-bool -std=c++14 -fPIC $(DEFS) ifeq ($(DEBUG),1) CXXFLAGS += -g -O0 #useful for debugging @@ -92,7 +90,7 @@ benchmarks: $(OUT): $(OBJS) $(ROOT_DIR)/Constants.mk - $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) $(LIBS) + $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group clean: rm -f $(OUT) $(OBJS) *.err *.json *.log diff --git a/collector/src/benchmarks/Makefile b/collector/src/benchmarks/Makefile index e1a3a99..64fd009 100644 --- a/collector/src/benchmarks/Makefile +++ b/collector/src/benchmarks/Makefile @@ -7,7 +7,7 @@ ROOT_DIR:=$(shell readlink -f $(THIS_DIR)/../../..) include $(ROOT_DIR)/Constants.mk include $(ROOT_DIR)/Prometheus-Support.mk -CXXFLAGS=-Wall -Werror -Wno-switch-bool -std=c++11 -fPIC $(DEFS) +CXXFLAGS=-Wall -Werror -Wno-switch-bool -std=c++14 -fPIC $(DEFS) ifeq ($(DEBUG),1) CXXFLAGS += -g -O0 #useful for debugging @@ -75,7 +75,7 @@ debug: gdb $(OUT) $(OUT): $(OBJS) $(ROOT_DIR)/Constants.mk - $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) $(LIBS) + $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group clean: rm -f $(OUT) $(OBJS) diff --git a/collector/src/tests/Makefile b/collector/src/tests/Makefile index d887f24..883b5b3 100644 --- a/collector/src/tests/Makefile +++ b/collector/src/tests/Makefile @@ -7,7 +7,7 @@ ROOT_DIR:=$(shell readlink -f $(THIS_DIR)/../../..) include $(ROOT_DIR)/Constants.mk include $(ROOT_DIR)/Prometheus-Support.mk -CXXFLAGS += -Wall -Werror -Wno-switch-bool -std=c++11 -fPIC $(DEFS) +CXXFLAGS += -Wall -Werror -Wno-switch-bool -std=c++14 -fPIC $(DEFS) ifeq ($(DEBUG),1) CXXFLAGS += -g -O0 #useful for debugging @@ -88,7 +88,7 @@ accept_new_results: done $(OUT): $(OBJS) $(ROOT_DIR)/Constants.mk - $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) $(LIBS) + $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group clean: rm -f $(OUT) $(OBJS) *.err *.json *.log diff --git a/collector/src/tests/tests_cgroup.cpp b/collector/src/tests/tests_cgroup.cpp index 155e7d8..6615773 100644 --- a/collector/src/tests/tests_cgroup.cpp +++ b/collector/src/tests/tests_cgroup.cpp @@ -16,7 +16,9 @@ // GTest helpers //------------------------------------------------------------------------------ +#ifndef PATH_MAX #define PATH_MAX (4096) +#endif std::string get_unit_test_abs_dir() { diff --git a/conanfile.txt b/conanfile.txt index b360418..202ee22 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,20 +1,18 @@ # -# Conanfile to retrieve prometheus-cpp library (and its dependencies: civetweb, openssl, libcurl) +# Conanfile to retrieve prometheus-cpp library (and its dependencies/*: civetweb, openssl, libcurl) # This Conanfile is used also by COPR during RPM creation. # [requires] - # prometheus-cpp 1.1.0 cannot be used because it supports only C++14 onward; however the compiler shipping with Centos7 - # supports at most the C++11 dialect... so till we want to support Centos7, we need to stick with prometheus-cpp 1.0.0 - prometheus-cpp/1.2.4@ + prometheus-cpp/1.3.0@ [options] # by using shared=False we create a cmonitor_collector binary that is self-contained - prometheus-cpp:shared=False # default is True - prometheus-cpp:with_pull=True # default is True - prometheus-cpp:with_push=False # default is False - prometheus-cpp:with_compression=False # default is False - prometheus-cpp:fPIC=True # default is True + prometheus-cpp/*:shared=False # default is True + prometheus-cpp/*:with_pull=True # default is True + prometheus-cpp/*:with_push=False # default is False + prometheus-cpp/*:with_compression=False # default is False + prometheus-cpp/*:fPIC=True # default is True [generators] - make + MakeDeps