From c3dd495e5aa55f0f86344963009ae55f5a65328b Mon Sep 17 00:00:00 2001
From: Greg Hogan <code@greghogan.com>
Date: Fri, 30 Apr 2021 14:06:34 +0000
Subject: [PATCH 11/12] gnu: Add aws-crt-cpp.

* gnu/packages/cpp.scm (aws-crt-cpp): New variable.
* gnu/packages/patches/aws-crt-cpp-cmake-prefix.patch,
gnu/packages/patches/aws-crt-cpp-disable-networking-tests.patch: New files.
* gnu/local.mk (dist_patch_DATA): Add them.
---
 gnu/local.mk                                  |  2 +
 gnu/packages/cpp.scm                          | 39 +++++++++++++++
 .../patches/aws-crt-cpp-cmake-prefix.patch    | 13 +++++
 ...aws-crt-cpp-disable-networking-tests.patch | 47 +++++++++++++++++++
 4 files changed, 101 insertions(+)
 create mode 100644 gnu/packages/patches/aws-crt-cpp-cmake-prefix.patch
 create mode 100644 gnu/packages/patches/aws-crt-cpp-disable-networking-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 4f5f3b7bdf..65d91ffd9b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -876,6 +876,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/aws-c-s3-cmake-prefix.patch		\
   %D%/packages/patches/aws-c-s3-disable-networking-tests.patch	\
   %D%/packages/patches/aws-checksums-cmake-prefix.patch		\
+  %D%/packages/patches/aws-crt-cpp-cmake-prefix.patch		\
+  %D%/packages/patches/aws-crt-cpp-disable-networking-tests.patch	\
   %D%/packages/patches/azr3.patch				\
   %D%/packages/patches/bash-reproducible-linux-pgrp-pipe.patch	\
   %D%/packages/patches/bash-completion-directories.patch	\
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index 5fd9002440..592320b3ef 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -877,6 +877,45 @@ of C++14 components that complements @code{std} and Boost.")
     (supported-systems '("aarch64-linux" "x86_64-linux"))
     (license license:asl2.0)))
 
+(define-public aws-crt-cpp
+  (let* ((commit "c2d6ffa5597825111cc76ad71ffc6aef664d0f25")
+         (revision "1"))
+    (package
+      (name "aws-crt-cpp")
+      (version (git-version "0.14.2" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/awslabs/aws-crt-cpp")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0l7iwynk2rgzjnr1hi1raazghmk4m7pj47vdq2kf2cfz0b6v9jf5"))
+                (patches
+                 (search-patches
+                  "aws-crt-cpp-cmake-prefix.patch"
+                  "aws-crt-cpp-disable-networking-tests.patch"))))
+      (build-system cmake-build-system)
+      (arguments
+       '(#:configure-flags
+         '("-DBUILD_SHARED_LIBS=ON"
+           "-DBUILD_DEPS=OFF")))
+      (propagated-inputs
+       `(("aws-c-auth" ,aws-c-auth)
+         ("aws-c-cal" ,aws-c-cal)
+         ("aws-c-event-stream" ,aws-c-event-stream)
+         ("aws-c-http" ,aws-c-http)
+         ("aws-c-mqtt" ,aws-c-mqtt)
+         ("aws-c-s3" ,aws-c-s3)))
+      (synopsis "C++ wrapper for Amazon Web Services C libraries")
+      (description "The AWS Common Runtime (CRT) library provides a C++ wrapper
+implementation for the following @acronym{AWS,Amazon Web Services} C libraries:
+aws-c-auth, aws-c-cal, aws-c-common, aws-c-compression, aws-c-event-stream,
+aws-c-http, aws-c-io, aws-c-mqtt, aws-checksums, and s2n.")
+      (home-page "https://github.com/awslabs/aws-crt-cpp")
+      (license license:asl2.0))))
+
 (define-public aws-sdk-cpp
   (package
     (name "aws-sdk-cpp")
diff --git a/gnu/packages/patches/aws-crt-cpp-cmake-prefix.patch b/gnu/packages/patches/aws-crt-cpp-cmake-prefix.patch
new file mode 100644
index 0000000000..b45818875f
--- /dev/null
+++ b/gnu/packages/patches/aws-crt-cpp-cmake-prefix.patch
@@ -0,0 +1,13 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -39,6 +39,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+ include(AwsCheckHeadersCxx)
+ include(CTest)
+ 
++if (DEFINED ENV{CMAKE_PREFIX_PATH})
++    set(CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
++endif()
++
+ if (DEFINED CMAKE_PREFIX_PATH)
+     file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
+ endif()
diff --git a/gnu/packages/patches/aws-crt-cpp-disable-networking-tests.patch b/gnu/packages/patches/aws-crt-cpp-disable-networking-tests.patch
new file mode 100644
index 0000000000..4c1be7d028
--- /dev/null
+++ b/gnu/packages/patches/aws-crt-cpp-disable-networking-tests.patch
@@ -0,0 +1,47 @@
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -13,9 +13,9 @@ add_test_case(ApiMultiDefaultCreateDestroy)
+ add_test_case(EventLoopResourceSafety)
+ add_test_case(ClientBootstrapResourceSafety)
+ if (NOT BYO_CRYPTO)
+-    add_net_test_case(MqttClientResourceSafety)
++    #add_net_test_case(MqttClientResourceSafety)
+     add_net_test_case(MqttClientNewConnectionUninitializedTlsContext)
+-    add_net_test_case(TLSContextResourceSafety)
++    #add_net_test_case(TLSContextResourceSafety)
+     add_net_test_case(TLSContextUninitializedNewConnectionOptions)
+ endif ()
+ add_test_case(Base64RoundTrip)
+@@ -29,15 +29,15 @@ add_test_case(SHA256ResourceSafety)
+ add_test_case(MD5ResourceSafety)
+ add_test_case(SHA256HMACResourceSafety)
+ if (NOT BYO_CRYPTO)
+-    add_net_test_case(HttpDownloadNoBackPressureHTTP1_1)
+-    add_net_test_case(HttpDownloadNoBackPressureHTTP2)
+-    add_net_test_case(HttpStreamUnActivated)
++    #add_net_test_case(HttpDownloadNoBackPressureHTTP1_1)
++    #add_net_test_case(HttpDownloadNoBackPressureHTTP2)
++    #add_net_test_case(HttpStreamUnActivated)
+     add_net_test_case(HttpCreateConnectionInvalidTlsConnectionOptions)
+     add_net_test_case(IotPublishSubscribe)
+-    add_net_test_case(HttpClientConnectionManagerResourceSafety)
++    #add_net_test_case(HttpClientConnectionManagerResourceSafety)
+     add_net_test_case(HttpClientConnectionManagerInvalidTlsConnectionOptions)
+-    add_net_test_case(HttpClientConnectionWithPendingAcquisitions)
+-    add_net_test_case(HttpClientConnectionWithPendingAcquisitionsAndClosedConnections)
++    #add_net_test_case(HttpClientConnectionWithPendingAcquisitions)
++    #add_net_test_case(HttpClientConnectionWithPendingAcquisitionsAndClosedConnections)
+ endif ()
+ add_test_case(DefaultResolution)
+ add_test_case(OptionalCopySafety)
+@@ -55,8 +55,8 @@ add_test_case(TestProviderEnvironmentGet)
+ add_test_case(TestProviderProfileGet)
+ add_test_case(TestProviderImdsGet)
+ if (NOT BYO_CRYPTO)
+-    add_net_test_case(TestProviderDefaultChainGet)
+-    add_net_test_case(TestProviderDefaultChainManualTlsContextGet)
++    #add_net_test_case(TestProviderDefaultChainGet)
++    #add_net_test_case(TestProviderDefaultChainManualTlsContextGet)
+ endif ()
+ add_test_case(TestProviderDelegateGet)
+ add_test_case(HttpRequestTestCreateDestroy)
-- 
2.33.0

