Skip to content

Commit

Permalink
(#13302) aws-c-sdkutils: update dependencies and support conan v2
Browse files Browse the repository at this point in the history
  • Loading branch information
toge authored Oct 5, 2022
1 parent c21d14b commit bdde7ec
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 47 deletions.
7 changes: 0 additions & 7 deletions recipes/aws-c-sdkutils/all/CMakeLists.txt

This file was deleted.

67 changes: 36 additions & 31 deletions recipes/aws-c-sdkutils/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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],
Expand All @@ -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")
Expand All @@ -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"]

3 changes: 0 additions & 3 deletions recipes/aws-c-sdkutils/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
21 changes: 15 additions & 6 deletions recipes/aws-c-sdkutils/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
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)
cmake.configure()
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")
11 changes: 11 additions & 0 deletions recipes/aws-c-sdkutils/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
18 changes: 18 additions & 0 deletions recipes/aws-c-sdkutils/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit bdde7ec

Please sign in to comment.