From 91be8099882b845142bc8f5cc2a65768cf3b59fb Mon Sep 17 00:00:00 2001
From: Greg Hogan <code@greghogan.com>
Date: Tue, 19 Jan 2021 12:53:18 +0000
Subject: [PATCH 5/7] gnu: Add aws-c-io.

* gnu/packages/c.scm (aws-c-io): New variable.
* gnu/packages/patches/aws-c-io-cmake-prefix.patch,
gnu/packages/patches/aws-c-io-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-io-cmake-prefix.patch       | 13 +++
 .../aws-c-io-disable-networking-tests.patch   | 81 +++++++++++++++++++
 4 files changed, 127 insertions(+)
 create mode 100644 gnu/packages/patches/aws-c-io-cmake-prefix.patch
 create mode 100644 gnu/packages/patches/aws-c-io-disable-networking-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 5fb2d56018..37d351acca 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -832,6 +832,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-io-cmake-prefix.patch		\
+  %D%/packages/patches/aws-c-io-disable-networking-tests.patch		\
   %D%/packages/patches/aws-checksums-cmake-prefix.patch		\
   %D%/packages/patches/azr3.patch				\
   %D%/packages/patches/bash-reproducible-linux-pgrp-pipe.patch	\
diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index c83e6f36e3..74c4b673a7 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -621,6 +621,37 @@ communication.")
     (home-page "https://github.com/awslabs/aws-c-event-stream")
     (license license:asl2.0)))
 
+(define-public aws-c-io
+  (package
+    (name "aws-c-io")
+    (version "0.9.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
+                "1vwyf1pm0hhcypyjc9xh9x7y50ic79xlbck1yf9d9wz0bnh43p7v"))
+              (patches
+               (search-patches
+                "aws-c-io-cmake-prefix.patch"
+                "aws-c-io-disable-networking-tests.patch"))))
+    (build-system cmake-build-system)
+    (arguments
+     '(#:configure-flags
+       '("-DBUILD_SHARED_LIBS=ON")))
+    (propagated-inputs
+     `(("aws-c-cal" ,aws-c-cal)
+       ("aws-c-common" ,aws-c-common)
+       ("s2n" ,s2n)))
+    (synopsis "Event driven framework for implementing application protocols")
+    (description "This library provides a C99 framework for constructing
+event-driven, asynchronous network application protocols.")
+    (home-page "https://github.com/awslabs/aws-c-io")
+    (license license:asl2.0)))
+
 (define-public aws-c-cal
   (package
     (name "aws-c-cal")
diff --git a/gnu/packages/patches/aws-c-io-cmake-prefix.patch b/gnu/packages/patches/aws-c-io-cmake-prefix.patch
new file mode 100644
index 0000000000..da3e4eb4a5
--- /dev/null
+++ b/gnu/packages/patches/aws-c-io-cmake-prefix.patch
@@ -0,0 +1,13 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -6,6 +6,10 @@ if (POLICY CMP0069)
+     cmake_policy(SET CMP0069 NEW) # Enable LTO/IPO if available in the compiler, see AwsCFlags
+ endif()
+ 
++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-io-disable-networking-tests.patch b/gnu/packages/patches/aws-c-io-disable-networking-tests.patch
new file mode 100644
index 0000000000..09fe11310c
--- /dev/null
+++ b/gnu/packages/patches/aws-c-io-disable-networking-tests.patch
@@ -0,0 +1,81 @@
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -52,8 +52,8 @@ add_test_case(local_socket_communication)
+ add_net_test_case(tcp_socket_communication)
+ add_net_test_case(udp_socket_communication)
+ add_test_case(udp_bind_connect_communication)
+-add_net_test_case(connect_timeout)
+-add_net_test_case(connect_timeout_cancelation)
++#add_net_test_case(connect_timeout)
++#add_net_test_case(connect_timeout_cancelation)
+ if (USE_VSOCK)
+ 	add_test_case(vsock_loopback_socket_communication)
+ endif ()
+@@ -64,7 +64,7 @@ add_test_case(incoming_tcp_sock_errors)
+ add_test_case(incoming_duplicate_tcp_bind_errors)
+ add_test_case(incoming_udp_sock_errors)
+ add_test_case(wrong_thread_read_write_fails)
+-add_net_test_case(cleanup_before_connect_or_timeout_doesnt_explode)
++#add_net_test_case(cleanup_before_connect_or_timeout_doesnt_explode)
+ add_test_case(cleanup_in_accept_doesnt_explode)
+ add_test_case(cleanup_in_write_cb_doesnt_explode)
+ add_test_case(sock_write_cb_is_async)
+@@ -81,21 +81,21 @@ add_test_case(channel_tasks_run)
+ add_test_case(channel_rejects_post_shutdown_tasks)
+ add_test_case(channel_cancels_pending_tasks)
+ add_test_case(channel_duplicate_shutdown)
+-add_net_test_case(channel_connect_some_hosts_timeout)
++#add_net_test_case(channel_connect_some_hosts_timeout)
+
+-add_net_test_case(test_default_with_ipv6_lookup)
++#add_net_test_case(test_default_with_ipv6_lookup)
+ add_test_case(test_resolver_ipv6_address_lookup)
+-add_net_test_case(test_default_with_multiple_lookups)
++#add_net_test_case(test_default_with_multiple_lookups)
+ add_test_case(test_resolver_ipv4_address_lookup)
+-add_net_test_case(test_default_with_ipv4_only_lookup)
++#add_net_test_case(test_default_with_ipv4_only_lookup)
+ add_test_case(test_resolver_ttls)
+ add_test_case(test_resolver_connect_failure_recording)
+ add_test_case(test_resolver_ttl_refreshes_on_resolve)
+
+ add_net_test_case(test_resolver_listener_create_destroy)
+-add_net_test_case(test_resolver_add_listener_before_host)
+-add_net_test_case(test_resolver_add_listener_after_host)
+-add_net_test_case(test_resolver_add_multiple_listeners_fn)
++#add_net_test_case(test_resolver_add_listener_before_host)
++#add_net_test_case(test_resolver_add_listener_after_host)
++#add_net_test_case(test_resolver_add_multiple_listeners_fn)
+ add_net_test_case(test_resolver_listener_host_re_add_fn)
+ add_net_test_case(test_resolver_listener_multiple_results)
+ add_net_test_case(test_resolver_listener_address_expired_fn)
+@@ -119,20 +119,20 @@ add_test_case(socket_handler_close)
+ if (NOT BYO_CRYPTO)
+     add_net_test_case(test_concurrent_cert_import)
+     add_test_case(tls_channel_echo_and_backpressure_test)
+-    add_net_test_case(tls_client_channel_negotiation_error_expired)
+-    add_net_test_case(tls_client_channel_negotiation_error_wrong_host)
+-    add_net_test_case(tls_client_channel_negotiation_error_self_signed)
+-    add_net_test_case(tls_client_channel_negotiation_error_untrusted_root)
++    #add_net_test_case(tls_client_channel_negotiation_error_expired)
++    #add_net_test_case(tls_client_channel_negotiation_error_wrong_host)
++    #add_net_test_case(tls_client_channel_negotiation_error_self_signed)
++    #add_net_test_case(tls_client_channel_negotiation_error_untrusted_root)
+     #track these down in s2n and find out why that aren't failing.
+     #add_net_test_case(tls_client_channel_negotiation_error_revoked)
+     #add_net_test_case(tls_client_channel_negotiation_error_pinning)
+-    add_net_test_case(tls_client_channel_negotiation_error_socket_closed)
+-    add_net_test_case(tls_client_channel_negotiation_success)
+-    add_net_test_case(tls_client_channel_negotiation_success_ecc256)
+-    add_net_test_case(tls_client_channel_negotiation_success_ecc384)
++    #add_net_test_case(tls_client_channel_negotiation_error_socket_closed)
++    #add_net_test_case(tls_client_channel_negotiation_success)
++    #add_net_test_case(tls_client_channel_negotiation_success_ecc256)
++    #add_net_test_case(tls_client_channel_negotiation_success_ecc384)
+     add_net_test_case(tls_server_multiple_connections)
+     add_net_test_case(tls_server_hangup_during_negotiation)
+-    add_net_test_case(tls_client_channel_no_verify)
++    #add_net_test_case(tls_client_channel_no_verify)
+     add_net_test_case(test_tls_negotiation_timeout)
+     add_net_test_case(tls_double_channel)
+     add_net_test_case(alpn_successfully_negotiates)
-- 
2.30.2

