From 454af422f6f6e2cb3cf9447297e3e3becd95fbf2 Mon Sep 17 00:00:00 2001 From: seladb Date: Tue, 24 Jan 2023 21:46:55 -0800 Subject: [PATCH] (#14712) pcapplusplus: add version v22.11 * Update recipe to PcapPlusPlus v22.11 * Add `test_v1_package` * Fix typo * Add sources for 22.11 * Trigger CI * Address comment in CMakeLists Co-authored-by: Uilian Ries * Remove `test_package.cpp` from `test_v1_package` * Try fixing the bin path * Apply changes suggested by @prince-chrismc * Fix bin folder * Fix test_v1_package bin dir * Revert bin location change * Simplify test package Signed-off-by: Uilian Ries Signed-off-by: Uilian Ries Co-authored-by: Uilian Ries --- recipes/pcapplusplus/all/conandata.yml | 9 ++++ recipes/pcapplusplus/all/conanfile.py | 8 ++-- .../all/test_package/1_packet.pcap | Bin 447 -> 0 bytes .../all/test_package/CMakeLists.txt | 9 ++-- .../all/test_package/conanfile.py | 30 ++++-------- .../all/test_package/test_package.cpp | 45 ++---------------- .../all/test_v1_package/CMakeLists.txt | 8 ++++ .../all/test_v1_package/conanfile.py | 18 +++++++ recipes/pcapplusplus/config.yml | 2 + 9 files changed, 60 insertions(+), 69 deletions(-) delete mode 100644 recipes/pcapplusplus/all/test_package/1_packet.pcap create mode 100644 recipes/pcapplusplus/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/pcapplusplus/all/test_v1_package/conanfile.py diff --git a/recipes/pcapplusplus/all/conandata.yml b/recipes/pcapplusplus/all/conandata.yml index 9786a06e3c7e2..ff3d1d4847765 100644 --- a/recipes/pcapplusplus/all/conandata.yml +++ b/recipes/pcapplusplus/all/conandata.yml @@ -8,6 +8,9 @@ sources: "22.05": url: "https://github.com/seladb/PcapPlusPlus/archive/v22.05.tar.gz" sha256: "5f299c4503bf5d3c29f82b8d876a19be7dea29c2aadcb52f2f3b394846c21da9" + "22.11": + url: "https://github.com/seladb/PcapPlusPlus/archive/v22.11.tar.gz" + sha256: "3172f12f2f8a8902ae1ad6be5d65c3059c42c49c1a28e97e5d8d25a48b05e44f" patches: "21.05": - patch_file: "patches/0001-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch" @@ -50,3 +53,9 @@ patches: patch_description: Fix md5 include configuration patch_type: conan base_path: source_subfolder + + "22.11": + - patch_file: "patches/0002-Pass-CXXFLAGS-CPPFLAGS-when-compiling-3rd-party-sour.patch" + patch_description: Pass CXXFLAGS and CPPFLAGS when-compiling 3rd party source + patch_type: conan + base_path: "source_subfolder" diff --git a/recipes/pcapplusplus/all/conanfile.py b/recipes/pcapplusplus/all/conanfile.py index ef9a8444da061..680bbfb33f9d8 100644 --- a/recipes/pcapplusplus/all/conanfile.py +++ b/recipes/pcapplusplus/all/conanfile.py @@ -40,8 +40,9 @@ def config_options(self): def requirements(self): if self.settings.os == "Windows": - self.requires("pthreads4w/3.0.0") self.requires("npcap/1.70") + if self.version < "22.11": + self.requires("pthreads4w/3.0.0") else: self.requires("libpcap/1.9.1") @@ -86,9 +87,10 @@ def _build_windows(self): config_args = [ "configure-windows-visual-studio.bat", "--pcap-sdk", self.deps_cpp_info["npcap"].rootpath, - "--pthreads-home", self.deps_cpp_info["pthreads4w"].rootpath, "--vs-version", "vs2015", ] + if self.version < "22.11": + config_args += ["--pthreads-home", self.deps_cpp_info["pthreads4w"].rootpath] self.run(" ".join(config_args), run_environment=True) msbuild = MSBuild(self) targets = ['Common++', 'Packet++', 'Pcap++'] @@ -120,7 +122,7 @@ def package(self): def package_info(self): self.cpp_info.libs = ["Pcap++", "Packet++", "Common++"] - if self.settings.os in ("FreeBSD", "Linux"): + if self.version < "22.11" and self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs.append("pthread") if self.settings.os == "Macos": self.cpp_info.frameworks.extend(["CoreFoundation", "Security", "SystemConfiguration"]) diff --git a/recipes/pcapplusplus/all/test_package/1_packet.pcap b/recipes/pcapplusplus/all/test_package/1_packet.pcap deleted file mode 100644 index b3aa1e0fed7714bf4bbe5530798ed5a28995deb5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 447 zcmca|c+)~A1{MYcU}0bca;n=bLyphjW0(%)fN;(S&rSF84BTcZ|Nh0n;L5<*$-v;i z;2@}Si;IDw3y2vROds #include -#include -#include -#include +#include -int main(int argc, char **argv) { - if (argc < 2) { - std::cerr << "ERROR: Need at least one argument" << std::endl; - return 1; - } - - // open a pcap file for reading - pcpp::PcapFileReaderDevice reader(argv[1]); - if (!reader.open()) { - std::cerr << "ERROR: Error opening the pcap file" << std::endl; - return 1; - } - - // read the first (and only) packet from the file - pcpp::RawPacket rawPacket; - if (!reader.getNextPacket(rawPacket)) { - std::cerr << "ERROR: Couldn't read the first packet in the file" << std::endl; - return 1; - } - - // parse the raw packet into a parsed packet - pcpp::Packet parsedPacket(&rawPacket); - - // verify the packet is IPv4 - if (parsedPacket.isPacketOfType(pcpp::IPv4)) { - // extract source and dest IPs - pcpp::IPv4Address srcIP = parsedPacket.getLayerOfType()->getSrcIPv4Address(); - pcpp::IPv4Address destIP = parsedPacket.getLayerOfType()->getDstIPv4Address(); - - // print source and dest IPs - std::cout << "Source IP is '" << srcIP.toString() << "'; Dest IP is '" << destIP.toString() << "'" << std::endl; - } - - // close the file - reader.close(); - - return 0; +int main() { + std::cout << "PCAP++ VERSION: " << pcpp::getPcapPlusPlusVersionFull() << std::endl; + return EXIT_SUCCESS; } diff --git a/recipes/pcapplusplus/all/test_v1_package/CMakeLists.txt b/recipes/pcapplusplus/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/pcapplusplus/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/pcapplusplus/all/test_v1_package/conanfile.py b/recipes/pcapplusplus/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/pcapplusplus/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/pcapplusplus/config.yml b/recipes/pcapplusplus/config.yml index 5a01a9fd55268..26e119bb00764 100644 --- a/recipes/pcapplusplus/config.yml +++ b/recipes/pcapplusplus/config.yml @@ -5,3 +5,5 @@ versions: folder: all "22.05": folder: all + "22.11": + folder: all