Skip to content

Commit

Permalink
Copy upstream aws-sdk-cpp port.
Browse files Browse the repository at this point in the history
  • Loading branch information
teo-tsirpanis committed May 28, 2024
1 parent 624c19e commit daf9c82
Show file tree
Hide file tree
Showing 9 changed files with 1,554 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ports/aws-sdk-cpp/fix-aws-root.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/cmake/AWSSDKConfig.cmake b/cmake/AWSSDKConfig.cmake
--- a/cmake/AWSSDKConfig.cmake (revision 2f90f9fd6c56460bd382243aa215fcddcb5883c8)
+++ b/cmake/AWSSDKConfig.cmake (date 1636913220527)
@@ -54,18 +54,14 @@
string(REPLACE ";" "${AWS_MODULE_DIR};" SYSTEM_MODULE_PATH "${CMAKE_SYSTEM_PREFIX_PATH}${AWS_MODULE_DIR}")
list(APPEND CMAKE_MODULE_PATH ${AWS_MODULE_PATH} ${SYSTEM_MODULE_PATH})

-# On Windows, dlls are treated as runtime target and installed in bindir
if (WIN32 AND AWSSDK_INSTALL_AS_SHARED_LIBS)
- set(AWSSDK_INSTALL_LIBDIR "${AWSSDK_INSTALL_BINDIR}")
# If installed CMake scripts are associated with dll library, define USE_IMPORT_EXPORT for customers
add_definitions(-DUSE_IMPORT_EXPORT)
endif()


# Compute the default installation root relative to this file.
-# from prefix/lib/cmake/AWSSDK/xx.cmake to prefix
get_filename_component(AWSSDK_DEFAULT_ROOT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
-get_filename_component(AWSSDK_DEFAULT_ROOT_DIR "${AWSSDK_DEFAULT_ROOT_DIR}" PATH)
get_filename_component(AWSSDK_DEFAULT_ROOT_DIR "${AWSSDK_DEFAULT_ROOT_DIR}" PATH)
get_filename_component(AWSSDK_DEFAULT_ROOT_DIR "${AWSSDK_DEFAULT_ROOT_DIR}" PATH)
get_filename_component(AWS_NATIVE_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
31 changes: 31 additions & 0 deletions ports/aws-sdk-cpp/fix_find_curl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/cmake/external_dependencies.cmake b/cmake/external_dependencies.cmake
index acf16c0..3a49fb4 100644
--- a/cmake/external_dependencies.cmake
+++ b/cmake/external_dependencies.cmake
@@ -80,23 +80,12 @@ if(NOT NO_HTTP_CLIENT AND NOT USE_CRT_HTTP_CLIENT)
set(BUILD_CURL 1)
message(STATUS " Building Curl as part of AWS SDK")
else()
- include(FindCURL)
+ find_package(CURL REQUIRED)
if(NOT CURL_FOUND)
message(FATAL_ERROR "Could not find curl")
+ else()
+ set(CURL_LIBRARIES CURL::libcurl)
endif()
-
- # When built from source using cmake, curl does not include
- # CURL_INCLUDE_DIRS or CURL_INCLUDE_DIRS so we need to use
- # find_package to fix it
- if ("${CURL_INCLUDE_DIRS}" STREQUAL "" AND "${CURL_LIBRARIES}" STREQUAL "")
- message(STATUS "Could not find curl include or library path, falling back to find with config.")
- find_package(CURL)
- set(CURL_LIBRARIES CURL::libcurl)
- else ()
- message(STATUS " Curl include directory: ${CURL_INCLUDE_DIRS}")
- List(APPEND EXTERNAL_DEPS_INCLUDE_DIRS ${CURL_INCLUDE_DIRS})
- set(CLIENT_LIBS ${CURL_LIBRARIES})
- endif ()
set(CLIENT_LIBS_ABSTRACT_NAME curl)
message(STATUS " Curl target link: ${CURL_LIBRARIES}")
endif()
73 changes: 73 additions & 0 deletions ports/aws-sdk-cpp/generateFeatures.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)][string]$SourcesRef,
[Parameter(Mandatory=$false)][string]$PortDirectory = $PSScriptRoot,
[Parameter(Mandatory=$false)][string]$vcpkg = "$PSScriptRoot/../../vcpkg"
)

$ErrorActionPreference = "Stop"

$ManifestIn = "$PortDirectory/vcpkg.in.json"
$ManifestOut = "$PortDirectory/vcpkg.json"

$ExtractedSources = "${env:TEMP}/aws-sdk-cpp-generateFeatures-$SourcesRef"
if (-not (Test-Path $ExtractedSources)) {
if (Test-Path "$ExtractedSources.tmp") {
Remove-Item -Force "$ExtractedSources.tmp"
}
git clone "https://github.com/aws/aws-sdk-cpp" "$ExtractedSources.tmp" | Out-Host
git -c "$ExtractedSources.tmp" checkout $SourcesRef
Move-Item "$ExtractedSources.tmp" "$ExtractedSources"
}
Write-Host "Using sources directory: $ExtractedSources"


$subfolders = Get-ChildItem -Path "$ExtractedSources\generated\src\aws-cpp-sdk-*", "$ExtractedSources\src\aws-cpp-sdk*" | Sort-Object -Property Name

$manifest = Get-Content $ManifestIn | ConvertFrom-Json
$manifest | Add-Member `
-NotePropertyName '$note' `
-NotePropertyValue 'Automatically generated by generateFeatures.ps1'
$manifest | Add-Member -NotePropertyName 'features' -NotePropertyValue @{}

function GetDescription($dir, $modulename)
{
if (Test-Path "$dir\CMakeLists.txt")
{
$descs = @(Select-String -Path "$dir\CMakeLists.txt" -Pattern "`"C\+\+ SDK for the AWS [^`"]*`"")
if ($descs.count -eq 1) {
$desc = $descs[0].Matches.Value -replace "`"",""
"$desc"
}
else { "C++ SDK for the AWS $modulename service" }
}
else { "C++ SDK for the AWS $modulename service" }
}

$featureDependencies = @{}
Select-String -Path "$ExtractedSources\cmake\sdksCommon.cmake" -Pattern "list\(APPEND SDK_DEPENDENCY_LIST `"([\w-]+):([\w-,]+)`"\)" -AllMatches `
| ForEach-Object { $_.Matches } `
| ForEach-Object { $featureDependencies[$_.Groups[1].Value] = @($_.Groups[2].Value -split "," `
| Where-Object { $_ -ne "core" }) }

foreach ($subfolder in $subfolders)
{
$modulename = $subfolder.name -replace "^aws-cpp-sdk-",""
if ($modulename -match "-tests`$") { continue }
if ($modulename -match "-sample`$") { continue }
if ($modulename -eq "core") { continue }

$lowermodulename = $modulename.ToLower()

$featureObj = @{ description = (GetDescription $subfolder $modulename) }

if ($featureDependencies.ContainsKey($lowermodulename)) {
$featureObj.dependencies = ,@{ name = "aws-sdk-cpp"; "default-features" = $false; "features" = $featureDependencies[$lowermodulename] }
}

$manifest.features.Add("$lowermodulename", $featureObj)
}

[IO.File]::WriteAllText($ManifestOut, (ConvertTo-Json -Depth 10 -InputObject $manifest))

& $vcpkg format-manifest --feature-flags=-manifests $ManifestOut
20 changes: 20 additions & 0 deletions ports/aws-sdk-cpp/lock-curl-http-and-tls-settings.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/aws-cpp-sdk-core/CMakeLists.txt b/src/aws-cpp-sdk-core/CMakeLists.txt
index c44546b0e..b66888362 100644
--- a/src/aws-cpp-sdk-core/CMakeLists.txt
+++ b/src/aws-cpp-sdk-core/CMakeLists.txt
@@ -113,13 +113,8 @@ if(ENABLE_CURL_CLIENT)
int main() {
CURL* handle = curl_easy_init();
return curl_easy_setopt(handle, CURLOPT_PROXY_SSLCERT, \"client.pem\"); }")
- if (CMAKE_CROSSCOMPILING)
- check_c_source_compiles("${CHECK_CURL_HAS_H2}" CURL_HAS_H2)
- check_c_source_compiles("${CHECK_CURL_HAS_TLS_PROXY}" CURL_HAS_TLS_PROXY)
- else()
- check_c_source_runs("${CHECK_CURL_HAS_H2}" CURL_HAS_H2)
- check_c_source_runs("${CHECK_CURL_HAS_TLS_PROXY}" CURL_HAS_TLS_PROXY)
- endif()
+ set(CURL_HAS_H2 OFF)
+ set(CURL_HAS_TLS_PROXY ON)
elseif(ENABLE_WINDOWS_CLIENT)
# NOTE: HTTP/2 is not supported when using IXML_HTTP_REQUEST_2
if(USE_IXML_HTTP_REQUEST_2)
12 changes: 12 additions & 0 deletions ports/aws-sdk-cpp/patch-relocatable-rpath.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 41d220d5fa..f6ee9a2a74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -147,7 +147,6 @@ if (LEGACY_BUILD)
endif ()

# Add Linker search paths to RPATH so as to fix the problem where some linkers can't find cross-compiled dependent libraries in customer paths when linking executables.
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true)

# build the sdk targets
project("aws-cpp-sdk-all" VERSION "${PROJECT_VERSION}" LANGUAGES CXX)
102 changes: 102 additions & 0 deletions ports/aws-sdk-cpp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
vcpkg_buildpath_length_warning(37)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO aws/aws-sdk-cpp
REF "${VERSION}"
SHA512 826be806ddd87eb452f97df70b19df4194e984775408d8f99246244b6949abcab583e4cbe1ae3bc5d61f3c78267d0e75ea9e69956188ab12e0318344a4314591
PATCHES
patch-relocatable-rpath.patch
fix-aws-root.patch
lock-curl-http-and-tls-settings.patch
fix_find_curl.patch
)

string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" FORCE_SHARED_CRT)

set(EXTRA_ARGS "")
if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS)
set(rpath "@loader_path")
elseif (VCPKG_TARGET_IS_ANDROID)
set(EXTRA_ARGS "-DTARGET_ARCH=ANDROID"
"-DGIT_EXECUTABLE=--invalid-git-executable--"
"-DGIT_FOUND=TRUE"
"-DNDK_DIR=$ENV{ANDROID_NDK_HOME}"
"-DANDROID_BUILD_ZLIB=FALSE"
"-DANDROID_BUILD_CURL=FALSE"
"-DANDROID_BUILD_OPENSSL=FALSE"
)
else()
set(rpath "\$ORIGIN")
endif()

string(REPLACE "awsmigrationhub" "AWSMigrationHub" targets "${FEATURES}")
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE
OPTIONS
${EXTRA_ARGS}
"-DENABLE_UNITY_BUILD=ON"
"-DENABLE_TESTING=OFF"
"-DFORCE_SHARED_CRT=${FORCE_SHARED_CRT}"
"-DBUILD_ONLY=${targets}"
"-DBUILD_DEPS=OFF"
"-DBUILD_SHARED_LIBS=OFF"
"-DAWS_SDK_WARNINGS_ARE_ERRORS=OFF"
"-DCMAKE_INSTALL_RPATH=${rpath}"
"-DCMAKE_MODULE_PATH=${CURRENT_INSTALLED_DIR}/share/aws-c-common" # use extra cmake files
)
vcpkg_cmake_install()

foreach(TARGET IN LISTS targets)
string(TOLOWER "aws-cpp-sdk-${TARGET}" package)
vcpkg_cmake_config_fixup(PACKAGE_NAME "${package}" CONFIG_PATH "lib/cmake/aws-cpp-sdk-${TARGET}" DO_NOT_DELETE_PARENT_CONFIG_PATH)
endforeach()
vcpkg_cmake_config_fixup(PACKAGE_NAME "awssdk" CONFIG_PATH "lib/cmake/AWSSDK")

vcpkg_copy_pdbs()

file(GLOB_RECURSE AWS_TARGETS "${CURRENT_PACKAGES_DIR}/share/*/*-targets-*.cmake")
foreach(AWS_TARGET IN LISTS AWS_TARGETS)
file(READ ${AWS_TARGET} _contents)
string(REGEX REPLACE
"bin\\/([A-Za-z0-9_.-]+\\.lib)"
"lib/\\1"
_contents "${_contents}")
file(WRITE ${AWS_TARGET} "${_contents}")
endforeach()

file(GLOB AWS_CONFIGS "${CURRENT_PACKAGES_DIR}/share/*/aws-cpp-sdk-*-config.cmake")
list(FILTER AWS_CONFIGS EXCLUDE REGEX "aws-cpp-sdk-core-config\\.cmake\$")
foreach(AWS_CONFIG IN LISTS AWS_CONFIGS)
file(READ "${AWS_CONFIG}" _contents)
file(WRITE "${AWS_CONFIG}" "include(CMakeFindDependencyMacro)\nfind_dependency(aws-cpp-sdk-core)\n${_contents}")
endforeach()

file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/lib/pkgconfig"
"${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig"
"${CURRENT_PACKAGES_DIR}/nuget"
"${CURRENT_PACKAGES_DIR}/debug/nuget"
)

if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(GLOB LIB_FILES ${CURRENT_PACKAGES_DIR}/bin/*.lib)
if(LIB_FILES)
file(COPY ${LIB_FILES} DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
file(REMOVE ${LIB_FILES})
endif()
file(GLOB DEBUG_LIB_FILES ${CURRENT_PACKAGES_DIR}/debug/bin/*.lib)
if(DEBUG_LIB_FILES)
file(COPY ${DEBUG_LIB_FILES} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
file(REMOVE ${DEBUG_LIB_FILES})
endif()

file(APPEND "${CURRENT_PACKAGES_DIR}/include/aws/core/SDKConfig.h" "#ifndef USE_IMPORT_EXPORT\n#define USE_IMPORT_EXPORT\n#endif")
endif()

configure_file("${CURRENT_PORT_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" @ONLY)

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
12 changes: 12 additions & 0 deletions ports/aws-sdk-cpp/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
The package @PORT@:@TARGET_TRIPLET@ provides CMake targets:

When using AWSSDK, AWSSDK_ROOT_DIR must be defined by the user.
find_package(AWSSDK CONFIG COMPONENTS core dynamodb kinesis s3 REQUIRED)
target_include_directories(main PRIVATE ${AWSSDK_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${AWSSDK_LIBRARIES})

OR

find_package(aws-cpp-sdk-core REQUIRED)
target_include_directories(main PRIVATE aws-cpp-sdk-core)
target_link_libraries(main PRIVATE aws-cpp-sdk-core)
38 changes: 38 additions & 0 deletions ports/aws-sdk-cpp/vcpkg.in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "aws-sdk-cpp",
"version": "1.11.215",
"port-version": 1,
"description": "AWS SDK for C++",
"homepage": "https://github.com/aws/aws-sdk-cpp",
"license": "Apache-2.0",
"supports": "!(windows & arm) & !uwp",
"dependencies": [
"aws-crt-cpp",
{
"name": "curl",
"default-features": false,
"features": [
"ssl"
],
"platform": "!uwp & !windows"
},
{
"name": "openssl",
"platform": "!uwp & !windows"
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
],
"default-features": [
"dynamodb",
"kinesis",
"s3"
]
}
Loading

0 comments on commit daf9c82

Please sign in to comment.