From 3f80148ef55e16cf29d6388589e97bfcbcea4495 Mon Sep 17 00:00:00 2001
From: Greg Hogan <code@greghogan.com>
Date: Fri, 30 Apr 2021 13:58:33 +0000
Subject: [PATCH 04/10] gnu: Add aws-c-http.

* gnu/packages/c.scm (aws-c-http): New variable.
* gnu/packages/patches/aws-c-http-cmake-prefix.patch,
gnu/packages/patches/aws-c-http-disable-networking-tests.patch: New files.
* gnu/local.mk (dist_patch_DATA): Add them.
---
 gnu/local.mk                                  |  2 +
 gnu/packages/c.scm                            | 31 ++++++++++++
 .../patches/aws-c-http-cmake-prefix.patch     | 13 +++++
 .../aws-c-http-disable-networking-tests.patch | 48 +++++++++++++++++++
 4 files changed, 94 insertions(+)
 create mode 100644 gnu/packages/patches/aws-c-http-cmake-prefix.patch
 create mode 100644 gnu/packages/patches/aws-c-http-disable-networking-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3ca711d4a5..5b38a26391 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -837,6 +837,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/awesome-reproducible-png.patch		\
   %D%/packages/patches/aws-c-cal-cmake-prefix.patch		\
   %D%/packages/patches/aws-c-event-stream-cmake-prefix.patch  \
+  %D%/packages/patches/aws-c-http-cmake-prefix.patch		\
+  %D%/packages/patches/aws-c-http-disable-networking-tests.patch\
   %D%/packages/patches/aws-c-io-cmake-prefix.patch		\
   %D%/packages/patches/aws-c-io-disable-networking-tests.patch	\
   %D%/packages/patches/aws-checksums-cmake-prefix.patch		\
diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index 985a1d9de7..f9037db005 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -695,3 +695,34 @@ event-driven, asynchronous network application protocols.")
 cryptographic primitives for the @acronym{AWS,Amazon Web Services} SDK.")
     (home-page "https://github.com/awslabs/aws-c-cal")
     (license license:asl2.0)))
+
+(define-public aws-c-http
+  (package
+    (name "aws-c-http")
+    (version "0.6.2")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url (string-append "https://github.com/awslabs/" name))
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "03d23yi1iprk3pic6i05ygljs687yanzp5r3m3s943mzd91axnd9"))
+              (patches
+               (search-patches
+                "aws-c-http-cmake-prefix.patch"
+                "aws-c-http-disable-networking-tests.patch"))))
+    (build-system cmake-build-system)
+    (arguments
+     '(#:configure-flags
+       '("-DBUILD_SHARED_LIBS=ON")))
+    (propagated-inputs
+     `(("aws-c-compression" ,aws-c-compression)
+       ("aws-c-io" ,aws-c-io)))
+    (synopsis "Amazon Web Services HTTP library")
+    (description
+     "This library provides a C99 implementation of the HTTP/1.1 and HTTP/2
+specifications.")
+    (home-page "https://github.com/awslabs/aws-c-http")
+    (license license:asl2.0)))
diff --git a/gnu/packages/patches/aws-c-http-cmake-prefix.patch b/gnu/packages/patches/aws-c-http-cmake-prefix.patch
new file mode 100644
index 0000000000..ec650a7e82
--- /dev/null
+++ b/gnu/packages/patches/aws-c-http-cmake-prefix.patch
@@ -0,0 +1,13 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -7,6 +7,10 @@ endif()
+ 
+ option(ENABLE_PROXY_INTEGRATION_TESTS "Whether to run the proxy integration tests that rely on a proxy server installed and running locally" OFF)
+ 
++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-c-http-disable-networking-tests.patch b/gnu/packages/patches/aws-c-http-disable-networking-tests.patch
new file mode 100644
index 0000000000..9bfd422341
--- /dev/null
+++ b/gnu/packages/patches/aws-c-http-disable-networking-tests.patch
@@ -0,0 +1,48 @@
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -136,8 +136,8 @@ add_test_case(strutil_trim_http_whitespace)
+ add_test_case(strutil_is_http_token)
+ add_test_case(strutil_is_lowercase_http_token)
+ 
+-add_net_test_case(tls_download_medium_file_h1)
+-add_net_test_case(tls_download_medium_file_h2)
++#add_net_test_case(tls_download_medium_file_h1)
++#add_net_test_case(tls_download_medium_file_h2)
+ 
+ add_test_case(websocket_decoder_sanity_check)
+ add_test_case(websocket_decoder_simplest_frame)
+@@ -438,21 +438,21 @@ add_test_case(connection_setup_shutdown)
+ 
+ # connection manager tests
+ # unit tests where connections are mocked
+-add_net_test_case(test_connection_manager_setup_shutdown)
+-add_net_test_case(test_connection_manager_acquire_release_mix_synchronous)
+-add_net_test_case(test_connection_manager_connect_callback_failure)
+-add_net_test_case(test_connection_manager_connect_immediate_failure)
+-add_net_test_case(test_connection_manager_proxy_setup_shutdown)
+-add_net_test_case(test_connection_manager_idle_culling_single)
+-add_net_test_case(test_connection_manager_idle_culling_many)
+-add_net_test_case(test_connection_manager_idle_culling_mixture)
++#add_net_test_case(test_connection_manager_setup_shutdown)
++#add_net_test_case(test_connection_manager_acquire_release_mix_synchronous)
++#add_net_test_case(test_connection_manager_connect_callback_failure)
++#add_net_test_case(test_connection_manager_connect_immediate_failure)
++#add_net_test_case(test_connection_manager_proxy_setup_shutdown)
++#add_net_test_case(test_connection_manager_idle_culling_single)
++#add_net_test_case(test_connection_manager_idle_culling_many)
++#add_net_test_case(test_connection_manager_idle_culling_mixture)
+ 
+ # tests where we establish real connections
+-add_net_test_case(test_connection_manager_single_connection)
+-add_net_test_case(test_connection_manager_many_connections)
+-add_net_test_case(test_connection_manager_acquire_release)
+-add_net_test_case(test_connection_manager_close_and_release)
+-add_net_test_case(test_connection_manager_acquire_release_mix)
++#add_net_test_case(test_connection_manager_single_connection)
++#add_net_test_case(test_connection_manager_many_connections)
++#add_net_test_case(test_connection_manager_acquire_release)
++#add_net_test_case(test_connection_manager_close_and_release)
++#add_net_test_case(test_connection_manager_acquire_release_mix)
+ 
+ 
+ add_test_case(h1_server_sanity_check)
-- 
2.31.1

