Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aws-sdk-cpp/1.7.299 recipe #1146

Closed
wants to merge 10 commits into from
7 changes: 7 additions & 0 deletions recipes/aws-sdk-cpp/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/aws-sdk-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.8.34":
url: "https://github.com/aws/aws-sdk-cpp/archive/1.8.34.tar.gz"
sha256: "d036f51b61e86473af289ff18f758a02bc04aede5296d9aac8b81a501d71a87d"
133 changes: 133 additions & 0 deletions recipes/aws-sdk-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
from conans import CMake, ConanFile, tools
import os
import string


class AwsSdkCppConan(ConanFile):
name = "aws-sdk-cpp"
description = "The AWS SDK for C++ provides a modern C++ (version C++ 11 or later) interface for Amazon Web Services (AWS)."
topics = ("conan", "aws", "amazon", "cloud", )
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/aws/aws-sdk-cpp"
license = "Apache-2.0",
exports_sources = "CMakeLists.txt",
generators = "cmake", "cmake_find_package"
settings = "os", "arch", "compiler", "build_type"
short_paths = True
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_rtti": [True, False],
"use_virtual_operations": [True, False],
"with_curl": [True, False],
"enable_curl_logging": [True, False],
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
"build_only": "ANY",
}

default_options = {
"shared": False,
"fPIC": True,
"with_rtti": True,
"use_virtual_operations": True,
"with_curl": True,
"enable_curl_logging": False,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
"build_only": None,
}


_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
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, 2003)
Comment on lines +47 to +48
Copy link
Contributor

@SpaceIm SpaceIm Nov 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2003? Don't you mean 11 (looking at build())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep 11. 2003 it's not listed as default cppstd in setting.yml.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make the change to 11.
But 2003 is a fine value too.
Last time I checked, tools.check_min_cppstd converts self.settings.compiler.cppstd and 11 to a 4-digit year,
That way comparing 98 and 11 uses the same code path.

Copy link
Contributor Author

@madebr madebr Nov 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, using 98,11,14,17 and 20 will cause a new y2k-kind problem in less then 80 years. 🤣

if not self.options.with_curl:
del self.options.enable_curl_logging

def requirements(self):
self.requires("aws-c-common/0.4.25")
self.requires("aws-c-event-stream/0.1.5")
self.requires("openssl/1.1.1g")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.requires("openssl/1.1.1g")
self.requires("openssl/1.1.1h")

self.requires("zlib/1.2.11")
if self.options.with_curl:
self.requires("libcurl/7.71.1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.requires("libcurl/7.71.1")
self.requires("libcurl/7.73.0")


@property
def _cmake_cpp_standard(self):
return ''.join(c for c in str(self.settings.compiler.cppstd) if c in string.digits)

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_folder = "aws-sdk-cpp-{}".format(self.version)
os.rename(extracted_folder, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)

if not self.settings.compiler.cppstd:
self._cmake.definitions["CMAKE_CXX_STANDARD"] = 11
self._cmake.definitions["BUILD_DEPS"] = False
self._cmake.definitions["ENABLE_UNITY_BUILD"] = True
self._cmake.definitions["ENABLE_RTTI"] = self.options.with_rtti
self._cmake.definitions["FORCE_CURL"] = self.options.with_curl
self._cmake.definitions["ENABLE_CURL_LOGGING"] = self.options.get_safe("enable_curl_logging")
if self.settings.compiler.cppstd:
self._cmake.definitions["CPP_STANDARD"] = self._cmake_cpp_standard

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.options.build_only:
self._cmake.definitions["BUILD_ONLY"] = self.options.build_only

self._cmake.definitions["ENABLE_TESTING"] = False
self._cmake.definitions["SIMPLE_INSTALL"] = True
if self.settings.compiler == "Visual Studio":
self._cmake.definitions["FORCE_SHARED_CRT"] = "MD" in str(self.settings.compiler.runtime)

self._cmake.definitions["AUTORUN_UNIT_TESTS"] = False

self._cmake.definitions["ANDROID_BUILD_CURL"] = False
self._cmake.definitions["ANDROID_BUILD_OPENSSL"] = False
self._cmake.definitions["ANDROID_BUILD_ZLIB"] = False

self._cmake.configure()
return self._cmake

def _patch_sources(self):
tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "sdks.cmake"),
"sort_links(EXPORTS)", "# sort_links(EXPORTS)")
for root, _, _ in os.walk(self._source_subfolder):
cmakelists = os.path.join(root, "CMakeLists.txt")
repl = "AWS::aws-c-event-stream"
if os.path.isfile(cmakelists) and repl in tools.load(cmakelists):
tools.replace_in_file(cmakelists, repl, "CONAN_PKG::aws-c-event-stream", strict=False)
Comment on lines +101 to +105
Copy link
Contributor

@SpaceIm SpaceIm Nov 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be required anymore, imported target in aws-c-event-stream recipe was fixed in #2584


@property
def _cpu_count(self):
try:
cpus = int(tools.cpu_count())
return min((cpus, 2))
except ValueError:
return 2

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
# Reduce parallelism to avoid out-of-memory on limited memory build systems
with tools.environment_append({"CONAN_CPU_COUNT": str(self._cpu_count)}):
cmake.build()

def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why delete this? I, as a consumer, prefer the library's cmake config script, if available, rather than conan's generated one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's cci policy to remove these.
But I agree to your sentiment.
Most cmake config scripts now are relocatable, whereas in the past they had absolute paths to the build systems embedded into them.

@danimtb @uilianries @SpaceIm @jgsogo
aws-sdk-cpp provides a lot of libraries (and config cmake scripts). By a lot, I mean 30+.
conan does currently not provide a way to generate multiple config scripts.
And even then, the generated conan cmake scripts will be generic and never the same as those provided by the aws-sdk-cpp cmake build script.

I feel cci should allow those cmake scripts that play by the book and are fully relocatable.
This would also save a lot of maintenance and acceptance of conan/cci.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the other AWS packages don't delete this folder, e.g.

self.cpp_info.components["aws-c-common-lib"].builddirs = [os.path.join("lib", "cmake")]

tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as there are inter-dependencies between components (e.g. many depend on aws-sdk-core) it's not good to use collect_libs (see https://docs.conan.io/en/latest/reference/tools.html?highlight=inter%20dependent#tools-collect-libs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it needs a similar approach as my boost components pr (#2097)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, you have a lot going on

self.cpp_info.names["cmake_find_package"] = "AWSSDK"
self.cpp_info.names["cmake_find_package_multi"] = "AWSSDK"
8 changes: 8 additions & 0 deletions recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/aws-sdk-cpp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
10 changes: 10 additions & 0 deletions recipes/aws-sdk-cpp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <aws/core/Aws.h>


int main(void)
{
Aws::SDKOptions options;
Aws::InitAPI(options);
Aws::ShutdownAPI(options);
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/aws-sdk-cpp/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.8.34":
folder: all