From f9a40f964530ab98dc2d04a2440e61da285484ea Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 6 Feb 2024 12:27:23 +0100 Subject: [PATCH 1/2] prepare to CCI Signed-off-by: Uilian Ries --- recipes/etcd-cpp-apiv3/all/conanfile.py | 31 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/recipes/etcd-cpp-apiv3/all/conanfile.py b/recipes/etcd-cpp-apiv3/all/conanfile.py index 28a5f3b079e0e..a95deda207020 100644 --- a/recipes/etcd-cpp-apiv3/all/conanfile.py +++ b/recipes/etcd-cpp-apiv3/all/conanfile.py @@ -1,7 +1,8 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout -from conan.tools.files import export_conandata_patches, get, load, copy, collect_libs, rmdir +from conan.tools.files import export_conandata_patches, get, copy, rmdir +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv import os required_conan_version = ">=1.53.0" @@ -11,9 +12,9 @@ class EtcdCppApiv3Conan(ConanFile): package_type = "library" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3" - license = "etcd-cpp-apiv3" + license = "BSD-3-Clause" description = ("C++ library for etcd's v3 client APIs, i.e., ETCDCTL_API=3.") - topics = ("etcd-cpp-apiv3", "api") + topics = ("etcd", "api", ) settings = "os", "arch", "compiler", "build_type" options = { @@ -25,6 +26,10 @@ class EtcdCppApiv3Conan(ConanFile): "fPIC": True, } + @property + def _is_legacy_one_profile(self): + return not hasattr(self, "settings_build") + def export_sources(self): export_conandata_patches(self) @@ -39,25 +44,32 @@ def configure(self): def layout(self): cmake_layout(self, src_folder="src") + def build_requirements(self): + if not self._is_legacy_one_profile: + self.tool_requires("protobuf/") + self.tool_requires("grpc/") + def requirements(self): self.requires("protobuf/3.21.12") self.requires("openssl/[>=1.1 <4]") self.requires("grpc/1.54.3") self.requires("cpprestsdk/2.10.19", transitive_headers=True, transitive_libs=True) - def validate(self): - if self.dependencies["grpc"].options.shared: - raise ConanInvalidConfiguration("grpc must be built as a static library") - if self.settings.os == "Macos": - raise ConanInvalidConfiguration("Recipe is not MasOs ready yet") - def source(self): get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) def generate(self): + env = VirtualBuildEnv(self) + env.generate() + if self._is_legacy_one_profile: + env = VirtualRunEnv(self) + env.generate(scope="build") + tc = CMakeToolchain(self) tc.variables["gRPC_VERSION"] = self.dependencies["grpc"].ref.version + tc.variables["ETCD_CMAKE_CXX_STANDARD"] = self.settings.compiler.get_safe("cppstd", "11") + tc.variables["OpenSSL_DIR"] = self.dependencies["openssl"].package_folder tc.generate() cmake_deps = CMakeDeps(self) @@ -76,4 +88,3 @@ def package(self): def package_info(self): self.cpp_info.libs = ["etcd-cpp-api"] - From eb0e4da37d06b8da94f1c8fae1999ecaf63a5c87 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 6 Feb 2024 12:31:50 +0100 Subject: [PATCH 2/2] remove not used import Signed-off-by: Uilian Ries --- recipes/etcd-cpp-apiv3/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/etcd-cpp-apiv3/all/conanfile.py b/recipes/etcd-cpp-apiv3/all/conanfile.py index a95deda207020..15fd45080b1f3 100644 --- a/recipes/etcd-cpp-apiv3/all/conanfile.py +++ b/recipes/etcd-cpp-apiv3/all/conanfile.py @@ -1,5 +1,4 @@ from conan import ConanFile -from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout from conan.tools.files import export_conandata_patches, get, copy, rmdir from conan.tools.env import VirtualBuildEnv, VirtualRunEnv