Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pcapplusplus: add version v22.11 #14712

Merged
merged 15 commits into from
Jan 25, 2023
9 changes: 9 additions & 0 deletions recipes/pcapplusplus/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
8 changes: 5 additions & 3 deletions recipes/pcapplusplus/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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++']
Expand Down Expand Up @@ -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"])
Expand Down
5 changes: 3 additions & 2 deletions recipes/pcapplusplus/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test(self):
os.path.join(self.deps_cpp_info['libpcap'].bin_paths[0], "pcap.dll"),
os.path.join("bin", "wpcap.dll")
)
bin_path = os.path.join("bin", "test_package")

bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
pcap_file_path = os.path.join(self.source_folder, "1_packet.pcap")
self.run(f"{bin_path} {pcap_file_path}", run_environment=True)
self.run(f"{bin_path} {pcap_file_path}", env="conanrun")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might have been some confusion, this has not been migrated so the "old" way should still be used AFAIK

I would try with as it previously was using

Suggested change
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
pcap_file_path = os.path.join(self.source_folder, "1_packet.pcap")
self.run(f"{bin_path} {pcap_file_path}", run_environment=True)
self.run(f"{bin_path} {pcap_file_path}", env="conanrun")
bin_path = os.path.join("bin", "test_package")
pcap_file_path = os.path.join(self.source_folder, "1_packet.pcap")
self.run(f"{bin_path} {pcap_file_path}", run_environment=True)

Binary file not shown.
8 changes: 8 additions & 0 deletions recipes/pcapplusplus/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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/)
38 changes: 38 additions & 0 deletions recipes/pcapplusplus/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from conan import ConanFile
from conan.tools.build import can_run
from conans import CMake
import os
import shutil


class PcapplusplusTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def requirements(self):
self.requires(self.tested_reference_str)
if can_run(self) and self.settings.os == "Windows":
self.requires("libpcap/1.10.1")

def configure(self):
if can_run(self) and self.settings.os == "Windows":
self.options["libpcap"].shared = True

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
if self.settings.os == "Windows":
# Use libpcap DLL as a replacement for npcap DLL
# It will not provide all the functions
# but it will cover enough to check that what we compiled is correct
shutil.copy(
os.path.join(self.deps_cpp_info['libpcap'].bin_paths[0], "pcap.dll"),
os.path.join("bin", "wpcap.dll")
)
bin_path = os.path.join("bin", "test_package")
pcap_file_path = os.path.join(self.source_folder, "1_packet.pcap")
self.run(f"{bin_path} {pcap_file_path}", run_environment=True)
2 changes: 2 additions & 0 deletions recipes/pcapplusplus/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ versions:
folder: all
"22.05":
folder: all
"22.11":
folder: all