From bdde7ec2505b3f5f794b8e354ea58ad412d8fbba Mon Sep 17 00:00:00 2001 From: toge Date: Thu, 6 Oct 2022 00:44:19 +0900 Subject: [PATCH] (#13302) aws-c-sdkutils: update dependencies and support conan v2 --- recipes/aws-c-sdkutils/all/CMakeLists.txt | 7 -- recipes/aws-c-sdkutils/all/conanfile.py | 67 ++++++++++--------- .../all/test_package/CMakeLists.txt | 3 - .../all/test_package/conanfile.py | 21 ++++-- .../all/test_v1_package/CMakeLists.txt | 11 +++ .../all/test_v1_package/conanfile.py | 18 +++++ 6 files changed, 80 insertions(+), 47 deletions(-) delete mode 100644 recipes/aws-c-sdkutils/all/CMakeLists.txt create mode 100644 recipes/aws-c-sdkutils/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/aws-c-sdkutils/all/test_v1_package/conanfile.py diff --git a/recipes/aws-c-sdkutils/all/CMakeLists.txt b/recipes/aws-c-sdkutils/all/CMakeLists.txt deleted file mode 100644 index fe3c5e109c923..0000000000000 --- a/recipes/aws-c-sdkutils/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper LANGUAGES C) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/aws-c-sdkutils/all/conanfile.py b/recipes/aws-c-sdkutils/all/conanfile.py index 37509472eb1f5..43b3b4f755411 100644 --- a/recipes/aws-c-sdkutils/all/conanfile.py +++ b/recipes/aws-c-sdkutils/all/conanfile.py @@ -1,18 +1,17 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.files import get, copy, rmdir +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout import os -required_conan_version = ">=1.43.0" - +required_conan_version = ">=1.52.0" class AwsCSDKUtils(ConanFile): name = "aws-c-sdkutils" - description = "aws c language sdk utility library." - topics = ("aws", "amazon", "cloud", "utility") + description = "C99 library implementing AWS SDK specific utilities. Includes utilities for ARN parsing, reading AWS profiles, etc..." + license = "Apache-2.0", url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/awslabs/aws-c-sdkutils" - license = "Apache-2.0", - exports_sources = "CMakeLists.txt", - generators = "cmake", "cmake_find_package_multi" + topics = ("aws", "amazon", "cloud", "utility", "ARN") settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -23,45 +22,52 @@ class AwsCSDKUtils(ConanFile): "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("aws-c-common/0.6.19") + self.requires("aws-c-common/0.8.2") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "aws-c-sdkutils")) + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-sdkutils")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "aws-c-sdkutils") @@ -77,4 +83,3 @@ def package_info(self): self.cpp_info.components["aws-c-sdkutils-lib"].libs = ["aws-c-sdkutils"] self.cpp_info.components["aws-c-sdkutils-lib"].requires = ["aws-c-common::aws-c-common-lib"] - diff --git a/recipes/aws-c-sdkutils/all/test_package/CMakeLists.txt b/recipes/aws-c-sdkutils/all/test_package/CMakeLists.txt index 61121c6334930..4b5efc665c153 100644 --- a/recipes/aws-c-sdkutils/all/test_package/CMakeLists.txt +++ b/recipes/aws-c-sdkutils/all/test_package/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.1) project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - find_package(aws-c-sdkutils REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) diff --git a/recipes/aws-c-sdkutils/all/test_package/conanfile.py b/recipes/aws-c-sdkutils/all/test_package/conanfile.py index 49a3a66ea5bad..a9fb96656f203 100644 --- a/recipes/aws-c-sdkutils/all/test_package/conanfile.py +++ b/recipes/aws-c-sdkutils/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", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + 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) @@ -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.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-sdkutils/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-sdkutils/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6e620de3b4bc3 --- /dev/null +++ b/recipes/aws-c-sdkutils/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) + +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-sdkutils REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} AWS::aws-c-sdkutils) diff --git a/recipes/aws-c-sdkutils/all/test_v1_package/conanfile.py b/recipes/aws-c-sdkutils/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/aws-c-sdkutils/all/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)