python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / aws-sdk-cpp / default.nix
blobefe8129d3b4f616f93b2964e9e40e4e5922cd23b
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , fetchpatch
5 , cmake
6 , curl
7 , openssl
8 , s2n-tls
9 , zlib
10 , aws-crt-cpp
11 , aws-c-cal
12 , aws-c-common
13 , aws-c-event-stream
14 , aws-c-io
15 , aws-checksums
16 , CoreAudio
17 , AudioToolbox
18 , # Allow building a limited set of APIs, e.g. ["s3" "ec2"].
19   apis ? ["*"]
20 , # Whether to enable AWS' custom memory management.
21   customMemoryManagement ? true
24 let
25   host_os = if stdenv.hostPlatform.isDarwin then "APPLE"
26        else if stdenv.hostPlatform.isAndroid then "ANDROID"
27        else if stdenv.hostPlatform.isWindows then "WINDOWS"
28        else if stdenv.hostPlatform.isLinux then "LINUX"
29        else throw "Unknown host OS";
32 stdenv.mkDerivation rec {
33   pname = "aws-sdk-cpp";
34   version = "1.9.294";
36   src = fetchFromGitHub {
37     owner = "aws";
38     repo = "aws-sdk-cpp";
39     rev = version;
40     sha256 = "sha256-Z1eRKW+8nVD53GkNyYlZjCcT74MqFqqRMeMc33eIQ9g=";
41   };
43   patches = [
44     ./cmake-dirs.patch
45   ];
47   postPatch = ''
48     # Avoid blanket -Werror to evade build failures on less
49     # tested compilers.
50     substituteInPlace cmake/compiler_settings.cmake \
51       --replace '"-Werror"' ' '
53     # Missing includes for GCC11
54     sed '5i#include <thread>' -i \
55       aws-cpp-sdk-cloudfront-integration-tests/CloudfrontOperationTest.cpp \
56       aws-cpp-sdk-cognitoidentity-integration-tests/IdentityPoolOperationTest.cpp \
57       aws-cpp-sdk-dynamodb-integration-tests/TableOperationTest.cpp \
58       aws-cpp-sdk-elasticfilesystem-integration-tests/ElasticFileSystemTest.cpp \
59       aws-cpp-sdk-lambda-integration-tests/FunctionTest.cpp \
60       aws-cpp-sdk-mediastore-data-integration-tests/MediaStoreDataTest.cpp \
61       aws-cpp-sdk-queues/source/sqs/SQSQueue.cpp \
62       aws-cpp-sdk-redshift-integration-tests/RedshiftClientTest.cpp \
63       aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp \
64       aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp \
65       aws-cpp-sdk-s3control-integration-tests/S3ControlTest.cpp \
66       aws-cpp-sdk-sqs-integration-tests/QueueOperationTest.cpp \
67       aws-cpp-sdk-transfer-tests/TransferTests.cpp
68     # Flaky on Hydra
69     rm aws-cpp-sdk-core-tests/aws/auth/AWSCredentialsProviderTest.cpp
70     # Includes aws-c-auth private headers, so only works with submodule build
71     rm aws-cpp-sdk-core-tests/aws/auth/AWSAuthSignerTest.cpp
72   '' + lib.optionalString stdenv.hostPlatform.isMusl ''
73     # TestRandomURLMultiThreaded fails
74     rm aws-cpp-sdk-core-tests/http/HttpClientTest.cpp
75   '' + lib.optionalString stdenv.isi686 ''
76     # EPSILON is exceeded
77     rm aws-cpp-sdk-core-tests/aws/client/AdaptiveRetryStrategyTest.cpp
78   '';
80   # FIXME: might be nice to put different APIs in different outputs
81   # (e.g. libaws-cpp-sdk-s3.so in output "s3").
82   outputs = [ "out" "dev" ];
84   nativeBuildInputs = [ cmake curl ];
86   buildInputs = [
87     curl openssl zlib
88   ] ++ lib.optionals (stdenv.isDarwin &&
89                         ((builtins.elem "text-to-speech" apis) ||
90                          (builtins.elem "*" apis)))
91          [ CoreAudio AudioToolbox ];
93   # propagation is needed for Security.framework to be available when linking
94   propagatedBuildInputs = [ aws-crt-cpp ];
96   cmakeFlags = [
97     "-DBUILD_DEPS=OFF"
98   ] ++ lib.optional (!customMemoryManagement) "-DCUSTOM_MEMORY_MANAGEMENT=0"
99   ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
100     "-DENABLE_TESTING=OFF"
101     "-DCURL_HAS_H2=1"
102     "-DCURL_HAS_TLS_PROXY=1"
103     "-DTARGET_ARCH=${host_os}"
104   ] ++ lib.optional (apis != ["*"])
105     "-DBUILD_ONLY=${lib.concatStringsSep ";" apis}";
107   NIX_CFLAGS_COMPILE = [
108     # openssl 3 generates several deprecation warnings
109     "-Wno-error=deprecated-declarations"
110   ];
112   # aws-cpp-sdk-core-tests/aws/client/AWSClientTest.cpp
113   # seem to have a datarace
114   enableParallelChecking = false;
116   postFixupHooks = [
117     # This bodge is necessary so that the file that the generated -config.cmake file
118     # points to an existing directory.
119     "mkdir -p $out/include"
120   ];
122   __darwinAllowLocalNetworking = true;
124   # Builds in 2+h with 2 cores, and ~10m with a big-parallel builder.
125   requiredSystemFeatures = [ "big-parallel" ];
127   meta = with lib; {
128     description = "A C++ interface for Amazon Web Services";
129     homepage = "https://github.com/aws/aws-sdk-cpp";
130     license = licenses.asl20;
131     platforms = platforms.unix;
132     maintainers = with maintainers; [ eelco orivej ];
133     # building ec2 runs out of memory: cc1plus: out of memory allocating 33554372 bytes after a total of 74424320 bytes
134     broken = stdenv.buildPlatform.is32bit && ((builtins.elem "ec2" apis) || (builtins.elem "*" apis));
135   };