From 65b8e86e81eb887c1485810c022a47c545b2a60d Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Tue, 27 Aug 2024 17:26:35 -0600 Subject: [PATCH] Update recipe (#247) * Update recipe * Remove unused flavours. --- .github/workflows/build_dependencies.yml | 1 - .github/workflows/merge_conan_build.yml | 6 +- .github/workflows/pr_conan_build.yml | 6 +- .gitignore | 1 + 3rd_party/prerelease_dummy/conanfile.py | 23 ------- CMakeLists.txt | 23 ++----- cmake/debug_flags.cmake | 4 +- conanfile.py | 77 ++++++++++++++---------- src/CMakeLists.txt | 2 +- src/cache/CMakeLists.txt | 6 +- src/metrics/CMakeLists.txt | 2 +- src/utility/CMakeLists.txt | 16 ++--- src/version/tests/test_version.cpp | 3 +- src/version/version.cpp | 4 +- 14 files changed, 74 insertions(+), 100 deletions(-) delete mode 100644 3rd_party/prerelease_dummy/conanfile.py diff --git a/.github/workflows/build_dependencies.yml b/.github/workflows/build_dependencies.yml index 93f988f5..4f9ca3c6 100644 --- a/.github/workflows/build_dependencies.yml +++ b/.github/workflows/build_dependencies.yml @@ -104,7 +104,6 @@ jobs: conan export 3rd_party/folly folly/2022.01.31.00@ conan export 3rd_party/gperftools conan export 3rd_party/jemalloc - conan export 3rd_party/prerelease_dummy conan export 3rd_party/pistache pistache/cci.20201127@ cached_pkgs=$(ls -1d ~/.conan/data/*/*/*/*/export 2>/dev/null | sed 's,.*data/,,' | cut -d'/' -f1,2 | paste -sd',' - -) echo "::info:: Pre-cached: ${cached_pkgs}" diff --git a/.github/workflows/merge_conan_build.yml b/.github/workflows/merge_conan_build.yml index 884809b7..b4fbf42e 100644 --- a/.github/workflows/merge_conan_build.yml +++ b/.github/workflows/merge_conan_build.yml @@ -12,18 +12,14 @@ jobs: strategy: fail-fast: false matrix: - platform: ["ubuntu-22.04", "ubuntu-20.04"] + platform: ["ubuntu-22.04"] build-type: ["Debug", "Release"] malloc-impl: ["libc", "tcmalloc"] prerelease: ["True", "False"] exclude: - - build-type: Debug - platform: ubuntu-20.04 - malloc-impl: libc build-type: Release platform: ubuntu-22.04 - - prerelease: "True" - platform: ubuntu-20.04 uses: ./.github/workflows/build_dependencies.yml with: platform: ${{ matrix.platform }} diff --git a/.github/workflows/pr_conan_build.yml b/.github/workflows/pr_conan_build.yml index 7841bc5b..a37c1112 100644 --- a/.github/workflows/pr_conan_build.yml +++ b/.github/workflows/pr_conan_build.yml @@ -11,19 +11,15 @@ jobs: strategy: fail-fast: false matrix: - platform: ["ubuntu-22.04", "ubuntu-20.04"] + platform: ["ubuntu-22.04"] build-type: ["Debug", "Release"] malloc-impl: ["libc", "tcmalloc"] prerelease: ["True", "False"] exclude: - - build-type: Debug - platform: ubuntu-20.04 - build-type: Debug platform: tcmalloc - malloc-impl: libc build-type: Release - - prerelease: "True" - platform: ubuntu-20.04 uses: ./.github/workflows/build_dependencies.yml with: platform: ${{ matrix.platform }} diff --git a/.gitignore b/.gitignore index 5d114c73..8062cbb6 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,7 @@ cmake-*/** .vscode/** # Visual Studio +CMakeUserPresets.json CMakeSettings.json .vs/** diff --git a/3rd_party/prerelease_dummy/conanfile.py b/3rd_party/prerelease_dummy/conanfile.py deleted file mode 100644 index 34daaeed..00000000 --- a/3rd_party/prerelease_dummy/conanfile.py +++ /dev/null @@ -1,23 +0,0 @@ -from conans import ConanFile, CMake, tools - -class PrereleaseConan(ConanFile): - name = "prerelease_dummy" - version = "1.0.1" - homepage = "https://github.corp.ebay.com/SDS/prerelease_dummy" - description = "A dummy package to invoke PRERELEASE option" - topics = ("ebay", "nublox") - url = "https://github.corp.ebay.com/SDS/prerelease_dummy" - license = "Apache-2.0" - - settings = () - - exports_sources = ("LICENSE") - - def build(self): - pass - - def package(self): - pass - - def package_info(self): - self.cpp_info.cxxflags.append("-D_PRERELEASE=1") diff --git a/CMakeLists.txt b/CMakeLists.txt index 8944503d..7491b3d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,19 +59,15 @@ if (${MALLOC_IMPL} STREQUAL "tcmalloc") endif() find_package(jwt-cpp REQUIRED) find_package(nlohmann_json REQUIRED) -find_package(prerelease_dummy QUIET) find_package(prometheus-cpp REQUIRED) find_package(zmarok-semver REQUIRED) find_package(spdlog REQUIRED) find_package(Threads REQUIRED) -# Linux Specific dependencies -if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Linux) - find_package(breakpad REQUIRED) - find_package(folly REQUIRED) - find_package(userspace-rcu REQUIRED) - list (APPEND COMMON_DEPS breakpad::breakpad) -endif() +find_package(breakpad REQUIRED) +find_package(folly REQUIRED) +find_package(userspace-rcu REQUIRED) +list (APPEND COMMON_DEPS breakpad::breakpad) list (APPEND COMMON_DEPS Boost::headers @@ -86,10 +82,6 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Linux) ) endif() -if (${prerelease_dummy_FOUND}) - list (APPEND COMMON_DEPS prerelease_dummy::prerelease_dummy) -endif () - if (DEFINED MALLOC_IMPL) if (${MALLOC_IMPL} STREQUAL "tcmalloc") list(APPEND COMMON_DEPS gperftools::gperftools) @@ -112,13 +104,6 @@ endif() # add conan information add_flags("-DPACKAGE_NAME=sisl") -if (DEFINED CONAN_PACKAGE_VERSION) - message("Package Version: [${CONAN_PACKAGE_VERSION}]") - add_flags("-DPACKAGE_VERSION=\\\"${CONAN_PACKAGE_VERSION}\\\"") -else () - message("Unknown Package Version") - add_flags("-DPACKAGE_VERSION=\\\"${CONAN_PACKAGE_VERSION}\\\"") -endif () if(UNIX) # enable proper memstream flags diff --git a/cmake/debug_flags.cmake b/cmake/debug_flags.cmake index 6dab2ec2..fbe2cfdf 100644 --- a/cmake/debug_flags.cmake +++ b/cmake/debug_flags.cmake @@ -62,8 +62,8 @@ if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")) set (REALLY_NO_OPTIMIZATION_FLAGS "${REALLY_NO_OPTIMIZATION_FLAGS} -fthreadsafe-statics" )# Slightly smaller in code that doesn't need to be TS. endif() -if (DEFINED CONAN_BUILD_COVERAGE) - if (${CONAN_BUILD_COVERAGE}) +if (DEFINED BUILD_COVERAGE) + if (${BUILD_COVERAGE}) include (cmake/CodeCoverage.cmake) APPEND_COVERAGE_COMPILER_FLAGS() SETUP_TARGET_FOR_COVERAGE_GCOVR_XML(NAME coverage EXECUTABLE ctest DEPENDENCIES ) diff --git a/conanfile.py b/conanfile.py index 8cd7c3f4..2c16a3d7 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,14 +1,15 @@ -from os.path import join from conan import ConanFile -from conan.tools.files import copy +from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd -from conans import CMake +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout +from conan.tools.files import copy +from os.path import join -required_conan_version = ">=1.52.0" +required_conan_version = ">=1.60.0" class SISLConan(ConanFile): name = "sisl" - version = "8.7.0" + version = "8.8.0" homepage = "https://github.com/eBay/sisl" description = "Library for fast data structures, utilities" topics = ("ebay", "components", "core", "efficiency") @@ -34,20 +35,14 @@ class SISLConan(ConanFile): 'malloc_impl': 'tcmalloc', } - generators = "cmake", "cmake_find_package" exports_sources = ("CMakeLists.txt", "cmake/*", "include/*", "src/*", "LICENSE") def build_requirements(self): - self.build_requires("benchmark/1.7.0") - self.build_requires("gtest/1.11.0") - if self.settings.compiler in ["gcc"]: - self.build_requires("pistache/0.0.5") + self.test_requires("gtest/1.14.0") + self.test_requires("benchmark/1.8.2") + self.test_requires("pistache/0.0.5") def requirements(self): - # Custom packages - if self.options.prerelease: - self.requires("prerelease_dummy/1.0.1") - # Generic packages (conan-center) self.requires("boost/1.79.0") if self.settings.os in ["Linux"]: @@ -57,7 +52,7 @@ def requirements(self): self.requires("flatbuffers/1.12.0") if self.settings.os in ["Linux"]: self.requires("folly/2022.01.31.00") - self.requires("grpc/1.48.0") + self.requires("grpc/1.50.1") self.requires("jwt-cpp/0.4.0") self.requires("nlohmann_json/3.11.2") self.requires("prometheus-cpp/1.0.1") @@ -71,6 +66,7 @@ def requirements(self): self.requires("libcurl/8.4.0", override=True) self.requires("xz_utils/5.2.5", override=True) self.requires("zlib/1.2.12", override=True) + self.requires("lz4/1.9.4", override=True) if self.options.malloc_impl == "jemalloc": self.requires("jemalloc/5.2.1") elif self.options.malloc_impl == "tcmalloc": @@ -81,6 +77,8 @@ def validate(self): check_min_cppstd(self, 17) def configure(self): + if self.settings.compiler in ["gcc"]: + self.options['pistache'].with_ssl: True if self.options.shared: del self.options.fPIC if self.settings.build_type == "Debug": @@ -89,26 +87,40 @@ def configure(self): if self.options.coverage or self.options.sanitize: self.options.malloc_impl = 'libc' - def build(self): - cmake = CMake(self) - - definitions = {'CONAN_BUILD_COVERAGE': 'OFF', - 'CMAKE_EXPORT_COMPILE_COMMANDS': 'ON', - 'CONAN_CMAKE_SILENT_OUTPUT': 'ON', - 'MEMORY_SANITIZER_ON': 'OFF', - 'MALLOC_IMPL': self.options.malloc_impl} - + def layout(self): + cmake_layout(self) + + def generate(self): + # This generates "conan_toolchain.cmake" in self.generators_folder + tc = CMakeToolchain(self) + tc.variables["CONAN_CMAKE_SILENT_OUTPUT"] = "ON" + tc.variables["CTEST_OUTPUT_ON_FAILURE"] = "ON" + tc.variables["MEMORY_SANITIZER_ON"] = "OFF" + tc.variables["BUILD_COVERAGE"] = "OFF" + tc.variables['MALLOC_IMPL'] = self.options.malloc_impl + tc.preprocessor_definitions["PACKAGE_VERSION"] = self.version + tc.preprocessor_definitions["PACKAGE_NAME"] = self.name + if self.options.get_safe("prerelease") or (self.settings.build_type == "Debug"): + tc.preprocessor_definitions["_PRERELEASE"] = "1" + tc.variables["_PRERELEASE"] = "ON" if self.settings.build_type == "Debug": - if self.options.sanitize: - definitions['MEMORY_SANITIZER_ON'] = 'ON' - elif self.options.coverage: - definitions['CONAN_BUILD_COVERAGE'] = 'ON' + tc.preprocessor_definitions["_PRERELEASE"] = "1" + 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() - definitions['MALLOC_IMPL'] = self.options.malloc_impl + # 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() - cmake.test(output_on_failure=True) + if not self.conf.get("tools.build:skip_test", default=False): + cmake.test() def package(self): lib_dir = join(self.package_folder, "lib") @@ -136,6 +148,9 @@ def package_info(self): if self.settings.compiler == "gcc": self.cpp_info.cppflags.extend(["-fconcepts"]) + if self.options.get_safe("prerelease") or (self.settings.build_type == "Debug"): + self.cpp_info.defines.append("_PRERELEASE=1") + if self.settings.os == "Linux": self.cpp_info.libs.append("flip") self.cpp_info.cppflags.append("-D_POSIX_C_SOURCE=200809L") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d39a86c1..f62d804f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,7 +34,7 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Linux) $ ) list(APPEND SISL_DEPS - Folly::Folly + Folly::folly breakpad::breakpad ) endif() diff --git a/src/cache/CMakeLists.txt b/src/cache/CMakeLists.txt index 06b1f035..b89c5b72 100644 --- a/src/cache/CMakeLists.txt +++ b/src/cache/CMakeLists.txt @@ -11,7 +11,7 @@ target_sources(test_range_hashmap PRIVATE tests/test_range_hashmap.cpp ) target_include_directories(test_range_hashmap BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(test_range_hashmap sisl ${COMMON_DEPS} Folly::Folly GTest::gtest) +target_link_libraries(test_range_hashmap sisl ${COMMON_DEPS} Folly::folly GTest::gtest) #add_test(NAME RangeHashMap COMMAND test_range_hashmap --num_iters 10000) add_executable(test_range_cache) @@ -19,7 +19,7 @@ target_sources(test_range_cache PRIVATE tests/test_range_cache.cpp ) target_include_directories(test_range_cache BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(test_range_cache sisl ${COMMON_DEPS} Folly::Folly GTest::gtest) +target_link_libraries(test_range_cache sisl ${COMMON_DEPS} Folly::folly GTest::gtest) #add_test(NAME RangeCache COMMAND test_range_cache --num_iters 1000) add_executable(test_simple_cache) @@ -27,5 +27,5 @@ target_sources(test_simple_cache PRIVATE tests/test_simple_cache.cpp ) target_include_directories(test_simple_cache BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(test_simple_cache sisl ${COMMON_DEPS} Folly::Folly GTest::gtest) +target_link_libraries(test_simple_cache sisl ${COMMON_DEPS} Folly::folly GTest::gtest) add_test(NAME SimpleCache COMMAND test_simple_cache --num_iters 1000) diff --git a/src/metrics/CMakeLists.txt b/src/metrics/CMakeLists.txt index f14e62f7..6854a093 100644 --- a/src/metrics/CMakeLists.txt +++ b/src/metrics/CMakeLists.txt @@ -12,7 +12,7 @@ target_sources(sisl_metrics PRIVATE ) target_link_libraries(sisl_metrics ${COMMON_DEPS} - Folly::Folly + Folly::folly ) add_executable(metrics_farm_test) diff --git a/src/utility/CMakeLists.txt b/src/utility/CMakeLists.txt index 0b95585d..b31ff424 100644 --- a/src/utility/CMakeLists.txt +++ b/src/utility/CMakeLists.txt @@ -30,11 +30,13 @@ target_sources(test_enum PRIVATE target_link_libraries(test_enum ${COMMON_DEPS} GTest::gtest) add_test(NAME Enum COMMAND test_enum) -if (${prerelease_dummy_FOUND}) - add_executable(test_objlife) - target_sources(test_objlife PRIVATE - tests/test_objlife_counter.cpp - ) - target_link_libraries(test_objlife sisl ${COMMON_DEPS} GTest::gtest) - add_test(NAME ObjLife COMMAND test_objlife) +if (DEFINED ${_PRERELEASE}) + if (${_PRERELEASE}) + add_executable(test_objlife) + target_sources(test_objlife PRIVATE + tests/test_objlife_counter.cpp + ) + target_link_libraries(test_objlife sisl ${COMMON_DEPS} GTest::gtest) + add_test(NAME ObjLife COMMAND test_objlife) + endif () endif () diff --git a/src/version/tests/test_version.cpp b/src/version/tests/test_version.cpp index ee8f5f2b..ac93d91f 100644 --- a/src/version/tests/test_version.cpp +++ b/src/version/tests/test_version.cpp @@ -3,6 +3,7 @@ #include #include #include +#include using namespace sisl; @@ -10,7 +11,7 @@ SISL_OPTIONS_ENABLE(logging) SISL_LOGGING_INIT(test_version) void entry() { - auto ver{version::Semver200_version(PACKAGE_VERSION)}; + auto ver{version::Semver200_version(BOOST_PP_STRINGIZE(PACKAGE_VERSION))}; sisl::VersionMgr::addVersion("dummy", ver); } diff --git a/src/version/version.cpp b/src/version/version.cpp index faf1abd7..2885f2e4 100644 --- a/src/version/version.cpp +++ b/src/version/version.cpp @@ -15,6 +15,8 @@ * *********************************************************************************/ #include + +#include #include namespace sisl { @@ -24,7 +26,7 @@ std::once_flag VersionMgr::m_init_flag; void VersionMgr::createAndInit() { m_instance = new VersionMgr(); - auto ver{version::Semver200_version(PACKAGE_VERSION)}; + auto ver{version::Semver200_version(BOOST_PP_STRINGIZE(PACKAGE_VERSION))}; m_instance->m_version_map["sisl"] = ver; }