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

[aws-sdk-cpp] package files for building SDK plugins #7830

Merged
merged 5 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/aws-sdk-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ patches:
"1.9.100":
- base_path: source_subfolder
patch_file: patches/1.9.100-0001-disable-sort-links.patch
- base_path: source_subfolder
patch_file: patches/1.9.100-0002-aws-plugin-conf.patch
"1.8.130":
- base_path: source_subfolder
patch_file: patches/1.8.130-0001-disable-sort-links.patch
Expand All @@ -18,3 +20,5 @@ patches:
patch_file: patches/1.8.130-0003-disable-cmake-install-rpath-use-link-path.patch
- base_path: source_subfolder
patch_file: patches/1.8.130-0004-improve-pulseaudio-detection.patch
- base_path: source_subfolder
patch_file: patches/1.8.130-0005-aws-plugin-conf.patch
37 changes: 35 additions & 2 deletions recipes/aws-sdk-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

from conan.tools.files import rename
from conan.tools.microsoft import msvc_runtime_flag
from conans import ConanFile, CMake, tools
from conans import CMake, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.43.0"

Expand Down Expand Up @@ -421,6 +423,29 @@ def build(self):
cmake = self._configure_cmake()
cmake.build()

@property
def _res_folder(self):
return "res"

def _create_project_cmake_module(self):
# package files needed to build other components (e.g. aws-cdi-sdk) with this SDK
for file in [
"cmake/compiler_settings.cmake",
"cmake/initialize_project_version.cmake",
"cmake/utilities.cmake",
"cmake/sdk_plugin_conf.cmake",
"toolchains/cmakeProjectConfig.cmake",
"toolchains/pkg-config.pc.in",
"aws-cpp-sdk-core/include/aws/core/VersionConfig.h"
]:
self.copy(file, src=self._source_subfolder, dst=self._res_folder)
tools.replace_in_file(os.path.join(self.package_folder, self._res_folder, file), "CMAKE_CURRENT_SOURCE_DIR", "AWS_NATIVE_SDK_ROOT", strict=False)

# avoid getting error from hook
with tools.chdir(os.path.join(self.package_folder, self._res_folder)):
rename(self, os.path.join("toolchains", "cmakeProjectConfig.cmake"), os.path.join("toolchains", "cmakeProjectConf.cmake"))
tools.replace_in_file(os.path.join("cmake", "utilities.cmake"), "cmakeProjectConfig.cmake", "cmakeProjectConf.cmake")

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
Expand All @@ -432,6 +457,8 @@ def package(self):
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

self._create_project_cmake_module()

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "AWSSDK")

Expand Down Expand Up @@ -507,3 +534,9 @@ def package_info(self):
self.cpp_info.names["cmake_find_package_multi"] = "AWS"
self.cpp_info.components["core"].names["cmake_find_package"] = "aws-sdk-cpp-core"
self.cpp_info.components["core"].names["cmake_find_package_multi"] = "aws-sdk-cpp-core"

self.cpp_info.components["plugin_scripts"].requires = ["core"]
self.cpp_info.components["plugin_scripts"].builddirs.extend([
os.path.join(self._res_folder, "cmake"),
os.path.join(self._res_folder, "toolchains")])
self.cpp_info.components["plugin_scripts"].build_modules.append(os.path.join(self._res_folder, "cmake", "sdk_plugin_conf.cmake"))
44 changes: 44 additions & 0 deletions recipes/aws-sdk-cpp/all/patches/1.8.130-0005-aws-plugin-conf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
commit 1179cb040d6b9292d30eb7d444298cd286f9f574
Author: dvirtz <dvirtz@gmail.com>
Date: Tue Nov 16 21:38:45 2021 +0200

add a file to configure SDK plugins

diff --git a/cmake/sdk_plugin_conf.cmake b/cmake/sdk_plugin_conf.cmake
new file mode 100644
index 0000000000..474ead75bd
--- /dev/null
+++ b/cmake/sdk_plugin_conf.cmake
@@ -0,0 +1,32 @@
+get_filename_component(AWS_NATIVE_SDK_ROOT ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
+set(SIMPLE_INSTALL TRUE)
+
+if (CMAKE_INSTALL_BINDIR)
+ set(BINARY_DIRECTORY "${CMAKE_INSTALL_BINDIR}")
+endif()
+
+if (CMAKE_INSTALL_LIBDIR)
+ set(LIBRARY_DIRECTORY "${CMAKE_INSTALL_LIBDIR}")
+endif()
+
+if (CMAKE_INSTALL_INCLUDEDIR)
+ set(INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}")
+endif()
+
+if(BUILD_SHARED_LIBS)
+ set(ARCHIVE_DIRECTORY "${BINARY_DIRECTORY}")
+else()
+ set(ARCHIVE_DIRECTORY "${LIBRARY_DIRECTORY}")
+endif()
+
+if(DEFINED CMAKE_CXX_STANDARD)
+ set(STANDARD_DEFAULT ${CMAKE_CXX_STANDARD})
+else()
+ set(STANDARD_DEFAULT "11")
+endif()
+set(CPP_STANDARD ${STANDARD_DEFAULT} CACHE STRING "Flag to upgrade the C++ standard used. The default is 11. The minimum is 11.")
+
+include(CMakePackageConfigHelpers)
+include(initialize_project_version)
+include(utilities)
+include(compiler_settings)
44 changes: 44 additions & 0 deletions recipes/aws-sdk-cpp/all/patches/1.9.100-0002-aws-plugin-conf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
commit 1179cb040d6b9292d30eb7d444298cd286f9f574
Author: dvirtz <dvirtz@gmail.com>
Date: Tue Nov 16 21:38:45 2021 +0200

add a file to configure SDK plugins

diff --git a/cmake/sdk_plugin_conf.cmake b/cmake/sdk_plugin_conf.cmake
new file mode 100644
index 0000000000..474ead75bd
--- /dev/null
+++ b/cmake/sdk_plugin_conf.cmake
@@ -0,0 +1,32 @@
+get_filename_component(AWS_NATIVE_SDK_ROOT ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
+set(SIMPLE_INSTALL TRUE)
+
+if (CMAKE_INSTALL_BINDIR)
+ set(BINARY_DIRECTORY "${CMAKE_INSTALL_BINDIR}")
+endif()
+
+if (CMAKE_INSTALL_LIBDIR)
+ set(LIBRARY_DIRECTORY "${CMAKE_INSTALL_LIBDIR}")
+endif()
+
+if (CMAKE_INSTALL_INCLUDEDIR)
+ set(INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}")
+endif()
+
+if(BUILD_SHARED_LIBS)
+ set(ARCHIVE_DIRECTORY "${BINARY_DIRECTORY}")
+else()
+ set(ARCHIVE_DIRECTORY "${LIBRARY_DIRECTORY}")
+endif()
+
+if(DEFINED CMAKE_CXX_STANDARD)
+ set(STANDARD_DEFAULT ${CMAKE_CXX_STANDARD})
+else()
+ set(STANDARD_DEFAULT "11")
+endif()
+set(CPP_STANDARD ${STANDARD_DEFAULT} CACHE STRING "Flag to upgrade the C++ standard used. The default is 11. The minimum is 11.")
+
+include(CMakePackageConfigHelpers)
+include(initialize_project_version)
+include(utilities)
+include(compiler_settings)
4 changes: 3 additions & 1 deletion recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ conan_basic_setup(TARGETS)

find_package(AWSSDK REQUIRED CONFIG)

add_subdirectory(aws-sdk-cpp-plugin)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} AWS::aws-sdk-cpp-s3)
target_link_libraries(${PROJECT_NAME} aws-sdk-cpp-plugin)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "AwsSdkCppPlugin.h"
#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/client/ClientConfiguration.h>
#include <aws/s3/S3Client.h>

AwsSdkCppPlugin::AwsSdkCppPlugin() {
using namespace Aws;
using namespace Auth;
using namespace Client;
using namespace S3;
ClientConfiguration config;
auto client = MakeShared<S3Client>("S3Client",
MakeShared<DefaultAWSCredentialsProviderChain>("S3Client"), config,
AWSAuthV4Signer::PayloadSigningPolicy::Never /*signPayloads*/, true /*useVirtualAddressing*/, US_EAST_1_REGIONAL_ENDPOINT_OPTION::LEGACY);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <aws_sdk_cpp_plugin_export.h>

class AWS_SDK_CPP_PLUGIN_EXPORT AwsSdkCppPlugin
{
public:
AwsSdkCppPlugin();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.1)

add_project(aws-sdk-cpp-plugin "C++ AWS SDK plugin" AWS::aws-sdk-cpp-s3)

add_library(${PROJECT_NAME} AwsSdkCppPlugin.cpp)

include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME} BASE_NAME aws_sdk_cpp_plugin)
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_LIBS})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)

setup_install()

do_packaging()
14 changes: 2 additions & 12 deletions recipes/aws-sdk-cpp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
#include <iostream>
#include <memory>
#include <aws/core/Aws.h>
#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/client/ClientConfiguration.h>
#include <aws/s3/S3Client.h>
#include <AwsSdkCppPlugin.h>


int main() {
using namespace Aws;
using namespace Auth;
using namespace Client;
using namespace S3;
SDKOptions options;
InitAPI(options);
ClientConfiguration config;
auto client = MakeShared<S3Client>("S3Client",
MakeShared<DefaultAWSCredentialsProviderChain>("S3Client"), config,
AWSAuthV4Signer::PayloadSigningPolicy::Never /*signPayloads*/, true /*useVirtualAddressing*/, US_EAST_1_REGIONAL_ENDPOINT_OPTION::LEGACY);
AwsSdkCppPlugin Plugin;
ShutdownAPI(options);
return 0;
}
Expand Down