Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/newer conan #67

Merged
merged 12 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .copr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Main makefile for cmonitor project
# https://github.com/f18m/cmonitor
# Francesco Montorsi (c) 2019
# Francesco Montorsi (c) 2019-2024
#

# constants
Expand Down
6 changes: 3 additions & 3 deletions Prometheus-Support.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions collector/spec/collector.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions collector/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions collector/src/benchmarks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions collector/src/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions collector/src/tests/tests_cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// GTest helpers
//------------------------------------------------------------------------------

#ifndef PATH_MAX
#define PATH_MAX (4096)
#endif

std::string get_unit_test_abs_dir()
{
Expand Down
18 changes: 8 additions & 10 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -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