Skip to content

Commit 7f90a05

Browse files
authored
chore: upgrade to conan v2 (#726)
1 parent 81267c6 commit 7f90a05

21 files changed

+787
-1519
lines changed

.conanrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
conan_home=./build

.github/actions/build-cpp/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ WORKDIR /pktvisor-src
1515
RUN apt-get update && \
1616
apt-get upgrade --yes --force-yes && \
1717
apt-get install --yes --force-yes --no-install-recommends ${BUILD_DEPS} && \
18-
pip3 install 'conan==1.66.0' --force-reinstall
18+
pip3 install conan --force-reinstall
1919

2020
RUN chmod +x /entrypoint.sh
2121

.github/actions/build-cpp/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function build() {
2626
conan profile new --detect default
2727
conan profile update settings.compiler.libcxx=libstdc++11 default
2828
conan config set general.revisions_enabled=1
29-
PKG_CONFIG_PATH=/local/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=$INPUT_BUILD_TYPE -DASAN=$INPUT_ASAN /pktvisor-src
29+
PKG_CONFIG_PATH=/local/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=$INPUT_BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake -DASAN=$INPUT_ASAN /pktvisor-src
3030
make all -j 4
3131
}
3232

.github/workflows/build-develop.yml

+7-12
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ jobs:
3434
- name: Get Conan
3535
id: conan
3636
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
37-
with:
38-
version: 1.66.0
3937

4038
- name: Setup OSX Environment
4139
run: echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
@@ -46,11 +44,14 @@ jobs:
4644
path: ${{github.workspace}}/build/conan_home/
4745
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
4846
restore-keys: conan-${{ runner.os }}-
47+
48+
- name: Detect Conan Profile
49+
run: conan profile detect -f
4950

5051
- name: Configure CMake
5152
shell: bash
5253
working-directory: ${{github.workspace}}/build
53-
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
54+
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
5455

5556
- name: Build
5657
working-directory: ${{github.workspace}}/build
@@ -76,8 +77,6 @@ jobs:
7677
- name: Get Conan
7778
id: conan
7879
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
79-
with:
80-
version: 1.66.0
8180

8281
- name: Setup Conan Cache
8382
uses: actions/cache@v4
@@ -89,7 +88,7 @@ jobs:
8988
- name: Configure CMake
9089
shell: bash
9190
working-directory: ${{github.workspace}}/build
92-
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
91+
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
9392

9493
- name: Get VERSION
9594
id: build
@@ -120,8 +119,6 @@ jobs:
120119
- name: Get Conan
121120
id: conan
122121
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
123-
with:
124-
version: 1.66.0
125122

126123
- name: Setup Conan Cache
127124
uses: actions/cache@v4
@@ -133,7 +130,7 @@ jobs:
133130
- name: Configure CMake
134131
shell: bash
135132
working-directory: ${{github.workspace}}\build
136-
run: PKG_CONFIG_PATH=${{github.workspace}}\local\lib\pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
133+
run: PKG_CONFIG_PATH=${{github.workspace}}\local\lib\pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
137134

138135
- name: Get VERSION
139136
shell: pwsh
@@ -319,13 +316,11 @@ jobs:
319316
- name: Get Conan
320317
id: conan
321318
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
322-
with:
323-
version: 1.66.0
324319

325320
- name: Configure CMake to generate VERSION
326321
shell: bash
327322
working-directory: ${{github.workspace}}/build
328-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
323+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
329324

330325
- name: Get VERSION
331326
id: build

.github/workflows/build-release.yml

+4-12
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ jobs:
3131
- name: Get Conan
3232
id: conan
3333
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
34-
with:
35-
version: 1.66.0
3634

3735
- name: Setup Conan Cache
3836
uses: actions/cache@v4
@@ -44,7 +42,7 @@ jobs:
4442
- name: Configure CMake
4543
shell: bash
4644
working-directory: ${{github.workspace}}/build
47-
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
45+
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
4846

4947
- name: Build
5048
working-directory: ${{github.workspace}}/build
@@ -77,13 +75,11 @@ jobs:
7775
- name: Get Conan
7876
id: conan
7977
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
80-
with:
81-
version: 1.66.0
8278

8379
- name: Configure CMake to generate VERSION
8480
shell: bash
8581
working-directory: ${{github.workspace}}/build
86-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
82+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
8783

8884
- name: Get VERSION
8985
id: build
@@ -123,13 +119,11 @@ jobs:
123119
- name: Get Conan
124120
id: conan
125121
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
126-
with:
127-
version: 1.66.0
128122

129123
- name: Configure CMake to generate VERSION
130124
shell: bash
131125
working-directory: ${{github.workspace}}/build
132-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
126+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
133127

134128
- name: Set variables
135129
run: |
@@ -173,8 +167,6 @@ jobs:
173167
- name: Get Conan
174168
id: conan
175169
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
176-
with:
177-
version: 1.66.0
178170

179171
- name: Setup Conan Cache
180172
uses: actions/cache@v4
@@ -186,7 +178,7 @@ jobs:
186178
- name: Configure CMake
187179
shell: bash
188180
working-directory: ${{github.workspace}}\build
189-
run: PKG_CONFIG_PATH=${{github.workspace}}\local\lib\pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
181+
run: PKG_CONFIG_PATH=${{github.workspace}}\local\lib\pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
190182

191183
- name: Get VERSION
192184
shell: pwsh

.github/workflows/build_cross.yml

+38-40
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
env:
3939
CC: gcc
4040
CXX: g++
41-
CONAN_USER_HOME: "${{github.workspace}}"
41+
4242
steps:
4343
- name: Install sccache from cache
4444
id: cache-sccache
@@ -69,77 +69,75 @@ jobs:
6969
curl -L "${{matrix.toolchain}}" | tar -C toolchain -xz --strip-components=1
7070
7171
- name: Install Conan
72-
run: pip install --no-cache-dir 'conan==1.66.0' --force-reinstall
72+
run: pip install --no-cache-dir conan --force-reinstall
73+
74+
- name: Restore sccache
75+
uses: actions/cache@v4
76+
with:
77+
path: ~/.cache/sccache
78+
key: sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-${{github.run_id}}
79+
restore-keys: |
80+
sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-
81+
sccache-${{matrix.arch}}-${{github.base_ref||github.event.repository.default_branch}}-
82+
83+
- name: Checkout sources
84+
uses: actions/checkout@v4
85+
with:
86+
path: src
7387

7488
- name: Create Conan configuration
89+
working-directory: ${{github.workspace}}/src
7590
run: |
76-
# init config
77-
CONAN_V2_MODE=1 conan config init
78-
conan config set general.revisions_enabled=1
79-
# add custom compiler settings for libc
80-
python3 -c 'import yaml; p = "${{env.CONAN_USER_HOME}}/.conan/settings.yml"; d = yaml.safe_load(open(p)); d["compiler"]["gcc"]["libc"] = ["None", "glibc", "musl"]; yaml.safe_dump(d, open(p, "w"))'
91+
mkdir build/
92+
conan config list
93+
python3 -c 'import yaml; p = "build/settings.yml"; d = yaml.safe_load(open(p)); d["compiler"]["gcc"]["libc"] = ["glibc", "musl"]; yaml.safe_dump(d, open(p, "w"))'
94+
conan profile detect
95+
echo "compiler.libc=glibc" >> $(conan profile path default)
96+
8197
8298
- name: Create Conan host profile
99+
working-directory: ${{github.workspace}}/src
83100
run: |
84-
cat > "${{env.CONAN_USER_HOME}}/.conan/profiles/host" << "EOF"
101+
cat > "$(conan config home)/profiles/host" << "EOF"
85102
[settings]
86103
os=Linux
87-
os_build=Linux
88104
arch=${{matrix.conan_arch}}
89-
arch_build=x86_64
90105
compiler=gcc
91106
compiler.version=11
107+
compiler.cppstd=17
92108
compiler.libcxx=libstdc++11
93109
compiler.libc=musl
94110
build_type=Release
95-
[build_requires]
96-
[env]
111+
[buildenv]
97112
CC=${{github.workspace}}/toolchain/bin/${{matrix.cc}}
98113
CXX=${{github.workspace}}/toolchain/bin/${{matrix.cxx}}
99114
LDFLAGS=${{matrix.ldflags}}
100115
EOF
101116
102-
- name: Restore sccache
103-
uses: actions/cache@v4
104-
with:
105-
path: ~/.cache/sccache
106-
key: sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-${{github.run_id}}
107-
restore-keys: |
108-
sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-
109-
sccache-${{matrix.arch}}-${{github.base_ref||github.event.repository.default_branch}}-
110-
111-
- name: Checkout sources
112-
uses: actions/checkout@v4
113-
with:
114-
path: src
115-
116-
- name: Remove crashpad from conanfile
117-
run: sed -i "/crashpad/d" ${{github.workspace}}/src/conanfile.py
118-
119117
- name: Install dependencies
118+
working-directory: ${{github.workspace}}/src
120119
run: |
121-
mkdir build
122-
cd build
123-
conan install -pr:b default -pr:h host -g virtualenv --build=missing "${{github.workspace}}/src"
120+
conan install . -pr:b=default -pr:h="host" --build=missing
124121
125122
- name: Configure
123+
working-directory: ${{github.workspace}}/src/build
126124
run: |
127-
cd build
128-
source environment.sh.env
129125
export CC CXX
130126
export LDFLAGS=-static
131-
cmake "${{github.workspace}}/src" \
127+
source Release/generators/conanbuild.sh
128+
cmake .. \
132129
-DCMAKE_BUILD_TYPE=Release \
130+
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake \
131+
-DCONAN_HOST_PROFILE="host" \
132+
-DCONAN_INSTALL_ARGS=--build=never \
133133
-DCRASHPAD_NOT_SUPPORTED=true \
134134
-DCMAKE_C_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" -DCMAKE_CXX_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" \
135-
-DPKTVISOR_CONAN_INIT=OFF -DPKTVISOR_CONAN_BUILD="never" -DPKTVISOR_CONAN_BUILD_PROFILE="default" -DPKTVISOR_CONAN_HOST_PROFILE="host" \
136135
-DCORRADE_RC_PROGRAM=$(command -v corrade-rc) \
137136
-DCMAKE_CXX_STANDARD_LIBRARIES=-latomic
138137
139138
- name: Build
140-
run: |
141-
cd build
142-
make -j4 VERBOSE=1
139+
working-directory: ${{github.workspace}}/src/build
140+
run: make -j4 VERBOSE=1
143141

144142
- name: Print sccache stats
145143
run: |
@@ -175,7 +173,7 @@ jobs:
175173

176174
- name: Configure CMake to generate VERSION
177175
shell: bash
178-
run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release
176+
run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
179177

180178
- name: Rename folder and copy version
181179
shell: bash

.github/workflows/build_debug.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ jobs:
2323
- name: Get Conan
2424
id: conan
2525
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
26-
with:
27-
version: 1.66.0
2826

2927
- name: Setup Conan Cache
3028
uses: actions/cache@v4
@@ -41,7 +39,7 @@ jobs:
4139
- name: Configure CMake
4240
shell: bash
4341
working-directory: ${{github.workspace}}/build
44-
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON
42+
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake -DCODE_COVERAGE=ON
4543

4644
- name: Get VERSION
4745
id: build

.github/workflows/code-ql.yml

+2-32
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@ jobs:
1717

1818
strategy:
1919
fail-fast: false
20-
#matrix:
21-
# language: [ 'cpp', 'go', 'python' ]
22-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
23-
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
2420

2521
env:
2622
CC: gcc
2723
CXX: g++
28-
CONAN_USER_HOME: "${{github.workspace}}"
2924

3025
steps:
3126
- name: Checkout repository
@@ -69,38 +64,13 @@ jobs:
6964
- run: |
7065
# Run Build - set up dependencies, env vars, compile, and make test
7166
#install conan
72-
pip install --no-cache-dir 'conan==1.66.0' --force-reinstall
73-
# create conan config
74-
CONAN_V2_MODE=1 conan config init
75-
conan config set general.revisions_enabled=1
76-
# add custom compiler settings for libc
77-
python3 -c 'import yaml; p = "${{env.CONAN_USER_HOME}}/.conan/settings.yml"; d = yaml.safe_load(open(p)); d["compiler"]["gcc"]["libc"] = ["None", "glibc", "musl"]; yaml.safe_dump(d, open(p, "w"))'
78-
# Create Conan host profile
79-
cat > "${{env.CONAN_USER_HOME}}/.conan/profiles/host" << "EOF"
80-
[settings]
81-
os=Linux
82-
os_build=Linux
83-
arch=${{matrix.conan_arch}}
84-
arch_build=x86_64
85-
compiler=gcc
86-
compiler.version=11
87-
compiler.libcxx=libstdc++11
88-
compiler.libc=musl
89-
build_type=Release
90-
[options]
91-
pcapplusplus:with_musl=True
92-
[build_requires]
93-
[env]
94-
CC=${{github.workspace}}/toolchain/bin/${{matrix.cc}}
95-
CXX=${{github.workspace}}/toolchain/bin/${{matrix.cxx}}
96-
LDFLAGS=${{matrix.ldflags}}
97-
EOF
67+
pip install --no-cache-dir conan --force-reinstall
9868
# clone the repository, not sure if this needs to be done
9969
git clone https://github.com/netboxlabs/pktvisor.git
10070
cd pktvisor
10171
mkdir build && cd build
10272
# configure and handle dependencies
103-
cmake -DCMAKE_BUILD_TYPE=Release ..
73+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake ..
10474
# build and run tests
10575
sudo make all test
10676
#remove conan files

0 commit comments

Comments
 (0)