Skip to content

Commit

Permalink
chore: use conanfile.py for more flexibility (#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoparente authored Aug 22, 2024
1 parent e4a1ab8 commit c260fdc
Show file tree
Hide file tree
Showing 20 changed files with 66 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-cpp/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function build() {
cp -rf /github/workspace/integration_tests/ /pktvisor-src/integration_tests/
cp -rf /github/workspace/cmake/ /pktvisor-src/cmake/
cp -rf /github/workspace/CMakeLists.txt /pktvisor-src/
cp -rf /github/workspace/conanfile.txt /pktvisor-src/
cp -rf /github/workspace/conanfile.py /pktvisor-src/
mkdir /tmp/build
cd /tmp/build
cp -rf /pktvisor-src/build/conan_home/ .
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/build-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: Configure CMake
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: Configure CMake
Expand Down Expand Up @@ -170,16 +170,11 @@ jobs:
with:
version: 1.64.1

- name: Remove libpcap from conanfile
shell: bash
run: |
sed -i -e "s/libpcap.*//g" "${{github.workspace}}\conanfile.txt"
- name: Setup Conan Cache
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: Configure CMake
Expand Down Expand Up @@ -292,7 +287,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: Build pktvisord + push symbol to bugsplat.com
Expand Down Expand Up @@ -832,7 +827,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-arm64-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-arm64-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-arm64-

- name: Build pktvisord + push symbol to bugsplat.com
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: linux package install
Expand Down Expand Up @@ -282,16 +282,11 @@ jobs:
with:
version: 1.64.1

- name: Remove libpcap from conanfile
shell: bash
run: |
sed -i -e "s/libpcap.*//g" "${{github.workspace}}\conanfile.txt"
- name: Setup Conan Cache
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: Configure CMake
Expand Down Expand Up @@ -406,7 +401,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-arm64-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-arm64-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-arm64-

- name: Build pktvisord + push symbol to backtrace.io
Expand Down Expand Up @@ -528,7 +523,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: Build pktvisord + push symbol to backtrace.io
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build_cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ jobs:
path: src

- name: Remove crashpad from conanfile
run: |
sed -i -e "s/crashpad.*//g" ${{github.workspace}}/src/conanfile.txt
run: sed -i "/crashpad/d" ${{github.workspace}}/src/conanfile.py

- name: Install dependencies
run: |
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 @@ -39,7 +39,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: linux package install
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/conan_home/
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.txt', '*/conanfile.txt') }}
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-

- name: Build pktvisord + push symbol to backtrace.io
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ localconfig/
.cache/
.vscode/
build/
CMakeUserPresets.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ pktvisor is developed and tested on Linux and OSX. A Windows port is in progress
* CMake >= 3.13 (`cmake`)
* C++ compiler supporting C++17

For the list of packages included by conan, see [conanfile.txt](conanfile.txt)
For the list of packages included by conan, see [conanfile.py](conanfile.py)

#### Building

Expand Down
2 changes: 1 addition & 1 deletion cmd/pktvisor-reader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ find_package(docopt REQUIRED)

target_link_libraries(pktvisor-reader
PRIVATE
docopt::docopt
docopt_s
${VISOR_STATIC_PLUGINS}
)
2 changes: 1 addition & 1 deletion cmd/pktvisord/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ target_link_libraries(pktvisord
PRIVATE
timer
${ADDITIONAL_LIBS}
docopt::docopt
docopt_s
Visor::Core
${VISOR_STATIC_PLUGINS}
)
Expand Down
34 changes: 34 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from conan import ConanFile


class Pktvisor(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"

def requirements(self):
self.requires("catch2/3.6.0")
self.requires("corrade/2020.06")
self.requires("cpp-httplib/0.16.0")
self.requires("docopt.cpp/0.6.3")
self.requires("fast-cpp-csv-parser/cci.20240102")
self.requires("json-schema-validator/2.3.0")
self.requires("libmaxminddb/1.10.0")
self.requires("nlohmann_json/3.11.3")
self.requires("openssl/3.3.1")
if self.settings.os != "Windows":
self.requires("libpcap/1.10.4", force=True)
self.requires("opentelemetry-proto/1.3.0")
self.requires("pcapplusplus/23.09")
self.requires("abseil/20240116.2", force=True)
self.requires("protobuf/5.27.0")
self.requires("sigslot/1.2.2")
self.requires("spdlog/1.14.1")
self.requires("uvw/3.4.0")
self.requires("yaml-cpp/0.8.0")
self.requires("robin-hood-hashing/3.11.5")
self.requires("libcurl/8.9.1")
self.requires("crashpad/cci.20220219")

def build_requirements(self):
self.tool_requires("corrade/2020.06")
self.tool_requires("protobuf/5.27.0")
32 changes: 0 additions & 32 deletions conanfile.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY ./golang/ /pktvisor-src/golang/
COPY ./integration_tests/ /pktvisor-src/integration_tests/
COPY ./cmake/ /pktvisor-src/cmake/
COPY ./CMakeLists.txt /pktvisor-src/
COPY ./conanfile.txt /pktvisor-src/
COPY ./conanfile.py /pktvisor-src/

WORKDIR /tmp/build

Expand Down
6 changes: 3 additions & 3 deletions libs/visor_dns/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
message(STATUS "Visor Lib DNS Helper")

find_package(pcapplusplus REQUIRED)
find_package(PcapPlusPlus REQUIRED)
find_package(Catch2 REQUIRED)

add_library(VisorLibDns
Expand All @@ -19,7 +19,7 @@ target_include_directories(VisorLibDns
target_link_libraries(VisorLibDns
PUBLIC
Visor::Lib::Tcp
pcapplusplus::pcapplusplus
PcapPlusPlus::PcapPlusPlus
)

## TEST SUITE
Expand All @@ -30,7 +30,7 @@ add_executable(unit-tests-visor-dns
target_link_libraries(unit-tests-visor-dns
PRIVATE
Visor::Lib::Dns
catch2::catch2_with_main)
Catch2::Catch2WithMain)

add_test(NAME unit-tests-visor-dns
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/libs/visor_dns
Expand Down
4 changes: 2 additions & 2 deletions libs/visor_tcp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
message(STATUS "Visor Lib TCP Helper")

find_package(pcapplusplus REQUIRED)
find_package(PcapPlusPlus REQUIRED)

add_library(VisorLibTcp VisorTcpLayer.cpp)

Expand All @@ -13,5 +13,5 @@ target_include_directories(VisorLibTcp

target_link_libraries(VisorLibTcp
PUBLIC
pcapplusplus::pcapplusplus
PcapPlusPlus::PcapPlusPlus
)
2 changes: 1 addition & 1 deletion libs/visor_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ target_include_directories(VisorLibTest
target_link_libraries(VisorLibTest
INTERFACE
spdlog::spdlog
catch2::catch2_with_main)
Catch2::Catch2WithMain)

target_compile_features(VisorLibTest INTERFACE cxx_std_17)

Expand Down
6 changes: 3 additions & 3 deletions libs/visor_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
message(STATUS "Visor Lib Utils")

find_package(pcapplusplus REQUIRED)
find_package(PcapPlusPlus REQUIRED)
find_package(fmt REQUIRED)
find_package(Catch2 REQUIRED)

Expand All @@ -15,7 +15,7 @@ target_include_directories(VisorLibUtils

target_link_libraries(VisorLibUtils
PUBLIC
pcapplusplus::pcapplusplus
PcapPlusPlus::PcapPlusPlus
fmt::fmt
)

Expand All @@ -25,7 +25,7 @@ add_executable(unit-tests-visor-utils test_utils.cpp)
target_link_libraries(unit-tests-visor-utils
PRIVATE
Visor::Lib::Utils
catch2::catch2_with_main)
Catch2::Catch2WithMain)

add_test(NAME unit-tests-visor-utils
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/libs
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ target_link_libraries(unit-tests-visor-core
PRIVATE
Visor::Core
${VISOR_STATIC_PLUGINS}
catch2::catch2_with_main)
Catch2::Catch2WithMain)

add_test(NAME unit-tests-visor-core
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
Expand Down
4 changes: 2 additions & 2 deletions src/inputs/flow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ target_include_directories(VisorInputFlow
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)

find_package(pcapplusplus REQUIRED)
find_package(PcapPlusPlus REQUIRED)
find_package(uvw REQUIRED)

target_link_libraries(VisorInputFlow
PUBLIC
netflow
sflow
Visor::Core
pcapplusplus::pcapplusplus
PcapPlusPlus::PcapPlusPlus
uvw::uvw
)

Expand Down
2 changes: 1 addition & 1 deletion src/inputs/mock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ find_package(Catch2 REQUIRED)
target_link_libraries(unit-tests-input-mock
PRIVATE
Visor::Input::Mock
catch2::catch2_with_main)
Catch2::Catch2WithMain)

add_test(NAME unit-tests-input-mock
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
Expand Down
2 changes: 1 addition & 1 deletion src/inputs/pcap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ find_package(Catch2 REQUIRED)

target_link_libraries(unit-tests-input-pcap
PRIVATE Visor::Input::Pcap
catch2::catch2_with_main)
Catch2::Catch2WithMain)

add_test(NAME unit-tests-input-pcap
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
Expand Down

0 comments on commit c260fdc

Please sign in to comment.