From c8ebe44c23d1148c8a17c1881849b0714b416ec9 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 5 Apr 2024 17:03:38 +0300 Subject: [PATCH 1/5] libpcap: add support for dbus, libnl and rdma --- recipes/libpcap/all/conanfile.py | 46 +++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/recipes/libpcap/all/conanfile.py b/recipes/libpcap/all/conanfile.py index f8f592dda7427..d60beaf07d0f4 100644 --- a/recipes/libpcap/all/conanfile.py +++ b/recipes/libpcap/all/conanfile.py @@ -28,19 +28,20 @@ class LibPcapConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "enable_dbus": [True, False], + "enable_libnl": [True, False], "enable_libusb": [True, False], + "enable_rdma": [True, False], } default_options = { "shared": False, "fPIC": True, + "enable_dbus": False, + "enable_libnl": False, "enable_libusb": False, + "enable_rdma": False, } - # TODO: Add dbus-glib when available - # TODO: Add libnl-genl when available - # TODO: Add libbluetooth when available - # TODO: Add libibverbs when available - @property def _settings_build(self): return getattr(self, "settings_build", self.settings) @@ -50,6 +51,8 @@ def config_options(self): del self.options.fPIC if self.settings.os != "Linux": del self.options.enable_libusb + del self.options.enable_libnl + del self.options.enable_rdma def configure(self): if self.options.shared: @@ -66,6 +69,13 @@ def layout(self): def requirements(self): if self.options.get_safe("enable_libusb"): self.requires("libusb/1.0.26") + if self.options.get_safe("enable_libnl"): + self.requires("libnl/3.8.0") + if self.options.get_safe("enable_rdma"): + self.requires("rdma-core/49.0") + if self.options.get_safe("enable_dbus"): + self.requires("dbus/1.15.8", options={"with_glib": True}) + # TODO: Add libbluetooth when available def validate(self): if Version(self.version) < "1.10.0" and self.settings.os == "Macos" and self.options.shared: @@ -75,10 +85,12 @@ def validate(self): raise ConanInvalidConfiguration("cross-build of libpcap shared is broken on Apple") if Version(self.version) < "1.10.1" and self.settings.os == "Windows" and not self.options.shared: raise ConanInvalidConfiguration(f"{self.ref} can not be built static on Windows") + if self.options.get_safe("enable_dbus") and not self.dependencies["dbus"].options.with_glib: + raise ConanInvalidConfiguration("libpcap with dbus requires dbus/*:with_glib=True") def build_requirements(self): if self._settings_build.os == "Windows": - self.tool_requires("winflexbison/2.5.24") + self.tool_requires("winflexbison/2.5.25") else: self.tool_requires("bison/3.8.2") self.tool_requires("flex/2.6.4") @@ -105,16 +117,16 @@ def generate(self): VirtualRunEnv(self).generate(scope="build") tc = AutotoolsToolchain(self) - yes_no = lambda v: "yes" if v else "no" tc.configure_args.extend([ - f"--enable-usb={yes_no(self.options.get_safe('enable_libusb'))}", - "--disable-universal", - "--without-libnl", + "--disable-universal", # don't build universal binaries on macOS + "--enable-usb" if self.options.get_safe("enable_libusb") else "--disable-usb", + "--enable-dbus" if self.options.get_safe("enable_dbus") else "--disable-dbus", + "--enable-rdma" if self.options.get_safe("enable_rdma") else "--disable-rdma", + "--with-libnl" if self.options.get_safe("enable_libnl") else "--without-libnl", "--disable-bluetooth", - "--disable-packet-ring", - "--disable-dbus", - "--disable-rdma", ]) + if Version(self.version) < "1.10": + tc.configure_args.append("--disable-packet-ring") if cross_building(self): target_os = "linux" if self.settings.os == "Linux" else "null" tc.configure_args.append(f"--with-pcap={target_os}") @@ -171,3 +183,11 @@ def package_info(self): self.cpp_info.libs = [f"pcap{suffix}"] if self.settings.os == "Windows": self.cpp_info.system_libs = ["ws2_32"] + if self.options.get_safe("enable_libusb"): + self.cpp_info.requires.append("libusb::libusb") + if self.options.get_safe("enable_libnl"): + self.cpp_info.requires.append("libnl::nl-genl") + if self.options.get_safe("enable_rdma"): + self.cpp_info.requires.append("rdma-core::libibverbs") + if self.options.get_safe("enable_dbus"): + self.cpp_info.requires.append("dbus::dbus") From 4b8b25b41d5bc73940baf2c199a888167e4520e9 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 6 Apr 2024 14:14:43 +0300 Subject: [PATCH 2/5] libpcap: dbus:with_glib=True is not required --- recipes/libpcap/all/conanfile.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/recipes/libpcap/all/conanfile.py b/recipes/libpcap/all/conanfile.py index d60beaf07d0f4..9bf2ccdc11832 100644 --- a/recipes/libpcap/all/conanfile.py +++ b/recipes/libpcap/all/conanfile.py @@ -74,7 +74,7 @@ def requirements(self): if self.options.get_safe("enable_rdma"): self.requires("rdma-core/49.0") if self.options.get_safe("enable_dbus"): - self.requires("dbus/1.15.8", options={"with_glib": True}) + self.requires("dbus/1.15.8") # TODO: Add libbluetooth when available def validate(self): @@ -85,8 +85,6 @@ def validate(self): raise ConanInvalidConfiguration("cross-build of libpcap shared is broken on Apple") if Version(self.version) < "1.10.1" and self.settings.os == "Windows" and not self.options.shared: raise ConanInvalidConfiguration(f"{self.ref} can not be built static on Windows") - if self.options.get_safe("enable_dbus") and not self.dependencies["dbus"].options.with_glib: - raise ConanInvalidConfiguration("libpcap with dbus requires dbus/*:with_glib=True") def build_requirements(self): if self._settings_build.os == "Windows": From af9e1021d4c9b299a50d5b28f6f25279f427dd31 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 18:38:39 +0300 Subject: [PATCH 3/5] libpcap: update rdma-core --- recipes/libpcap/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libpcap/all/conanfile.py b/recipes/libpcap/all/conanfile.py index f21ecbca933f7..7f62c41a83217 100644 --- a/recipes/libpcap/all/conanfile.py +++ b/recipes/libpcap/all/conanfile.py @@ -74,7 +74,7 @@ def requirements(self): if self.options.get_safe("enable_libnl"): self.requires("libnl/3.8.0") if self.options.get_safe("enable_rdma"): - self.requires("rdma-core/49.0") + self.requires("rdma-core/52.0") if self.options.get_safe("enable_dbus"): self.requires("dbus/1.15.8") # TODO: Add libbluetooth when available From 9271f24e12a79e88b8bbb867c837127b6117fa97 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 24 Sep 2024 11:54:51 +0200 Subject: [PATCH 4/5] Add PkgConfigDeps Signed-off-by: Uilian Ries --- recipes/libpcap/all/conanfile.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/recipes/libpcap/all/conanfile.py b/recipes/libpcap/all/conanfile.py index 7f62c41a83217..0c94263addf04 100644 --- a/recipes/libpcap/all/conanfile.py +++ b/recipes/libpcap/all/conanfile.py @@ -4,8 +4,8 @@ from conan.tools.build import cross_building from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.env import VirtualBuildEnv, VirtualRunEnv -from conan.tools.files import chdir, copy, get, rm, rmdir -from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.files import chdir, copy, get, rm, rmdir, rename +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain, PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conan.tools.scm import Version @@ -137,8 +137,19 @@ def generate(self): tc.generate() AutotoolsDeps(self).generate() + pkg_config_deps = PkgConfigDeps(self) + # FIXME: https://github.com/conan-io/conan/issues/17048 + pkg_config_deps.set_property("libnl::nl-genl", "pkg_config_name", "libnl-genl-3.0") + pkg_config_deps.generate() + + def _patch_sources(self): + # TODO: Remove this after having https://github.com/conan-io/conan/issues/17048 fixed + if os.path.exists(os.path.join(self.generators_folder, "libnl-nl-genl.pc")): + rename(self, os.path.join(self.generators_folder, "libnl-nl-genl.pc"), + os.path.join(self.generators_folder, "libnl-genl-3.0.pc")) def build(self): + self._patch_sources() if self.settings.os == "Windows": cmake = CMake(self) cmake.configure() From 1d06f548828b05ae072e7e50bb7a43ac447ff4e2 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 24 Sep 2024 15:24:45 +0200 Subject: [PATCH 5/5] Use official libnl pc files Signed-off-by: Uilian Ries --- recipes/libpcap/all/conanfile.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/recipes/libpcap/all/conanfile.py b/recipes/libpcap/all/conanfile.py index 0c94263addf04..1cbe6a152dae8 100644 --- a/recipes/libpcap/all/conanfile.py +++ b/recipes/libpcap/all/conanfile.py @@ -4,7 +4,7 @@ from conan.tools.build import cross_building from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.env import VirtualBuildEnv, VirtualRunEnv -from conan.tools.files import chdir, copy, get, rm, rmdir, rename +from conan.tools.files import chdir, copy, get, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain, PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, is_msvc_static_runtime @@ -137,19 +137,10 @@ def generate(self): tc.generate() AutotoolsDeps(self).generate() - pkg_config_deps = PkgConfigDeps(self) - # FIXME: https://github.com/conan-io/conan/issues/17048 - pkg_config_deps.set_property("libnl::nl-genl", "pkg_config_name", "libnl-genl-3.0") - pkg_config_deps.generate() - - def _patch_sources(self): - # TODO: Remove this after having https://github.com/conan-io/conan/issues/17048 fixed - if os.path.exists(os.path.join(self.generators_folder, "libnl-nl-genl.pc")): - rename(self, os.path.join(self.generators_folder, "libnl-nl-genl.pc"), - os.path.join(self.generators_folder, "libnl-genl-3.0.pc")) + deps = PkgConfigDeps(self) + deps.generate() def build(self): - self._patch_sources() if self.settings.os == "Windows": cmake = CMake(self) cmake.configure()