[aws-sdk-cpp] Fix linking issue when using MinGW (#39064)

It appears like the aws-sdk-cpp maintainers, in an attempt to avoid a
warning when compiling with Visual Studio, opted to use a Microsoft-only
function for reading environment variables. As a result, linking the
library will fail in MinGW environments. This PR adds a patch to
aws-sdk-cpp port that will replace the non-standard function with a
standard compliant version when being compiled for Windows using a
non-Microsoft compiler.

- [x] Changes comply with the [maintainer
guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md).
- [ ] SHA512s are updated for each updated download.
- [ ] The "supports" clause reflects platforms that may be fixed by this
new version.
- [ ] Any fixed [CI
baseline](https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt)
entries are removed from that file.
- [ ] Any patches that are no longer applied are deleted from the port's
directory.
- [x] The version database is fixed by rerunning `./vcpkg x-add-version
--all` and committing the result.
- [x] Only one version is added to each modified port's versions file.
This commit is contained in:
Fabian Wosar 2024-06-04 06:46:34 +01:00 committed by GitHub
parent b43063e2fd
commit 283f99c84a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 2 deletions

View File

@ -0,0 +1,23 @@
diff --git a/src/aws-cpp-sdk-core/source/platform/windows/Environment.cpp b/src/aws-cpp-sdk-core/source/platform/windows/Environment.cpp
index d8b540312..b552a9dbf 100644
--- a/src/aws-cpp-sdk-core/source/platform/windows/Environment.cpp
+++ b/src/aws-cpp-sdk-core/source/platform/windows/Environment.cpp
@@ -19,6 +19,7 @@ that would need to be manually freed in all the client functions, just copy it i
*/
Aws::String GetEnv(const char *variableName)
{
+#ifdef _MSC_VER
char* variableValue = nullptr;
std::size_t valueSize = 0;
auto queryResult = _dupenv_s(&variableValue, &valueSize, variableName);
@@ -31,6 +32,10 @@ Aws::String GetEnv(const char *variableName)
}
return result;
+#else
+ auto variableValue = std::getenv(variableName);
+ return Aws::String( variableValue ? variableValue : "" );
+#endif
}
} // namespace Environment

View File

@ -10,6 +10,7 @@ vcpkg_from_github(
fix-aws-root.patch
lock-curl-http-and-tls-settings.patch
fix_find_curl.patch
fix-mingw-compatibility.patch
)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" FORCE_SHARED_CRT)

View File

@ -2,7 +2,7 @@
"$note": "Automatically generated by generateFeatures.ps1",
"name": "aws-sdk-cpp",
"version": "1.11.285",
"port-version": 2,
"port-version": 3,
"description": "AWS SDK for C++",
"homepage": "https://github.com/aws/aws-sdk-cpp",
"license": "Apache-2.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "27092f8627e032baefd12137452180975e1715d1",
"version": "1.11.285",
"port-version": 3
},
{
"git-tree": "252f02a82047e15da94b42568b63b4064ae55e56",
"version": "1.11.285",

View File

@ -426,7 +426,7 @@
},
"aws-sdk-cpp": {
"baseline": "1.11.285",
"port-version": 2
"port-version": 3
},
"azmq": {
"baseline": "2023-03-23",