Skip to content

Commit

Permalink
chore: upgrade to conan v2 (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoparente authored Jan 13, 2025
1 parent 81267c6 commit 7f90a05
Show file tree
Hide file tree
Showing 21 changed files with 787 additions and 1,519 deletions.
1 change: 1 addition & 0 deletions .conanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conan_home=./build
2 changes: 1 addition & 1 deletion .github/actions/build-cpp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WORKDIR /pktvisor-src
RUN apt-get update && \
apt-get upgrade --yes --force-yes && \
apt-get install --yes --force-yes --no-install-recommends ${BUILD_DEPS} && \
pip3 install 'conan==1.66.0' --force-reinstall
pip3 install conan --force-reinstall

RUN chmod +x /entrypoint.sh

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build-cpp/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function build() {
conan profile new --detect default
conan profile update settings.compiler.libcxx=libstdc++11 default
conan config set general.revisions_enabled=1
PKG_CONFIG_PATH=/local/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=$INPUT_BUILD_TYPE -DASAN=$INPUT_ASAN /pktvisor-src
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
make all -j 4
}

Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/build-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
with:
version: 1.66.0

- name: Setup OSX Environment
run: echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
Expand All @@ -46,11 +44,14 @@ jobs:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: Detect Conan Profile
run: conan profile detect -f

- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
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

- name: Build
working-directory: ${{github.workspace}}/build
Expand All @@ -76,8 +77,6 @@ jobs:
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
with:
version: 1.66.0

- name: Setup Conan Cache
uses: actions/cache@v4
Expand All @@ -89,7 +88,7 @@ jobs:
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
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

- name: Get VERSION
id: build
Expand Down Expand Up @@ -120,8 +119,6 @@ jobs:
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
with:
version: 1.66.0

- name: Setup Conan Cache
uses: actions/cache@v4
Expand All @@ -133,7 +130,7 @@ jobs:
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}\build
run: PKG_CONFIG_PATH=${{github.workspace}}\local\lib\pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
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

- name: Get VERSION
shell: pwsh
Expand Down Expand Up @@ -319,13 +316,11 @@ jobs:
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
with:
version: 1.66.0

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

- name: Get VERSION
id: build
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
with:
version: 1.66.0

- name: Setup Conan Cache
uses: actions/cache@v4
Expand All @@ -44,7 +42,7 @@ jobs:
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
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

- name: Build
working-directory: ${{github.workspace}}/build
Expand Down Expand Up @@ -77,13 +75,11 @@ jobs:
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
with:
version: 1.66.0

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

- name: Get VERSION
id: build
Expand Down Expand Up @@ -123,13 +119,11 @@ jobs:
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
with:
version: 1.66.0

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

- name: Set variables
run: |
Expand Down Expand Up @@ -173,8 +167,6 @@ jobs:
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
with:
version: 1.66.0

- name: Setup Conan Cache
uses: actions/cache@v4
Expand All @@ -186,7 +178,7 @@ jobs:
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}\build
run: PKG_CONFIG_PATH=${{github.workspace}}\local\lib\pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
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

- name: Get VERSION
shell: pwsh
Expand Down
78 changes: 38 additions & 40 deletions .github/workflows/build_cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
env:
CC: gcc
CXX: g++
CONAN_USER_HOME: "${{github.workspace}}"

steps:
- name: Install sccache from cache
id: cache-sccache
Expand Down Expand Up @@ -69,77 +69,75 @@ jobs:
curl -L "${{matrix.toolchain}}" | tar -C toolchain -xz --strip-components=1
- name: Install Conan
run: pip install --no-cache-dir 'conan==1.66.0' --force-reinstall
run: pip install --no-cache-dir conan --force-reinstall

- name: Restore sccache
uses: actions/cache@v4
with:
path: ~/.cache/sccache
key: sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-${{github.run_id}}
restore-keys: |
sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-
sccache-${{matrix.arch}}-${{github.base_ref||github.event.repository.default_branch}}-
- name: Checkout sources
uses: actions/checkout@v4
with:
path: src

- name: Create Conan configuration
working-directory: ${{github.workspace}}/src
run: |
# init config
CONAN_V2_MODE=1 conan config init
conan config set general.revisions_enabled=1
# add custom compiler settings for libc
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"))'
mkdir build/
conan config list
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"))'
conan profile detect
echo "compiler.libc=glibc" >> $(conan profile path default)
- name: Create Conan host profile
working-directory: ${{github.workspace}}/src
run: |
cat > "${{env.CONAN_USER_HOME}}/.conan/profiles/host" << "EOF"
cat > "$(conan config home)/profiles/host" << "EOF"
[settings]
os=Linux
os_build=Linux
arch=${{matrix.conan_arch}}
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.libc=musl
build_type=Release
[build_requires]
[env]
[buildenv]
CC=${{github.workspace}}/toolchain/bin/${{matrix.cc}}
CXX=${{github.workspace}}/toolchain/bin/${{matrix.cxx}}
LDFLAGS=${{matrix.ldflags}}
EOF
- name: Restore sccache
uses: actions/cache@v4
with:
path: ~/.cache/sccache
key: sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-${{github.run_id}}
restore-keys: |
sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-
sccache-${{matrix.arch}}-${{github.base_ref||github.event.repository.default_branch}}-
- name: Checkout sources
uses: actions/checkout@v4
with:
path: src

- name: Remove crashpad from conanfile
run: sed -i "/crashpad/d" ${{github.workspace}}/src/conanfile.py

- name: Install dependencies
working-directory: ${{github.workspace}}/src
run: |
mkdir build
cd build
conan install -pr:b default -pr:h host -g virtualenv --build=missing "${{github.workspace}}/src"
conan install . -pr:b=default -pr:h="host" --build=missing
- name: Configure
working-directory: ${{github.workspace}}/src/build
run: |
cd build
source environment.sh.env
export CC CXX
export LDFLAGS=-static
cmake "${{github.workspace}}/src" \
source Release/generators/conanbuild.sh
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake \
-DCONAN_HOST_PROFILE="host" \
-DCONAN_INSTALL_ARGS=--build=never \
-DCRASHPAD_NOT_SUPPORTED=true \
-DCMAKE_C_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" -DCMAKE_CXX_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" \
-DPKTVISOR_CONAN_INIT=OFF -DPKTVISOR_CONAN_BUILD="never" -DPKTVISOR_CONAN_BUILD_PROFILE="default" -DPKTVISOR_CONAN_HOST_PROFILE="host" \
-DCORRADE_RC_PROGRAM=$(command -v corrade-rc) \
-DCMAKE_CXX_STANDARD_LIBRARIES=-latomic
- name: Build
run: |
cd build
make -j4 VERBOSE=1
working-directory: ${{github.workspace}}/src/build
run: make -j4 VERBOSE=1

- name: Print sccache stats
run: |
Expand Down Expand Up @@ -175,7 +173,7 @@ jobs:

- name: Configure CMake to generate VERSION
shell: bash
run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release
run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake

- name: Rename folder and copy version
shell: bash
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/build_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jobs:
- name: Get Conan
id: conan
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
with:
version: 1.66.0

- name: Setup Conan Cache
uses: actions/cache@v4
Expand All @@ -41,7 +39,7 @@ jobs:
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
run: PKG_CONFIG_PATH=${{github.workspace}}/local/lib/pkgconfig cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON
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

- name: Get VERSION
id: build
Expand Down
34 changes: 2 additions & 32 deletions .github/workflows/code-ql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ jobs:

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

env:
CC: gcc
CXX: g++
CONAN_USER_HOME: "${{github.workspace}}"

steps:
- name: Checkout repository
Expand Down Expand Up @@ -69,38 +64,13 @@ jobs:
- run: |
# Run Build - set up dependencies, env vars, compile, and make test
#install conan
pip install --no-cache-dir 'conan==1.66.0' --force-reinstall
# create conan config
CONAN_V2_MODE=1 conan config init
conan config set general.revisions_enabled=1
# add custom compiler settings for libc
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"))'
# Create Conan host profile
cat > "${{env.CONAN_USER_HOME}}/.conan/profiles/host" << "EOF"
[settings]
os=Linux
os_build=Linux
arch=${{matrix.conan_arch}}
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.libcxx=libstdc++11
compiler.libc=musl
build_type=Release
[options]
pcapplusplus:with_musl=True
[build_requires]
[env]
CC=${{github.workspace}}/toolchain/bin/${{matrix.cc}}
CXX=${{github.workspace}}/toolchain/bin/${{matrix.cxx}}
LDFLAGS=${{matrix.ldflags}}
EOF
pip install --no-cache-dir conan --force-reinstall
# clone the repository, not sure if this needs to be done
git clone https://github.com/netboxlabs/pktvisor.git
cd pktvisor
mkdir build && cd build
# configure and handle dependencies
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake ..
# build and run tests
sudo make all test
#remove conan files
Expand Down
Loading

0 comments on commit 7f90a05

Please sign in to comment.