Skip to content

Commit

Permalink
chore: upgrade to conan v2
Browse files Browse the repository at this point in the history
  • Loading branch information
leoparente committed Dec 9, 2024
1 parent 6b532ae commit 250d226
Show file tree
Hide file tree
Showing 20 changed files with 907 additions and 1,001 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.64.1' --force-reinstall
pip3 install 'conan==2.6.0' --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
16 changes: 8 additions & 8 deletions .github/workflows/build-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.6.0

- name: Setup OSX Environment
run: echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
Expand All @@ -62,7 +62,7 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
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 @@ -101,7 +101,7 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.6.0

- name: linux package install
run: |
Expand All @@ -123,7 +123,7 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
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 @@ -168,7 +168,7 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.6.0

- name: Setup Conan Cache
uses: actions/cache@v4
Expand All @@ -185,7 +185,7 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
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 @@ -393,12 +393,12 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.6.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: 8 additions & 8 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.6.0

- name: Setup Conan Cache
uses: actions/cache@v4
Expand All @@ -50,7 +50,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 @@ -84,12 +84,12 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.6.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 @@ -134,12 +134,12 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.6.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 @@ -280,7 +280,7 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.6.0

- name: Setup Conan Cache
uses: actions/cache@v4
Expand All @@ -297,7 +297,7 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
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
25 changes: 6 additions & 19 deletions .github/workflows/build_cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
env:
CC: gcc-10
CXX: g++-10
CONAN_USER_HOME: "${{github.workspace}}"
steps:
- name: Install sccache from cache
id: cache-sccache
Expand Down Expand Up @@ -69,19 +68,11 @@ jobs:
curl -L "${{matrix.toolchain}}" | tar -C toolchain -xz --strip-components=1
- name: Install Conan
run: pip install --no-cache-dir 'conan==1.64.1' --force-reinstall

- name: Create Conan configuration
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"))'
run: pip install --no-cache-dir 'conan==2.6.0' --force-reinstall

- name: Create Conan host profile
run: |
cat > "${{env.CONAN_USER_HOME}}/.conan/profiles/host" << "EOF"
cat > "${{github.workspace}}/host" << "EOF"
[settings]
os=Linux
os_build=Linux
Expand Down Expand Up @@ -116,23 +107,19 @@ jobs:
- name: Remove crashpad from conanfile
run: sed -i "/crashpad/d" ${{github.workspace}}/src/conanfile.py

- name: Install dependencies
run: |
mkdir build
cd build
conan install -pr:b default -pr:h host -g virtualenv --build=missing "${{github.workspace}}/src"
- name: Configure
run: |
mkdir build
cd build
source environment.sh.env
export CC CXX
export LDFLAGS=-static
cmake "${{github.workspace}}/src" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake \
-DCONAN_HOST_PROFILE="${{github.workspace}}/host" \
-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
Expand Down Expand Up @@ -175,7 +162,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: 2 additions & 2 deletions .github/workflows/build_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.6.0

- name: Setup Conan Cache
uses: actions/cache@v4
Expand All @@ -55,7 +55,7 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
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
4 changes: 2 additions & 2 deletions .github/workflows/code-ql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- run: |
# Run Build - set up dependencies, env vars, compile, and make test
#install conan
pip install --no-cache-dir 'conan==1.64.1' --force-reinstall
pip install --no-cache-dir 'conan==2.6.0' --force-reinstall
# create conan config
CONAN_V2_MODE=1 conan config init
conan config set general.revisions_enabled=1
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
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
make all test
#remove conan files
Expand Down
32 changes: 1 addition & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,41 +59,11 @@ if(NOT MSVC)
add_compile_options(-Wall -pedantic -W -Wextra -Wno-unknown-pragmas)
endif()

# Conan setup

include(conan)
conan_cmake_autodetect(CONAN_SETTINGS)
message(STATUS "Detected conan settings: ${CONAN_SETTINGS}")

set(PKTVISOR_CONAN_INIT ON CACHE BOOL "Create new Conan environment for the build.")
set(PKTVISOR_CONAN_BUILD "missing" CACHE STRING "Specify conan packages to build from source. Values are separated by semicolon.")
set(PKTVISOR_CONAN_BUILD_PROFILE "" CACHE STRING "Profile for the build environment.")
set(PKTVISOR_CONAN_HOST_PROFILE "" CACHE STRING "Profile for the host environment.")

if(PKTVISOR_CONAN_INIT)
message(STATUS "Using new Conan environment")
set(ENV{CONAN_USER_HOME} ${CMAKE_BINARY_DIR}/conan_home)
set(ENV{CONAN_REVISIONS_ENABLED} 1)
endif()

if(WIN32)
set(CUSTOM_CMAKE_OPTIONS docopt.cpp:boost_regex=True)
endif()

conan_cmake_install(
PATH_OR_REFERENCE ${PROJECT_SOURCE_DIR}
BUILD ${PKTVISOR_CONAN_BUILD}
PROFILE_BUILD ${PKTVISOR_CONAN_BUILD_PROFILE}
PROFILE_HOST ${PKTVISOR_CONAN_HOST_PROFILE}
GENERATOR cmake
SETTINGS ${CONAN_SETTINGS}
OPTIONS ${CUSTOM_CMAKE_OPTIONS}
INSTALL_FOLDER ${CMAKE_BINARY_DIR})

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

find_package(Corrade REQUIRED PluginManager)
find_package(Corrade REQUIRED)
include(sanitizer)
if(CODE_COVERAGE)
include(CodeCoverage)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ 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
make all test
Expand Down
2 changes: 1 addition & 1 deletion cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
# runs your test executable and produces a code coverage report.
#
# 6. Build a Debug build:
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake ..
# make
# make my_coverage_target
#
Expand Down
Loading

0 comments on commit 250d226

Please sign in to comment.