diff --git a/3rd_party/dpdk/conandata.yml b/3rd_party/dpdk/conandata.yml new file mode 100644 index 00000000..9d9c8ffd --- /dev/null +++ b/3rd_party/dpdk/conandata.yml @@ -0,0 +1,8 @@ +sources: + "nbi.21.05": + url: "https://github.com/spdk/dpdk/archive/bad3c0e51d7a34e3188d75d94f15a36c8f5e8301.zip" + sha256: "a0db10b41ab8cbfbc19acca517ee6ebb574885b964a02e649b16d084747ce2a6" +patches: + "nbi.21.05": + - patch_file: "numa.patch" + patch_type: "conan" diff --git a/3rd_party/dpdk/conanfile.py b/3rd_party/dpdk/conanfile.py index 47798a10..4155388b 100644 --- a/3rd_party/dpdk/conanfile.py +++ b/3rd_party/dpdk/conanfile.py @@ -1,65 +1,66 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +from conan import ConanFile +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.files import patch, get -from conans import ConanFile, tools, Meson -from conans.tools import os_info, SystemPackageTool import glob, os +from os.path import join + +required_conan_version = ">=1.60.0" class LibDPDKConan(ConanFile): name = "dpdk" - version = "21.05" description = "Data Plane Development Kit" url = "https://github.corp.ebay.com/conan/dpdk" homepage = "https://github.com/dpdk/dpdk" license = "BSD-3" - generators = "pkg_config" - exports = ["LICENSE.md", "numa.patch"] source_subfolder = "source_subfolder" settings = "os", "compiler", "build_type", "arch" options = { - "shared": [True, False], - "fPIC": [True, False], - "numa": [True, False], - "native_build": [True, False], + "shared": ['True', 'False'], + "fPIC": ['True', 'False'], + "numa": ['True', 'False'], + "native_build": ['True', 'False'], + } + default_options = { + "shared": False, + "fPIC": True, + "numa": False, + "native_build": False, } - default_options = ( - "shared=False", - "fPIC=True", - "numa=False", - "native_build=False", - ) - scm = {"type" : "git", - "subfolder" : source_subfolder, - "url" : "https://github.com/spdk/dpdk.git", - "revision" : "bad3c0e51d7a34e3188d75d94f15a36c8f5e8301"} - build_requires = ( - "meson/0.59.0", - ) + exports_sources = ("LICENSE.md", "numa.patch") + no_copy_source=True + + def build_requirements(self): + self.tool_requires("meson/0.59.3") def configure(self): del self.settings.compiler.libcxx def source(self): - tools.patch(strip=0, base_path=self.source_subfolder, patch_file="numa.patch") + get(self, **self.conan_data["sources"][self.version], strip_root=True) + patch_file = os.path.join(self.export_sources_folder, "numa.patch") + patch(self, patch_file=patch_file) - def build(self): - meson = Meson(self) - meson_options = { - 'machine': 'default', - 'use_numa': 'false', - } + def generate(self): + tc = MesonToolchain(self) + tc.project_options["machine"] = "generic" + tc.preprocessor_definitions["use_numa"] = "false" if self.options.native_build: - meson_options['machine'] = 'native' + tc.project_options['machine'] = 'native' if self.options.numa: - meson_options['use_numa'] = 'true' - meson.configure(build_folder="build", defs=meson_options, source_folder="{}/{}".format(self.source_folder, self.source_subfolder)) + tc.preprocessor_definitions['use_numa'] = 'true' + tc.generate() + + def build(self): + meson = Meson(self) + meson.configure() meson.build() def package(self): meson = Meson(self) - meson.install(build_dir="build") + meson.install() removed_libs = glob.glob("{}/lib/*.a".format(self.package_folder), recursive=True) if not self.options.shared: @@ -71,7 +72,7 @@ def package(self): def package_info(self): self.cpp_info.libs = [ - "-Wl,--whole-archive -lrte_eal", + "rte_eal", "rte_timer", "rte_power", "rte_mempool", @@ -83,12 +84,12 @@ def package_info(self): "rte_pci", "rte_kvargs", "rte_net", - "-lrte_cryptodev", - "-lrte_ethdev", - "-lrte_rcu -Wl,--no-whole-archive" + "rte_cryptodev", + "rte_ethdev", + "rte_rcu" ] if self.options.numa: self.cpp_info.libs.append("numa") if self.settings.os == "Linux": - self.cpp_info.libs.extend(["pthread", "dl"]) + self.cpp_info.system_libs.extend(["pthread", "dl"]) self.env_info.RTE_SDK = self.package_folder diff --git a/3rd_party/fio/arch.patch b/3rd_party/fio/arch.patch deleted file mode 100644 index 4272c9f2..00000000 --- a/3rd_party/fio/arch.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff -Naur t_old/arch.c t/arch.c ---- t_old/arch.c 2020-08-27 12:10:31.780692668 -0500 -+++ t/arch.c 2020-08-27 10:26:44.563345646 -0500 -@@ -1,5 +1,5 @@ - #include "../arch/arch.h" - - unsigned long arch_flags = 0; --bool tsc_reliable; -+// bool tsc_reliable; - int arch_random; diff --git a/3rd_party/fio/conandata.yml b/3rd_party/fio/conandata.yml new file mode 100644 index 00000000..e0b39dfb --- /dev/null +++ b/3rd_party/fio/conandata.yml @@ -0,0 +1,4 @@ +sources: + "nbi.3.28": + url: "https://github.com/axboe/fio/archive/fio-3.28.tar.gz" + sha256: "135a3455ab6e9251430bb1b12e97151daf4ff5d2d22e8472562c9998a753a04f" diff --git a/3rd_party/fio/conanfile.py b/3rd_party/fio/conanfile.py index 95424d46..e87e21d0 100644 --- a/3rd_party/fio/conanfile.py +++ b/3rd_party/fio/conanfile.py @@ -1,50 +1,45 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +from conan import ConanFile +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.files import get, copy +from os.path import join -from conans import ConanFile, AutoToolsBuildEnvironment -from conans import tools -import os +required_conan_version = ">=1.60.0" class LibFIOConan(ConanFile): name = "fio" - version = "3.28" description = "Flexible IO Kit" url = "https://github.corp.ebay.com/conan/fio" homepage = "https://github.com/axboe/fio" license = "GPL-2" - exports = ["arch.patch", "rm_raw.patch"] settings = "os", "arch", "compiler" options = { - "native_build": [True, False], + "native_build": ['True', 'False'], } - default_options = ( - "native_build=False", - ) - source_subfolder = "source_subfolder" + default_options = { + "native_build": False, + } def configure(self): del self.settings.compiler.libcxx def source(self): - tools.get("{0}/archive/fio-{1}.tar.gz".format(self.homepage, self.version)) - os.rename("%s-%s-%s" % (self.name, self.name, self.version), self.source_subfolder) -# tools.patch(strip=0, base_path=self.source_subfolder, patch_file="arch.patch") -# tools.patch(strip=0, base_path=self.source_subfolder, patch_file="rm_raw.patch") + get(self, **self.conan_data["sources"][self.version], strip_root=True) - def build(self): - autotools = AutoToolsBuildEnvironment(self) - cargs = [] + def generate(self): + tc = AutotoolsToolchain(self) + tc.configure_args = [] if not self.options.native_build: - cargs.append("--disable-native") - env_vars = autotools.vars - with tools.environment_append(env_vars): - with tools.chdir(self.source_subfolder): - autotools.configure(args=cargs) - autotools.make() + tc.configure_args.append("--disable-native") + tc.generate() + + def build(self): + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy("fio", dst="bin", src="{}/".format(self.source_subfolder), keep_path=False) - self.copy("*.h", dst="include/fio", src="{}/".format(self.source_subfolder), keep_path=True) + copy(self, "fio", self.build_folder, join(self.package_folder, "bin"), keep_path=False) + copy(self, "*.h", self.source_folder, dst=join(self.package_folder, "include/fio"), keep_path=True) def deploy(self): self.copy("fio", dst="/usr/local/bin/", src="bin") diff --git a/3rd_party/fio/rm_raw.patch b/3rd_party/fio/rm_raw.patch deleted file mode 100644 index e2e9a9b5..00000000 --- a/3rd_party/fio/rm_raw.patch +++ /dev/null @@ -1,109 +0,0 @@ -diff --git a/diskutil.c b/diskutil.c -index 0051a7a0..ace7af3d 100644 ---- a/diskutil.c -+++ b/diskutil.c -@@ -166,14 +166,10 @@ static int get_device_numbers(char *file_name, int *maj, int *min) - if (S_ISBLK(st.st_mode)) { - majdev = major(st.st_rdev); - mindev = minor(st.st_rdev); -- } else if (S_ISCHR(st.st_mode)) { -- majdev = major(st.st_rdev); -- mindev = minor(st.st_rdev); -- if (fio_lookup_raw(st.st_rdev, &majdev, &mindev)) -- return -1; -- } else if (S_ISFIFO(st.st_mode)) -+ } else if (S_ISCHR(st.st_mode) || -+ S_ISFIFO(st.st_mode)) { - return -1; -- else { -+ } else { - majdev = major(st.st_dev); - mindev = minor(st.st_dev); - } -diff --git a/fio.1 b/fio.1 -index 6cc82542..9c12ad13 100644 ---- a/fio.1 -+++ b/fio.1 -@@ -1700,9 +1700,7 @@ Sets size to something really large and waits for ENOSPC (no space left on - device) or EDQUOT (disk quota exceeded) - as the terminating condition. Only makes sense with sequential - write. For a read workload, the mount point will be filled first then I/O --started on the result. This option doesn't make sense if operating on a raw --device node, since the size of that is already known by the file system. --Additionally, writing beyond end-of-device will not return ENOSPC there. -+started on the result. - .SS "I/O engine" - .TP - .BI ioengine \fR=\fPstr -diff --git a/os/os-linux.h b/os/os-linux.h -index f7137abe..16ed5258 100644 ---- a/os/os-linux.h -+++ b/os/os-linux.h -@@ -14,7 +14,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -41,7 +40,6 @@ - #define FIO_HAVE_IOSCHED_SWITCH - #define FIO_HAVE_ODIRECT - #define FIO_HAVE_HUGETLB --#define FIO_HAVE_RAWBIND - #define FIO_HAVE_BLKTRACE - #define FIO_HAVE_CL_SIZE - #define FIO_HAVE_CGROUPS -@@ -178,36 +176,6 @@ static inline unsigned long long os_phys_mem(void) - return (unsigned long long) pages * (unsigned long long) pagesize; - } - --static inline int fio_lookup_raw(dev_t dev, int *majdev, int *mindev) --{ -- struct raw_config_request rq; -- int fd; -- -- if (major(dev) != RAW_MAJOR) -- return 1; -- -- /* -- * we should be able to find /dev/rawctl or /dev/raw/rawctl -- */ -- fd = open("/dev/rawctl", O_RDONLY); -- if (fd < 0) { -- fd = open("/dev/raw/rawctl", O_RDONLY); -- if (fd < 0) -- return 1; -- } -- -- rq.raw_minor = minor(dev); -- if (ioctl(fd, RAW_GETBIND, &rq) < 0) { -- close(fd); -- return 1; -- } -- -- close(fd); -- *majdev = rq.block_major; -- *mindev = rq.block_minor; -- return 0; --} -- - #ifdef O_NOATIME - #define FIO_O_NOATIME O_NOATIME - #else -diff --git a/os/os.h b/os/os.h -index e47d3d97..17daf91d 100644 ---- a/os/os.h -+++ b/os/os.h -@@ -157,10 +157,6 @@ extern int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu); - #define OS_RAND_MAX RAND_MAX - #endif - --#ifndef FIO_HAVE_RAWBIND --#define fio_lookup_raw(dev, majdev, mindev) 1 --#endif -- - #ifndef FIO_PREFERRED_ENGINE - #define FIO_PREFERRED_ENGINE "psync" - #endif diff --git a/3rd_party/pistache/conandata.yml b/3rd_party/pistache/conandata.yml new file mode 100644 index 00000000..52f5d1cd --- /dev/null +++ b/3rd_party/pistache/conandata.yml @@ -0,0 +1,28 @@ +sources: + "nbi.0.0.5": + url: "https://github.com/pistacheio/pistache/archive/refs/tags/0.0.5.tar.gz" + sha256: "e2da87ebc01367e33bd8d7800cb2bf5c23e9fb4e6f49dce2cab5f8756df8dca0" + "cci.20240107": + url: "https://github.com/pistacheio/pistache/archive/1c733a145b01a4737cf5c7dd3709bd85be404886.tar.gz" + sha256: "156d2a4503be3d6c0726009c83e6d2e6e2e6378e6136436fc2d82d13597b6b0b" + "cci.20201127": + url: "https://github.com/pistacheio/pistache/archive/a3c5c68e0f08e19331d53d12846079ad761fe974.tar.gz" + sha256: "f1abb9e43ff847ebff8edb72623c9942162df134bccfb571af9c7817d3261fae" +patches: + "nbi.0.0.5": + - patch_file: "patches/0.0.5-0001-include-cstdint.patch" + patch_description: "include " + patch_type: "portability" + patch_source: "https://github.com/pistacheio/pistache/pull/1142" + "cci.20201127": + - patch_file: "patches/cci.20201127-0001-remove-fpic.patch" + patch_description: "disable fPIC" + patch_type: "conan" + - patch_file: "patches/cci.20201127-0002-include-stddef.patch" + patch_description: "include " + patch_type: "portability" + patch_source: "https://github.com/pistacheio/pistache/pull/965" + - patch_file: "patches/cci.20201127-0003-include-cstdint.patch" + patch_description: "include " + patch_type: "portability" + patch_source: "https://github.com/pistacheio/pistache/pull/1142" diff --git a/3rd_party/pistache/conanfile.py b/3rd_party/pistache/conanfile.py new file mode 100644 index 00000000..3577526d --- /dev/null +++ b/3rd_party/pistache/conanfile.py @@ -0,0 +1,179 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir, replace_in_file, collect_libs +from conan.tools.build import check_min_cppstd +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.layout import basic_layout +from conan.tools.gnu import PkgConfigDeps + +import os + +required_conan_version = ">=1.53.0" + +class PistacheConan(ConanFile): + name = "pistache" + description = "Pistache is a modern and elegant HTTP and REST framework for C++" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/pistacheio/pistache" + topics = ("http", "rest", "framework", "networking") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_ssl": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_ssl": False, + } + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "clang": "6", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + if self.version == "cci.20201127": + cmake_layout(self, src_folder="src") + else: + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("rapidjson/cci.20230929") + if self.options.with_ssl: + self.requires("openssl/[>=1.1 <4]") + if self.version != "cci.20201127": + self.requires("date/3.0.1") + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration(f"{self.ref} is only support on Linux.") + + if self.settings.compiler == "clang" and self.version in ["cci.20201127", "0.0.5"]: + raise ConanInvalidConfiguration(f"{self.ref}'s clang support is broken. See pistacheio/pistache#835.") + + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def build_requirements(self): + if self.version != "cci.20201127": + self.tool_requires("meson/1.3.1") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/2.1.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + if self.version == "cci.20201127": + tc = CMakeToolchain(self) + tc.variables["PISTACHE_ENABLE_NETWORK_TESTS"] = False + tc.variables["PISTACHE_USE_SSL"] = self.options.with_ssl + # pistache requires explicit value for fPIC + tc.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) + tc.generate() + + tc = CMakeDeps(self) + tc.generate() + else: + tc = MesonToolchain(self) + tc.project_options["PISTACHE_USE_SSL"] = self.options.with_ssl + tc.project_options["PISTACHE_BUILD_EXAMPLES"] = False + tc.project_options["PISTACHE_BUILD_TESTS"] = False + tc.project_options["PISTACHE_BUILD_DOCS"] = False + tc.generate() + + tc = PkgConfigDeps(self) + tc.generate() + + env = VirtualBuildEnv(self) + env.generate(scope="build") + + def build(self): + apply_conandata_patches(self) + if self.version != "cci.20201127": + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), + "dependency('RapidJSON', fallback: ['rapidjson', 'rapidjson_dep'])", + "dependency('rapidjson', fallback: ['rapidjson', 'rapidjson_dep'])") + + if self.version == "cci.20201127": + cmake = CMake(self) + cmake.configure() + cmake.build() + else: + meson = Meson(self) + meson.configure() + meson.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + if self.version == "cci.20201127": + cmake = CMake(self) + cmake.install() + else: + meson = Meson(self) + meson.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + if self.options.shared: + rm(self, "*.a", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) + + def package_info(self): + # TODO: Pistache does not use namespace + # TODO: Pistache variables are CamelCase e.g Pistache_BUILD_DIRS + self.cpp_info.set_property("cmake_file_name", "Pistache") + self.cpp_info.set_property("cmake_target_name", "Pistache::Pistache") + # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) + self.cpp_info.set_property("pkg_config_name", "libpistache") + + self.cpp_info.components["libpistache"].libs = collect_libs(self) + self.cpp_info.components["libpistache"].requires = ["rapidjson::rapidjson"] + if self.version != "cci.20201127": + self.cpp_info.components["libpistache"].requires.append("date::date") + if self.options.with_ssl: + self.cpp_info.components["libpistache"].requires.append("openssl::openssl") + self.cpp_info.components["libpistache"].defines = ["PISTACHE_USE_SSL=1"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["libpistache"].system_libs = ["pthread"] + if self.version != "cci.20201127": + self.cpp_info.components["libpistache"].system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "Pistache" + self.cpp_info.filenames["cmake_find_package_multi"] = "Pistache" + self.cpp_info.names["cmake_find_package"] = "Pistache" + self.cpp_info.names["cmake_find_package_multi"] = "Pistache" + self.cpp_info.names["pkg_config"] = "libpistache" + suffix = "_{}".format("shared" if self.options.shared else "static") + self.cpp_info.components["libpistache"].names["cmake_find_package"] = "pistache" + suffix + self.cpp_info.components["libpistache"].names["cmake_find_package_multi"] = "pistache" + suffix diff --git a/3rd_party/pistache/patches/0.0.5-0001-include-cstdint.patch b/3rd_party/pistache/patches/0.0.5-0001-include-cstdint.patch new file mode 100644 index 00000000..459b71e8 --- /dev/null +++ b/3rd_party/pistache/patches/0.0.5-0001-include-cstdint.patch @@ -0,0 +1,13 @@ +diff --git a/include/pistache/flags.h b/include/pistache/flags.h +index 9be2b32..ed37150 100644 +--- a/include/pistache/flags.h ++++ b/include/pistache/flags.h +@@ -11,7 +11,7 @@ + */ + + #pragma once +- ++#include + #include + #include + #include diff --git a/3rd_party/pistache/patches/cci.20201127-0001-remove-fpic.patch b/3rd_party/pistache/patches/cci.20201127-0001-remove-fpic.patch new file mode 100644 index 00000000..fa8d26ee --- /dev/null +++ b/3rd_party/pistache/patches/cci.20201127-0001-remove-fpic.patch @@ -0,0 +1,12 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 9cdac6b..b2d13b4 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -12,7 +12,6 @@ set(SOURCE_FILES + ) + + add_library(pistache OBJECT ${SOURCE_FILES}) +-set_target_properties(pistache PROPERTIES POSITION_INDEPENDENT_CODE 1) + add_definitions(-DONLY_C_LOCALE=1) + + set(PISTACHE_INCLUDE diff --git a/3rd_party/pistache/patches/cci.20201127-0002-include-stddef.patch b/3rd_party/pistache/patches/cci.20201127-0002-include-stddef.patch new file mode 100644 index 00000000..1f4d2425 --- /dev/null +++ b/3rd_party/pistache/patches/cci.20201127-0002-include-stddef.patch @@ -0,0 +1,12 @@ +fixed upstream https://github.com/pistacheio/pistache/pull/965 + +--- a/include/pistache/typeid.h ++++ b/include/pistache/typeid.h +@@ -11,6 +11,7 @@ + + #pragma once + ++#include + #include + + namespace Pistache { diff --git a/3rd_party/pistache/patches/cci.20201127-0003-include-cstdint.patch b/3rd_party/pistache/patches/cci.20201127-0003-include-cstdint.patch new file mode 100644 index 00000000..93b9a356 --- /dev/null +++ b/3rd_party/pistache/patches/cci.20201127-0003-include-cstdint.patch @@ -0,0 +1,13 @@ +diff --git a/include/pistache/flags.h b/include/pistache/flags.h +index 2538773..fcd0252 100644 +--- a/include/pistache/flags.h ++++ b/include/pistache/flags.h +@@ -5,7 +5,7 @@ + */ + + #pragma once +- ++#include + #include + #include + #include diff --git a/3rd_party/pistache/test_package/CMakeLists.txt b/3rd_party/pistache/test_package/CMakeLists.txt new file mode 100644 index 00000000..fd8a15bd --- /dev/null +++ b/3rd_party/pistache/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(Pistache REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Pistache::Pistache) +if(Pistache_VERSION EQUAL "cci.20201127") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +endif() diff --git a/3rd_party/pistache/test_package/conanfile.py b/3rd_party/pistache/test_package/conanfile.py new file mode 100644 index 00000000..a9fbb7f5 --- /dev/null +++ b/3rd_party/pistache/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/3rd_party/pistache/test_package/test_package.cpp b/3rd_party/pistache/test_package/test_package.cpp new file mode 100644 index 00000000..f29b0d71 --- /dev/null +++ b/3rd_party/pistache/test_package/test_package.cpp @@ -0,0 +1,27 @@ +#include "pistache/endpoint.h" + +using namespace Pistache; + +class HelloHandler : public Http::Handler { +public: + + HTTP_PROTOTYPE(HelloHandler) + + void onRequest(const Http::Request& request, Http::ResponseWriter response) override{ + response.send(Pistache::Http::Code::Ok, "Hello World\n"); + } +}; + +int main() { + Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(9080)); + auto opts = Pistache::Http::Endpoint::options() + .threads(1); + + Http::Endpoint server(addr); + server.init(opts); + server.setHandler(Http::make_handler()); + server.serveThreaded(); + server.shutdown(); + + return 0; +} diff --git a/3rd_party/pistache/test_v1_package/CMakeLists.txt b/3rd_party/pistache/test_v1_package/CMakeLists.txt new file mode 100644 index 00000000..be00a8c7 --- /dev/null +++ b/3rd_party/pistache/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +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/3rd_party/pistache/test_v1_package/conanfile.py b/3rd_party/pistache/test_v1_package/conanfile.py new file mode 100644 index 00000000..5a05af3c --- /dev/null +++ b/3rd_party/pistache/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/3rd_party/spdk/conandata.yml b/3rd_party/spdk/conandata.yml new file mode 100644 index 00000000..d8b3dacc --- /dev/null +++ b/3rd_party/spdk/conandata.yml @@ -0,0 +1,8 @@ +sources: + "nbi.21.07.y": + url: "https://github.com/SPDK/spdk/archive/96a91684d39bb0f18729f132a24b778876d3e8fc.tar.gz" + sha256: "07876855efed94cd62150366bf6d97d218bc1432be33c87991c28cb52761ec90" +patches: + "nbi.21.07.y": + - patch_file: "patches/patch.diff" + patch_type: "conan" diff --git a/3rd_party/spdk/conanfile.py b/3rd_party/spdk/conanfile.py index 7c13e6c8..78781df2 100644 --- a/3rd_party/spdk/conanfile.py +++ b/3rd_party/spdk/conanfile.py @@ -1,12 +1,15 @@ -#https://github.com/SPDK/spdk"!/usr/bin/env python -# -*- coding: utf-8 -*- +from conan import ConanFile +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps +from conan.tools.files import apply_conandata_patches +from conan.tools.files import patch, get, replace_in_file +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import copy +from os.path import join -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conan.tools.files import patch, copy, get +required_conan_version = ">=1.60.0" class LibSPDKConan(ConanFile): name = "spdk" - version = "21.07.y" description = "Data Plane Development Kit" url = "https://github.corp.ebay.com/conan/spdk" homepage = "https://github.com/SPDK/spdk" @@ -14,76 +17,91 @@ class LibSPDKConan(ConanFile): exports = ["LICENSE.md", "install.diff"] settings = "os", "compiler", "build_type", "arch" options = { - "native_build": [True, False], - "shared": [True, False], - "fPIC": [True, False] + "native_build": ['True', 'False'], + "shared": ['True', 'False'], + "fPIC": ['True', 'False'] + } + default_options = { + "native_build":True, + "shared":False, + "fPIC":True, } - default_options = ( - "native_build=False", - "shared=False", - "fPIC=True", - ) requires = ( - "dpdk/21.05", - "liburing/2.1", - "openssl/1.1.1q", ) build_requires = ( - "fio/3.28" ) exports_sources = "patches/*" + def requirements(self): + self.requires("dpdk/nbi.21.05", transitive_headers=True) + self.requires("liburing/2.4", transitive_headers=True) + self.requires("openssl/[>=1.1 <4]") + self.requires("fio/nbi.3.28") + def configure(self): del self.settings.compiler.libcxx def source(self): - get(self, "https://github.com/SPDK/spdk/archive/96a91684d39bb0f18729f132a24b778876d3e8fc.tar.gz", strip_root=True) + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) - def build(self): - patch(self, patch_file="patches/patch.diff", strip=1) - autotools = AutoToolsBuildEnvironment(self) - autotools.flags.append("-I{}/include".format(self.deps_cpp_info["openssl"].rootpath)) - cargs = ["--with-dpdk={}".format(self.deps_cpp_info["dpdk"].rootpath), + def generate(self): + tc = AutotoolsToolchain(self) + e = tc.environment() + e.append("CFLAGS", "-I{}/include".format(self.dependencies['openssl'].package_folder)) + e.append("CFLAGS", "-I{}/include".format(self.dependencies['liburing'].package_folder)) + e.append("LDFLAGS", "-L{}/lib".format(self.dependencies['openssl'].package_folder)) + e.append("LDFLAGS", "-L{}/lib".format(self.dependencies['liburing'].package_folder)) + e.append("LD_TYPE", "bfd") + + #autotools.flags.append("-I{}/include".format(self.deps_cpp_info["openssl"].rootpath)) + tc.configure_args = ["--with-dpdk={}".format(self.dependencies['dpdk'].package_folder), "--without-vhost", "--without-virtio", - "--with-fio={}/include/fio".format(self.deps_cpp_info["fio"].rootpath), - "--with-uring={}/include".format(self.deps_cpp_info["liburing"].rootpath), + "--with-fio={}/include/fio".format(self.dependencies['fio'].package_folder), + "--with-uring={}/include".format(self.dependencies['liburing'].package_folder), "--without-isal", "--disable-tests", - "--disable-unit-tests"] + "--disable-unit-tests", + "--prefix=/"] if not self.options.native_build: - cargs.append("--target-arch=corei7") - tools.replace_in_file("configure", "x86_64", "corei7") - tools.replace_in_file("configure", "march=native", "march=corei7") + tc.configure_args.append("--target-arch=corei7") + replace_in_file(self, "configure", "x86_64", "corei7") + replace_in_file(self, "configure", "march=native", "march=corei7") if self.settings.build_type == "Debug": - cargs.append("--enable-debug") - autotools.configure(args=cargs) - autotools.make(vars={ - "LD_TYPE":"bfd", - "LDFLAGS": "-L{0}/lib -L{1}/lib".format(self.deps_cpp_info["openssl"].rootpath, - self.deps_cpp_info["liburing"].rootpath) - }) + tc.configure_args.append("--enable-debug") + tc.generate(e) + + td = AutotoolsDeps(self) + td.generate() + + def build(self): + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy("common.sh", dst="scripts", src="scripts", keep_path=True) - self.copy("setup.sh", dst="scripts", src="scripts", keep_path=True) - self.copy("spdkcli*", dst="scripts", src="scripts", keep_path=True) - self.copy("rpc*", dst="scripts", src="scripts", keep_path=True) - self.copy("*.h", dst="include/spdk/lib", src="lib", keep_path=True) - self.copy("*.h", dst="include/spdk/module", src="module", keep_path=True) - autotools = AutoToolsBuildEnvironment(self) - autotools.install() + copy(self,"common.sh", dst=join(self.package_folder,"scripts"), src="scripts", keep_path=True) + copy(self,"setup.sh", dst=join(self.package_folder,"scripts"), src="scripts", keep_path=True) + copy(self,"spdkcli*", dst=join(self.package_folder,"scripts"), src="scripts", keep_path=True) + copy(self,"rpc*", dst=join(self.package_folder,"scripts"), src="scripts", keep_path=True) + + autotools = Autotools(self) + autotools.install(args=["DESTDIR={}".format(self.package_folder)]) + + copy(self,"*.h", dst=join(self.package_folder,"include/spdk/lib"), src="lib", keep_path=True) + copy(self,"*.h", dst=join(self.package_folder,"include/spdk/module"), src="module", keep_path=True) def deploy(self): - self.copy("*", dst="/usr/local/bin/spdk", src="bin") - self.copy("*", dst="/var/lib/spdk/scripts", src="scripts") - self.copy("*pci_ids.h", dst="/var/lib/spdk/include", src="include") + copy(self,"*", dst="/usr/local/bin/spdk", src="bin") + copy(self,"*", dst="/var/lib/spdk/scripts", src="scripts") + copy(self,"*pci_ids.h", dst="/var/lib/spdk/include", src="include") def package_info(self): self.cpp_info.libs = [ - "-Wl,--whole-archive -lspdk_accel_ioat", + "spdk_accel_ioat", "spdk_blobfs", "spdk_blob_bdev", "spdk_bdev_uring", @@ -123,6 +141,7 @@ def package_info(self): "spdk_env_dpdk", "spdk_util", "spdk_jsonrpc", - "-lspdk_json -Wl,--no-whole-archive", - "aio", "rt", "pthread", "uuid", "m"] + "spdk_json"] + + self.cpp_info.system_libs = ["aio", "rt", "pthread", "uuid", "m"] self.env_info.RTE_SDK = self.package_folder diff --git a/conanfile.py b/conanfile.py index 54c66806..239e910d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,8 +1,11 @@ from conan import ConanFile -from conan.tools.files import copy, get, save, load -from conans import CMake +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout +from conan.tools.files import copy from os.path import join, exists -import json + +required_conan_version = ">=1.60.0" class IOMgrConan(ConanFile): name = "iomgr" @@ -20,10 +23,10 @@ class IOMgrConan(ConanFile): "shared": ['True', 'False'], "fPIC": ['True', 'False'], "coverage": ['True', 'False'], - "grpc_support": ['True', 'False'], "sanitize": ['True', 'False'], - "spdk": ['True', 'False'], "testing" : ['full', 'off', 'epoll_mode', 'spdk_mode'], + "grpc_support": ['True', 'False'], + "spdk": ['True', 'False'], "fiber_impl" : ['boost', 'folly'] } default_options = { @@ -32,42 +35,49 @@ class IOMgrConan(ConanFile): 'coverage': False, 'grpc_support': False, 'sanitize': False, - 'spdk': True, 'testing': 'epoll_mode', + 'spdk': True, 'fiber_impl': 'boost', } - generators = "cmake", "cmake_find_package" exports_sources = "CMakeLists.txt", "cmake/*", "src/*", "test/*", "LICENSE" + def _min_cppstd(self): + return 20 + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd()) + def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") if self.settings.build_type == "Debug": if self.options.coverage and self.options.sanitize: raise ConanInvalidConfiguration("Sanitizer does not work with Code Coverage!") - if self.options.testing == 'off': + if self.conf.get("tools.build:skip_test", default=False): if self.options.coverage or self.options.sanitize: raise ConanInvalidConfiguration("Coverage/Sanitizer requires Testing!") if self.settings.arch != "x86_64": self.options["spdk"].native_build = True def build_requirements(self): - self.build_requires("gtest/1.14.0") - self.build_requires("cpr/1.10.4") + self.test_requires("gtest/1.14.0") + self.test_requires("cpr/1.10.4") def requirements(self): - self.requires("sisl/[~12.2, include_prerelease=True]@oss/master") + self.requires("sisl/[~12.2, include_prerelease=True]@oss/master", transitive_headers=True) if self.options.grpc_support: self.requires("grpc/[>=1.50]") - self.requires("liburing/2.4") + self.requires("liburing/2.4", transitive_headers=True) if self.options.spdk: - self.requires("spdk/21.07.y") - self.requires("pistache/0.0.5") + self.requires("spdk/nbi.21.07.y", transitive_headers=True) + self.requires("pistache/nbi.0.0.5", transitive_headers=True) self.requires("openssl/3.1.3", override=True) self.requires("libcurl/8.4.0", override=True) self.requires("lz4/1.9.4", override=True) self.requires("zstd/1.5.5", override=True) + self.requires("libunwind/1.8.0", override=True) def _download_grpc(self, folder): ref = self.dependencies['grpc'].ref.version @@ -81,40 +91,41 @@ def _download_grpc(self, folder): get(self, **source_info, destination=join(folder, "grpc_internal"), strip_root=True) save(self, touch_file_path, current_info_str) - def source(self): + def layout(self): if self.options.grpc_support: self._download_grpc(self.source_folder) + cmake_layout(self) def generate(self): if self.options.grpc_support: self._download_grpc(self.source_folder) - - def build(self): - cmake = CMake(self) - definitions = {'CMAKE_TEST_TARGET': self.options.testing, - 'CMAKE_EXPORT_COMPILE_COMMANDS': 'ON', - 'CONAN_CMAKE_SILENT_OUTPUT': 'ON', - 'MEMORY_SANITIZER_ON': 'OFF', - 'BUILD_TESTING': 'OFF', - } - if self.options.testing: - definitions['BUILD_TESTING'] = 'ON' - + # This generates "conan_toolchain.cmake" in self.generators_folder + tc = CMakeToolchain(self) + if not self.conf.get("tools.build:skip_test", default=False): + tc.variables["BUILD_TESTING"] = "ON" + tc.variables["CONAN_CMAKE_SILENT_OUTPUT"] = "ON" + tc.variables['CMAKE_EXPORT_COMPILE_COMMANDS'] = 'ON' + tc.variables["CTEST_OUTPUT_ON_FAILURE"] = "ON" + tc.variables["MEMORY_SANITIZER_ON"] = "OFF" + tc.variables["BUILD_COVERAGE"] = "OFF" + tc.variables["CMAKE_TEST_TARGET"] = self.options.testing if self.settings.build_type == "Debug": - if self.options.sanitize: - definitions['MEMORY_SANITIZER_ON'] = 'ON' - if self.options.coverage: - definitions['BUILD_COVERAGE'] = 'ON' + if self.options.get_safe("coverage"): + tc.variables['BUILD_COVERAGE'] = 'ON' + elif self.options.get_safe("sanitize"): + tc.variables['MEMORY_SANITIZER_ON'] = 'ON' + tc.generate() - if self.options.fiber_impl == "boost": - definitions['FIBER_IMPL'] = 'boost' - else: - definitions['FIBER_IMPL'] = 'folly' + # This generates "boost-config.cmake" and "grpc-config.cmake" etc in self.generators_folder + deps = CMakeDeps(self) + deps.generate() - cmake.configure(defs=definitions) + def build(self): + cmake = CMake(self) + cmake.configure() cmake.build() - if self.options.testing: - cmake.test(output_on_failure=True) + if not self.conf.get("tools.build:skip_test", default=False): + cmake.test() def package(self): copy(self, "LICENSE", self.source_folder, join(self.package_folder, "licenses"), keep_path=False) diff --git a/prepare.sh b/prepare.sh index 9c222851..0fcb0900 100755 --- a/prepare.sh +++ b/prepare.sh @@ -7,10 +7,12 @@ python -m pip install pyelftools > /dev/null echo "done." echo -n "Exporting custom recipes..." echo -n "dpdk." -conan export 3rd_party/dpdk +conan export 3rd_party/dpdk dpdk/nbi.21.05@ echo -n "fio." -conan export 3rd_party/fio +conan export 3rd_party/fio fio/nbi.3.28@ echo -n "spdk." -conan export 3rd_party/spdk +conan export 3rd_party/spdk spdk/nbi.21.07.y@ +echo -n "pistache." +conan export 3rd_party/pistache pistache/nbi.0.0.5@ echo "done." diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 79170dfe..9003a510 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.11) project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - set(CMAKE_CXX_STANDARD 20) find_package (Threads REQUIRED) find_package (iomgr REQUIRED) diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 038b3d18..497d9e05 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -1,11 +1,19 @@ -import os from conan import ConanFile -from conans import CMake -from conan.tools.build import cross_building +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(f"{bin_path} -c -h", run_environment=True) + if can_run(self): + sbin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(sbin_path, env="conanrun")