From 2183bfa8893e9efaa73edbdcebd255197a814ea6 Mon Sep 17 00:00:00 2001 From: toge Date: Mon, 26 Feb 2024 13:52:40 +0900 Subject: [PATCH 1/8] unleash-client-cpp: add version 1.3.0, support conan v2 --- recipes/unleash-client-cpp/all/CMakeLists.txt | 7 -- recipes/unleash-client-cpp/all/conandata.yml | 6 +- recipes/unleash-client-cpp/all/conanfile.py | 81 ++++++++----------- .../all/test_package/CMakeLists.txt | 7 +- .../all/test_package/conanfile.py | 19 +++-- recipes/unleash-client-cpp/config.yml | 2 + 6 files changed, 57 insertions(+), 65 deletions(-) delete mode 100644 recipes/unleash-client-cpp/all/CMakeLists.txt diff --git a/recipes/unleash-client-cpp/all/CMakeLists.txt b/recipes/unleash-client-cpp/all/CMakeLists.txt deleted file mode 100644 index b71c882d9d33f..0000000000000 --- a/recipes/unleash-client-cpp/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder) diff --git a/recipes/unleash-client-cpp/all/conandata.yml b/recipes/unleash-client-cpp/all/conandata.yml index 76a5bca8da701..7683a40843926 100644 --- a/recipes/unleash-client-cpp/all/conandata.yml +++ b/recipes/unleash-client-cpp/all/conandata.yml @@ -1,8 +1,12 @@ sources: + "1.3.0": + url: "https://github.com/aruizs/unleash-client-cpp/archive/refs/tags/v1.3.0.tar.gz" + sha256: "fa0b8d6101c6dbd08db23a3d353f386c17e9436a63d658f88c7d0b8619b8d501" "1.1.1": url: "https://github.com/aruizs/unleash-client-cpp/archive/refs/tags/v1.1.1.tar.gz" sha256: "2750dc231bf608910d4270ac39d83d46d25b88cc547a9d4d31f7ce4950effa7c" patches: "1.1.1": - patch_file: "patches/0001-no-conan-cmake.patch" - base_path: "source_subfolder" + patch_description: "remove conan cmake module" + patch_type: "portability" diff --git a/recipes/unleash-client-cpp/all/conanfile.py b/recipes/unleash-client-cpp/all/conanfile.py index 08a60bfc378de..af5cabe1791ba 100644 --- a/recipes/unleash-client-cpp/all/conanfile.py +++ b/recipes/unleash-client-cpp/all/conanfile.py @@ -1,18 +1,20 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir import os -required_conan_version = ">=1.43.0" - +required_conan_version = ">=1.53.0" class UnleashConan(ConanFile): name = "unleash-client-cpp" - homepage = "https://github.com/aruizs/unleash-client-cpp/" + description = "Unleash Client SDK for C++ projects." license = "MIT" url = "https://github.com/conan-io/conan-center-index" - description = "Unleash Client SDK for C++ projects." + homepage = "https://github.com/aruizs/unleash-client-cpp/" topics = ("unleash", "feature", "flag", "toggle") - + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -23,17 +25,6 @@ class UnleashConan(ConanFile): "fPIC": True, } - generators = "cmake", "cmake_find_package" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - @property def _min_cppstd(self): return "17" @@ -42,6 +33,7 @@ def _min_cppstd(self): def _compilers_min_version(self): return { "Visual Studio": "15", # Should we check toolset? + "msvc": "190", "gcc": "7", "clang": "4.0", "apple-clang": "3.8", @@ -49,9 +41,7 @@ def _compilers_min_version(self): } def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -61,13 +51,16 @@ def configure(self): if self.options.shared: del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") + def requirements(self): - self.requires("cpr/1.7.2") - self.requires("nlohmann_json/3.10.5") + self.requires("cpr/1.10.5") + self.requires("nlohmann_json/3.11.3") def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._min_cppstd) + check_min_cppstd(self, self._min_cppstd) def loose_lt_semver(v1, v2): lv1 = [int(v) for v in v1.split(".")] @@ -78,39 +71,33 @@ def loose_lt_semver(v1, v2): min_version = self._compilers_min_version.get(str(self.settings.compiler), False) if min_version and loose_lt_semver(str(self.settings.compiler.version), min_version): raise ConanInvalidConfiguration( - "{} requires C++{}, which your compiler does not support.".format(self.name, self._min_cppstd) + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) def source(self): - tools.get(**self.conan_data["sources"][self.version], - strip_root=True, destination=self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_TESTING"] = False - self._cmake.definitions["ENABLE_TEST_COVERAGE"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_TESTING"] = False + tc.variables["ENABLE_TESTING_COVERAGE"] = False + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.libs = ["unleash"] self.cpp_info.set_property("cmake_file_name", "unleash") self.cpp_info.set_property("cmake_target_name", "unleash::unleash") - self.cpp_info.libs = ["unleash"] - - self.cpp_info.names["cmake_find_package"] = "unleash" - self.cpp_info.names["cmake_find_package_multi"] = "unleash" - diff --git a/recipes/unleash-client-cpp/all/test_package/CMakeLists.txt b/recipes/unleash-client-cpp/all/test_package/CMakeLists.txt index 5dfa06d3b7057..bd4860f14d566 100644 --- a/recipes/unleash-client-cpp/all/test_package/CMakeLists.txt +++ b/recipes/unleash-client-cpp/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ cmake_minimum_required(VERSION 3.8) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(unleash CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} unleash::unleash) +target_link_libraries(${PROJECT_NAME} PRIVATE unleash::unleash) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/unleash-client-cpp/all/test_package/conanfile.py b/recipes/unleash-client-cpp/all/test_package/conanfile.py index 38f4483872d47..ef5d7042163ec 100644 --- a/recipes/unleash-client-cpp/all/test_package/conanfile.py +++ b/recipes/unleash-client-cpp/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +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 = "cmake", "cmake_find_package_multi" + 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) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/unleash-client-cpp/config.yml b/recipes/unleash-client-cpp/config.yml index 60d31991f5141..4d32e3eeef7e4 100644 --- a/recipes/unleash-client-cpp/config.yml +++ b/recipes/unleash-client-cpp/config.yml @@ -1,3 +1,5 @@ versions: + "1.3.0": + folder: all "1.1.1": folder: all From d363989455e1ac8d839bd4cad99f39f21622df36 Mon Sep 17 00:00:00 2001 From: toge Date: Mon, 26 Feb 2024 15:24:05 +0900 Subject: [PATCH 2/8] drop support clang with libc++ --- recipes/unleash-client-cpp/all/conanfile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes/unleash-client-cpp/all/conanfile.py b/recipes/unleash-client-cpp/all/conanfile.py index af5cabe1791ba..8d8876553d6f9 100644 --- a/recipes/unleash-client-cpp/all/conanfile.py +++ b/recipes/unleash-client-cpp/all/conanfile.py @@ -74,6 +74,11 @@ def loose_lt_semver(v1, v2): f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) + if self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libc++": + raise ConanInvalidConfiguration( + f"{self.ref} doesn't support clang with libc++. Use libstdc++ instead." + ) + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) From 6180b0327f517ed0a26b52f8f14ce0b243701686 Mon Sep 17 00:00:00 2001 From: toge Date: Mon, 26 Feb 2024 16:11:13 +0900 Subject: [PATCH 3/8] drop support apple-clang with libc++ --- recipes/unleash-client-cpp/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/unleash-client-cpp/all/conanfile.py b/recipes/unleash-client-cpp/all/conanfile.py index 8d8876553d6f9..3312d0126139b 100644 --- a/recipes/unleash-client-cpp/all/conanfile.py +++ b/recipes/unleash-client-cpp/all/conanfile.py @@ -74,7 +74,7 @@ def loose_lt_semver(v1, v2): f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) - if self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libc++": + if self.settings.compiler in ["clang", "apple-clang"] and self.settings.compiler.libcxx == "libc++": raise ConanInvalidConfiguration( f"{self.ref} doesn't support clang with libc++. Use libstdc++ instead." ) From 04995da2543ef8cb75c062757c95d12550ae448d Mon Sep 17 00:00:00 2001 From: toge Date: Mon, 26 Feb 2024 20:08:11 +0900 Subject: [PATCH 4/8] include sstream in 1.1.1 --- recipes/unleash-client-cpp/all/conandata.yml | 3 +++ .../all/patches/0002-include-sstream.patch | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 recipes/unleash-client-cpp/all/patches/0002-include-sstream.patch diff --git a/recipes/unleash-client-cpp/all/conandata.yml b/recipes/unleash-client-cpp/all/conandata.yml index 7683a40843926..a08e6eef651aa 100644 --- a/recipes/unleash-client-cpp/all/conandata.yml +++ b/recipes/unleash-client-cpp/all/conandata.yml @@ -10,3 +10,6 @@ patches: - patch_file: "patches/0001-no-conan-cmake.patch" patch_description: "remove conan cmake module" patch_type: "portability" + - patch_file: "patches/0002-include-sstream.patch" + patch_description: "include sstream" + patch_type: "portability" diff --git a/recipes/unleash-client-cpp/all/patches/0002-include-sstream.patch b/recipes/unleash-client-cpp/all/patches/0002-include-sstream.patch new file mode 100644 index 0000000000000..43049ac6a0863 --- /dev/null +++ b/recipes/unleash-client-cpp/all/patches/0002-include-sstream.patch @@ -0,0 +1,18 @@ +diff --git a/src/strategies/userwithid.cpp b/src/strategies/userwithid.cpp +index c2f3c7e..4dfbc28 100644 +--- a/src/strategies/userwithid.cpp ++++ b/src/strategies/userwithid.cpp +@@ -1,5 +1,6 @@ + #include "unleash/strategies/userwithid.h" + #include ++#include + #include + + namespace unleash { +@@ -19,4 +20,4 @@ bool UserWithId::isEnabled(const Context &context) { + return true; + return false; + } +-} // namespace unleash +\ No newline at end of file ++} // namespace unleash From 3c477bd03dcff40e12ae57023aa6d3358a3739d2 Mon Sep 17 00:00:00 2001 From: toge Date: Mon, 26 Feb 2024 22:51:12 +0900 Subject: [PATCH 5/8] fix msvc version Co-authored-by: Martin Valgur --- recipes/unleash-client-cpp/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/unleash-client-cpp/all/conanfile.py b/recipes/unleash-client-cpp/all/conanfile.py index 3312d0126139b..dfa5d4238742a 100644 --- a/recipes/unleash-client-cpp/all/conanfile.py +++ b/recipes/unleash-client-cpp/all/conanfile.py @@ -33,7 +33,7 @@ def _min_cppstd(self): def _compilers_min_version(self): return { "Visual Studio": "15", # Should we check toolset? - "msvc": "190", + "msvc": "191", "gcc": "7", "clang": "4.0", "apple-clang": "3.8", From 0d39aae6c6cc9f8bd0db219c0160726864b19eb5 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Thu, 30 May 2024 14:28:47 +0200 Subject: [PATCH 6/8] Removed support for v1.1.1 and cleaned old conan 1 cruft --- recipes/unleash-client-cpp/all/conandata.yml | 12 +--------- recipes/unleash-client-cpp/all/conanfile.py | 23 ++++--------------- .../all/patches/0001-no-conan-cmake.patch | 11 --------- .../all/patches/0002-include-sstream.patch | 18 --------------- .../all/test_package/test_package.cpp | 7 +++--- recipes/unleash-client-cpp/config.yml | 3 +-- 6 files changed, 11 insertions(+), 63 deletions(-) delete mode 100644 recipes/unleash-client-cpp/all/patches/0001-no-conan-cmake.patch delete mode 100644 recipes/unleash-client-cpp/all/patches/0002-include-sstream.patch diff --git a/recipes/unleash-client-cpp/all/conandata.yml b/recipes/unleash-client-cpp/all/conandata.yml index a08e6eef651aa..261e3afd1b159 100644 --- a/recipes/unleash-client-cpp/all/conandata.yml +++ b/recipes/unleash-client-cpp/all/conandata.yml @@ -2,14 +2,4 @@ sources: "1.3.0": url: "https://github.com/aruizs/unleash-client-cpp/archive/refs/tags/v1.3.0.tar.gz" sha256: "fa0b8d6101c6dbd08db23a3d353f386c17e9436a63d658f88c7d0b8619b8d501" - "1.1.1": - url: "https://github.com/aruizs/unleash-client-cpp/archive/refs/tags/v1.1.1.tar.gz" - sha256: "2750dc231bf608910d4270ac39d83d46d25b88cc547a9d4d31f7ce4950effa7c" -patches: - "1.1.1": - - patch_file: "patches/0001-no-conan-cmake.patch" - patch_description: "remove conan cmake module" - patch_type: "portability" - - patch_file: "patches/0002-include-sstream.patch" - patch_description: "include sstream" - patch_type: "portability" + diff --git a/recipes/unleash-client-cpp/all/conanfile.py b/recipes/unleash-client-cpp/all/conanfile.py index dfa5d4238742a..5c84a2f78a279 100644 --- a/recipes/unleash-client-cpp/all/conanfile.py +++ b/recipes/unleash-client-cpp/all/conanfile.py @@ -2,9 +2,11 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.files import copy, get, rmdir import os +from conan.tools.scm import Version + required_conan_version = ">=1.53.0" class UnleashConan(ConanFile): @@ -40,16 +42,13 @@ def _compilers_min_version(self): "intel": "17", } - 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: - del self.options.fPIC + self.options.rm_safe("fPIC") def layout(self): cmake_layout(self, src_folder="src") @@ -62,23 +61,12 @@ def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, self._min_cppstd) - def loose_lt_semver(v1, v2): - lv1 = [int(v) for v in v1.split(".")] - lv2 = [int(v) for v in v2.split(".")] - min_length = min(len(lv1), len(lv2)) - return lv1[:min_length] < lv2[:min_length] - min_version = self._compilers_min_version.get(str(self.settings.compiler), False) - if min_version and loose_lt_semver(str(self.settings.compiler.version), min_version): + if min_version and Version(self.settings.compiler.version) < min_version: raise ConanInvalidConfiguration( f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) - if self.settings.compiler in ["clang", "apple-clang"] and self.settings.compiler.libcxx == "libc++": - raise ConanInvalidConfiguration( - f"{self.ref} doesn't support clang with libc++. Use libstdc++ instead." - ) - def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -91,7 +79,6 @@ def generate(self): deps.generate() def build(self): - apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() diff --git a/recipes/unleash-client-cpp/all/patches/0001-no-conan-cmake.patch b/recipes/unleash-client-cpp/all/patches/0001-no-conan-cmake.patch deleted file mode 100644 index f88f88c81dde7..0000000000000 --- a/recipes/unleash-client-cpp/all/patches/0001-no-conan-cmake.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -25,8 +25,6 @@ if(DEFINED unleash_SHARED_LIBS) - endif() - - # External dependencies using Conan.io --include(cmake/Conan.cmake) --run_conan() - - # Create the main unleash library target - add_subdirectory(src) diff --git a/recipes/unleash-client-cpp/all/patches/0002-include-sstream.patch b/recipes/unleash-client-cpp/all/patches/0002-include-sstream.patch deleted file mode 100644 index 43049ac6a0863..0000000000000 --- a/recipes/unleash-client-cpp/all/patches/0002-include-sstream.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/src/strategies/userwithid.cpp b/src/strategies/userwithid.cpp -index c2f3c7e..4dfbc28 100644 ---- a/src/strategies/userwithid.cpp -+++ b/src/strategies/userwithid.cpp -@@ -1,5 +1,6 @@ - #include "unleash/strategies/userwithid.h" - #include -+#include - #include - - namespace unleash { -@@ -19,4 +20,4 @@ bool UserWithId::isEnabled(const Context &context) { - return true; - return false; - } --} // namespace unleash -\ No newline at end of file -+} // namespace unleash diff --git a/recipes/unleash-client-cpp/all/test_package/test_package.cpp b/recipes/unleash-client-cpp/all/test_package/test_package.cpp index 9af855c3e03d7..1eaf68256bc88 100644 --- a/recipes/unleash-client-cpp/all/test_package/test_package.cpp +++ b/recipes/unleash-client-cpp/all/test_package/test_package.cpp @@ -1,10 +1,11 @@ #include +#include +#include #include int main() { unleash::UnleashClient unleashClient = unleash::UnleashClient::create("production", "https://www.apple.com/%"); - unleashClient.initializeClient(); - return unleashClient.isEnabled("feature.toogle"); - + std::cout << "feature.toggle - is enabled: " << std::boolalpha << unleashClient.isEnabled("feature.toogle") << '\n'; + return 0; } diff --git a/recipes/unleash-client-cpp/config.yml b/recipes/unleash-client-cpp/config.yml index 4d32e3eeef7e4..055a8238dd014 100644 --- a/recipes/unleash-client-cpp/config.yml +++ b/recipes/unleash-client-cpp/config.yml @@ -1,5 +1,4 @@ versions: "1.3.0": folder: all - "1.1.1": - folder: all + From 58a3a62e2b86ec37e351b99eaf01e43da74ab86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Thu, 30 May 2024 14:33:26 +0200 Subject: [PATCH 7/8] Update recipes/unleash-client-cpp/all/conandata.yml --- recipes/unleash-client-cpp/all/conandata.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/unleash-client-cpp/all/conandata.yml b/recipes/unleash-client-cpp/all/conandata.yml index 261e3afd1b159..69cfd9795a61f 100644 --- a/recipes/unleash-client-cpp/all/conandata.yml +++ b/recipes/unleash-client-cpp/all/conandata.yml @@ -2,4 +2,3 @@ sources: "1.3.0": url: "https://github.com/aruizs/unleash-client-cpp/archive/refs/tags/v1.3.0.tar.gz" sha256: "fa0b8d6101c6dbd08db23a3d353f386c17e9436a63d658f88c7d0b8619b8d501" - From 06a381bcb61019e3ea298c8aacf85daa61f104de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Thu, 30 May 2024 14:36:10 +0200 Subject: [PATCH 8/8] Update recipes/unleash-client-cpp/config.yml --- recipes/unleash-client-cpp/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/unleash-client-cpp/config.yml b/recipes/unleash-client-cpp/config.yml index 055a8238dd014..426a0e4c79e9b 100644 --- a/recipes/unleash-client-cpp/config.yml +++ b/recipes/unleash-client-cpp/config.yml @@ -1,4 +1,3 @@ versions: "1.3.0": folder: all -