From 116bb95de9ddaf207c8aef5d9efc650cc00d3291 Mon Sep 17 00:00:00 2001 From: Vera Xia Date: Mon, 26 Aug 2024 09:50:37 -0700 Subject: [PATCH 01/11] Expose socket options from Mqtt5ClientBuilder (#652) --- include/aws/iot/Mqtt5Client.h | 9 +++++++++ source/iot/Mqtt5Client.cpp | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/include/aws/iot/Mqtt5Client.h b/include/aws/iot/Mqtt5Client.h index fbe5b8524..e1711bcee 100644 --- a/include/aws/iot/Mqtt5Client.h +++ b/include/aws/iot/Mqtt5Client.h @@ -298,6 +298,15 @@ namespace Aws */ Mqtt5ClientBuilder &WithCertificateAuthority(const Crt::ByteCursor &cert) noexcept; + /** + * Overrides the socket properties of the underlying MQTT connections made by the client. Leave undefined + * to use defaults (no TCP keep alive, 10 second socket timeout). + * + * @param socketOptions - The socket properties of the underlying MQTT connections made by the client + * @return - The Mqtt5ClientBuilder + */ + Mqtt5ClientBuilder &WithSocketOptions(Crt::Io::SocketOptions socketOptions) noexcept; + /** * Sets http proxy options. * diff --git a/source/iot/Mqtt5Client.cpp b/source/iot/Mqtt5Client.cpp index e9cc5226e..fa4b27e72 100644 --- a/source/iot/Mqtt5Client.cpp +++ b/source/iot/Mqtt5Client.cpp @@ -344,6 +344,12 @@ namespace Aws return *this; } + Mqtt5ClientBuilder &Mqtt5ClientBuilder::WithSocketOptions(Crt::Io::SocketOptions socketOptions) noexcept + { + m_options->WithSocketOptions(std::move(socketOptions)); + return *this; + } + Mqtt5ClientBuilder &Mqtt5ClientBuilder::WithHttpProxyOptions( const Crt::Http::HttpClientConnectionProxyOptions &proxyOptions) noexcept { From 8a9da3b018daf7bfaddf5a362bc010aa297fa630 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Mon, 26 Aug 2024 10:25:18 -0700 Subject: [PATCH 02/11] AutoTag PR for v0.28.0 (#654) Co-authored-by: GitHub Actions --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c7c49b4b4..697f087f3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.27.6 +0.28.0 From 00b6e9acdf03d6d0b3b69d7768514871b23a37ca Mon Sep 17 00:00:00 2001 From: sbiscigl Date: Fri, 23 Aug 2024 15:26:28 -0400 Subject: [PATCH 03/11] Fix typo in variant --- include/aws/crt/Variant.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/aws/crt/Variant.h b/include/aws/crt/Variant.h index f973316e6..e4cec4af5 100644 --- a/include/aws/crt/Variant.h +++ b/include/aws/crt/Variant.h @@ -53,7 +53,7 @@ namespace Aws { using VariantIndex = short; - template constexpr VariantIndex GetIndexOf(VariantIndex curIndex = -1) + template constexpr VariantIndex GetIndexOf(VariantIndex curIndex = 0) { return std::is_same::value ? curIndex : -1; } From 1cf4763184ef783dfc79b8b0a26f8cbaf578194f Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Tue, 27 Aug 2024 11:16:48 -0700 Subject: [PATCH 04/11] Fix Openssl Compile and Runtime Version Mismatch (#656) --- .github/workflows/ci.yml | 2 +- crt/aws-c-auth | 2 +- crt/aws-c-cal | 2 +- crt/aws-c-compression | 2 +- crt/aws-lc | 2 +- crt/s2n | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7631a21a..3f0fde7ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: - 'docs' env: - BUILDER_VERSION: v0.9.56 + BUILDER_VERSION: v0.9.63 BUILDER_SOURCE: releases BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net PACKAGE_NAME: aws-crt-cpp diff --git a/crt/aws-c-auth b/crt/aws-c-auth index 52bf59161..877c029fc 160000 --- a/crt/aws-c-auth +++ b/crt/aws-c-auth @@ -1 +1 @@ -Subproject commit 52bf591613d1a001c43ec99af7376f871759c5fe +Subproject commit 877c029fc4e93d205f9c6855188c3c51f6b497b4 diff --git a/crt/aws-c-cal b/crt/aws-c-cal index 77ca3aea8..2cb1d2eac 160000 --- a/crt/aws-c-cal +++ b/crt/aws-c-cal @@ -1 +1 @@ -Subproject commit 77ca3aea879bc768082fe7ec715adcde8e98c332 +Subproject commit 2cb1d2eac925e2dbc45025eb89af82bd790c23a0 diff --git a/crt/aws-c-compression b/crt/aws-c-compression index ea1d421a4..f36d01672 160000 --- a/crt/aws-c-compression +++ b/crt/aws-c-compression @@ -1 +1 @@ -Subproject commit ea1d421a421ad83a540309a94c38d50b6a5d836b +Subproject commit f36d01672d61e49d96a777870d456f66fa391cd4 diff --git a/crt/aws-lc b/crt/aws-lc index 057477806..2f1879759 160000 --- a/crt/aws-lc +++ b/crt/aws-lc @@ -1 +1 @@ -Subproject commit 05747780676652f41d0b9c570a495e4bb6608560 +Subproject commit 2f1879759b2e0fc70592665bdf10087b64f44b7d diff --git a/crt/s2n b/crt/s2n index 79c0f1b43..87f4a0585 160000 --- a/crt/s2n +++ b/crt/s2n @@ -1 +1 @@ -Subproject commit 79c0f1b434742d9f1152c48d3781433649f6f8fe +Subproject commit 87f4a0585dc3056433f193b9305f587cff239be3 From 433e820caa44a5f87219ae4c2d0dba5e9a456923 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Tue, 27 Aug 2024 11:17:22 -0700 Subject: [PATCH 05/11] AutoTag PR for v0.28.1 (#657) Co-authored-by: GitHub Actions --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 697f087f3..48f7a71df 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.28.0 +0.28.1 From a2cb2c5bd9cd51205ad52e4ab16d321b03caa068 Mon Sep 17 00:00:00 2001 From: sbiscigl Date: Thu, 29 Aug 2024 13:45:24 -0400 Subject: [PATCH 06/11] fix MSVC most vexing parse --- include/aws/crt/StringView.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/aws/crt/StringView.h b/include/aws/crt/StringView.h index 27c162ffe..3b6dc2f0f 100644 --- a/include/aws/crt/StringView.h +++ b/include/aws/crt/StringView.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) @@ -859,6 +860,6 @@ namespace std const Aws::Crt::basic_string_view &val) const noexcept { auto str = std::basic_string(val.data(), val.size()); - return std::hash>()(str); + return std::hash>{}(str); } } // namespace std From a4ef09fae941f4fe28eb03801bc8bbfe47928d74 Mon Sep 17 00:00:00 2001 From: SergeyRyabinin Date: Wed, 28 Aug 2024 18:34:18 +0000 Subject: [PATCH 07/11] Add wrappers around readsome and peek methods in std istream --- include/aws/crt/io/Stream.h | 24 ++++++++++++++++++++++++ source/io/Stream.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/include/aws/crt/io/Stream.h b/include/aws/crt/io/Stream.h index 91c8c36f2..b41f36413 100644 --- a/include/aws/crt/io/Stream.h +++ b/include/aws/crt/io/Stream.h @@ -114,6 +114,19 @@ namespace Aws */ virtual bool ReadImpl(ByteBuf &buffer) noexcept = 0; + /*** + * Read up-to buffer::capacity - buffer::len immediately available bytes into buffer::buffer + * Increment buffer::len by the amount you read in. + * + * @return true if nothing went wrong. + * Return true even if you read 0 bytes because the end-of-file has been reached. + * Return true even if you read 0 bytes because data is not currently available. + * + * Return false if an actual failure condition occurs, + * you SHOULD also raise an error via aws_raise_error(). + */ + virtual bool ReadSomeImpl(ByteBuf &buffer) noexcept = 0; + /** * @return the current status of the stream. */ @@ -136,6 +149,15 @@ namespace Aws */ virtual bool SeekImpl(int64_t offset, StreamSeekBasis seekBasis) noexcept = 0; + /** + * Peeks the stream + * + * Essentially calls peek on the underlying istream + * + * @return return value of the underlying istream::peek + */ + virtual int64_t PeekImpl() const noexcept = 0; + private: static int s_Seek(aws_input_stream *stream, int64_t offset, enum aws_stream_seek_basis basis); static int s_Read(aws_input_stream *stream, aws_byte_buf *dest); @@ -161,9 +183,11 @@ namespace Aws protected: bool ReadImpl(ByteBuf &buffer) noexcept override; + bool ReadSomeImpl(ByteBuf &buffer) noexcept override; StreamStatus GetStatusImpl() const noexcept override; int64_t GetLengthImpl() const noexcept override; bool SeekImpl(OffsetType offsetType, StreamSeekBasis seekBasis) noexcept override; + int64_t PeekImpl() const noexcept override; private: std::shared_ptr m_stream; diff --git a/source/io/Stream.cpp b/source/io/Stream.cpp index 975d1c516..b16267f10 100644 --- a/source/io/Stream.cpp +++ b/source/io/Stream.cpp @@ -5,6 +5,7 @@ #include #include +#include #include @@ -150,6 +151,26 @@ namespace Aws return status.is_valid && !status.is_end_of_stream; } + bool StdIOStreamInputStream::ReadSomeImpl(ByteBuf &buffer) noexcept + { + // I have no idea why "readsome() doesn't work at all" for the original dev. It works well for me + // Jokes aside, read will always block and try to read till eof + // readsome will return available bytes without waiting for eof and without closing the stream. + auto actuallyRead = m_stream->readsome( + reinterpret_cast(buffer.buffer + buffer.len), buffer.capacity - buffer.len); + + buffer.len += static_cast(actuallyRead); + + if (actuallyRead > 0 || (actuallyRead == 0 && m_stream->eof())) + { + return true; + } + + auto status = GetStatusImpl(); + + return status.is_valid && !status.is_end_of_stream; + } + StreamStatus StdIOStreamInputStream::GetStatusImpl() const noexcept { StreamStatus status; @@ -206,6 +227,11 @@ namespace Aws return true; } + + int64_t StdIOStreamInputStream::PeekImpl() const noexcept + { + return m_stream->peek(); + } } // namespace Io } // namespace Crt } // namespace Aws From e14c814728dc438a0b7dc694bd83418addc5a6a1 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Fri, 30 Aug 2024 09:25:19 -0700 Subject: [PATCH 08/11] AutoTag PR for v0.28.2 (#660) Co-authored-by: GitHub Actions --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 48f7a71df..a37255a85 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.28.1 +0.28.2 From 260575a9f3c961d9a3c73304c3df710ebe3c8403 Mon Sep 17 00:00:00 2001 From: Dmitriy Musatkin <63878209+DmitriyMusatkin@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:50:40 -0700 Subject: [PATCH 09/11] Bind out CRC64 (#662) --- CMakeLists.txt | 13 ++++++++++ crt/aws-checksums | 2 +- include/aws/crt/checksum/CRC.h | 39 ++++++++++++++++++++++++++++ include/aws/crt/crypto/Hash.h | 2 +- source/checksum/CRC.cpp | 32 +++++++++++++++++++++++ tests/CRCTest.cpp | 46 ++++++++++++++++++++++++++++++++++ 6 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 include/aws/crt/checksum/CRC.h create mode 100644 source/checksum/CRC.cpp create mode 100644 tests/CRCTest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fb54a14e0..1cab5f4f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,10 @@ file(GLOB AWS_CRT_AUTH_HEADERS "include/aws/crt/auth/*.h" ) +file(GLOB AWS_CRT_CHECKSUM_HEADERS + "include/aws/crt/checksum/*.h" +) + file(GLOB AWS_CRT_CRYPTO_HEADERS "include/aws/crt/crypto/*.h" ) @@ -178,6 +182,7 @@ file(GLOB AWS_CRT_CBOR_HEADERS file(GLOB AWS_CRT_PUBLIC_HEADERS ${AWS_CRT_HEADERS} ${AWS_CRT_AUTH_HEADERS} + ${AWS_CRT_CHECKSUM_HEADERS} ${AWS_CRT_CRYPTO_HEADERS} ${AWS_CRT_IO_HEADERS} ${AWS_CRT_IOT_HEADERS} @@ -204,6 +209,10 @@ file(GLOB AWS_CRT_AUTH_SRC "source/auth/*.cpp" ) +file(GLOB AWS_CRT_CHECKSUM_SRC + "source/checksum/*.cpp" +) + file(GLOB AWS_CRT_CRYPTO_SRC "source/crypto/*.cpp" ) @@ -235,6 +244,7 @@ file(GLOB AWS_CRT_CBOR_SRC file(GLOB AWS_CRT_CPP_SRC ${AWS_CRT_SRC} ${AWS_CRT_AUTH_SRC} + ${AWS_CRT_CHECKSUM_SRC} ${AWS_CRT_CRYPTO_SRC} ${AWS_CRT_IO_SRC} ${AWS_CRT_IOT_SRC} @@ -248,6 +258,7 @@ if(WIN32) if(MSVC) source_group("Header Files\\aws\\crt" FILES ${AWS_CRT_HEADERS}) source_group("Header Files\\aws\\crt\\auth" FILES ${AWS_CRT_AUTH_HEADERS}) + source_group("Header Files\\aws\\crt\\checksum" FILES ${AWS_CRT_CHECKSUM_HEADERS}) source_group("Header Files\\aws\\crt\\crypto" FILES ${AWS_CRT_CRYPTO_HEADERS}) source_group("Header Files\\aws\\crt\\io" FILES ${AWS_CRT_IO_HEADERS}) source_group("Header Files\\aws\\iot" FILES ${AWS_CRT_IOT_HEADERS}) @@ -258,6 +269,7 @@ if(WIN32) source_group("Source Files" FILES ${AWS_CRT_SRC}) source_group("Source Files\\auth" FILES ${AWS_CRT_AUTH_SRC}) + source_group("Source Files\\checksum" FILES ${AWS_CRT_CHECKSUM_SRC}) source_group("Source Files\\crypto" FILES ${AWS_CRT_CRYPTO_SRC}) source_group("Source Files\\io" FILES ${AWS_CRT_IO_SRC}) source_group("Source Files\\iot" FILES ${AWS_CRT_IOT_SRC}) @@ -328,6 +340,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC ${DEP_AWS_LIBS}) install(FILES ${AWS_CRT_HEADERS} DESTINATION "include/aws/crt" COMPONENT Development) install(FILES ${AWS_CRT_AUTH_HEADERS} DESTINATION "include/aws/crt/auth" COMPONENT Development) +install(FILES ${AWS_CRT_CHECKSUM_HEADERS} DESTINATION "include/aws/crt/crypto" COMPONENT Development) install(FILES ${AWS_CRT_CRYPTO_HEADERS} DESTINATION "include/aws/crt/crypto" COMPONENT Development) install(FILES ${AWS_CRT_IO_HEADERS} DESTINATION "include/aws/crt/io" COMPONENT Development) install(FILES ${AWS_CRT_IOT_HEADERS} DESTINATION "include/aws/iot" COMPONENT Development) diff --git a/crt/aws-checksums b/crt/aws-checksums index aac442a2d..ce04ab00b 160000 --- a/crt/aws-checksums +++ b/crt/aws-checksums @@ -1 +1 @@ -Subproject commit aac442a2dbbb5e72d0a3eca8313cf65e7e1cac2f +Subproject commit ce04ab00b3ecc41912f478bfedca39f8e1919d6b diff --git a/include/aws/crt/checksum/CRC.h b/include/aws/crt/checksum/CRC.h new file mode 100644 index 000000000..023d1d21a --- /dev/null +++ b/include/aws/crt/checksum/CRC.h @@ -0,0 +1,39 @@ +#pragma once +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#include +#include + +namespace Aws +{ + namespace Crt + { + namespace Checksum + { + /** + * The entry point function to perform a CRC32 (Ethernet, gzip) computation. + * Selects a suitable implementation based on hardware capabilities. + * Pass previousCRC32 if updating a running checksum. + */ + uint32_t AWS_CRT_CPP_API ComputeCRC32(ByteCursor input, uint32_t previousCRC32 = 0) noexcept; + + /** + * The entry point function to perform a Castagnoli CRC32c (iSCSI) computation. + * Selects a suitable implementation based on hardware capabilities. + * Pass previousCRC32C if updating a running checksum. + */ + uint32_t AWS_CRT_CPP_API ComputeCRC32C(ByteCursor input, uint32_t previousCRC32C = 0) noexcept; + + /** + * The entry point function to perform a CRC64-NVME (a.k.a. CRC64-Rocksoft) computation. + * Selects a suitable implementation based on hardware capabilities. + * Pass previousCRC64NVME if updating a running checksum. + * There are many variants of CRC64 algorithms. This CRC64 variant is bit-reflected (based on + * the non bit-reflected polynomial 0xad93d23594c93659) and inverts the CRC input and output bits. + */ + uint64_t AWS_CRT_CPP_API ComputeCRC64NVME(ByteCursor input, uint64_t previousCRC64NVME = 0) noexcept; + } // namespace Checksum + } // namespace Crt +} // namespace Aws diff --git a/include/aws/crt/crypto/Hash.h b/include/aws/crt/crypto/Hash.h index 98e3e3c93..af8a7c7d2 100644 --- a/include/aws/crt/crypto/Hash.h +++ b/include/aws/crt/crypto/Hash.h @@ -189,7 +189,7 @@ namespace Aws /** * Complete the hash computation and write the final digest to output. - * This cannote be called more than once. + * This cannot be called more than once. * If truncate_to is something other than 0, the output must be truncated to that number of bytes. * Raise an AWS error and return false to indicate failure. */ diff --git a/source/checksum/CRC.cpp b/source/checksum/CRC.cpp new file mode 100644 index 000000000..65ed70e28 --- /dev/null +++ b/source/checksum/CRC.cpp @@ -0,0 +1,32 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#include + +#include + +namespace Aws +{ + namespace Crt + { + namespace Checksum + { + uint32_t ComputeCRC32(ByteCursor input, uint32_t previousCRC32) noexcept + { + return aws_checksums_crc32_ex(input.ptr, input.len, previousCRC32); + } + + uint32_t ComputeCRC32C(ByteCursor input, uint32_t previousCRC32C) noexcept + { + return aws_checksums_crc32c_ex(input.ptr, input.len, previousCRC32C); + } + + uint64_t ComputeCRC64NVME(ByteCursor input, uint64_t previousCRC64NVME) noexcept + { + return aws_checksums_crc64nvme_ex(input.ptr, input.len, previousCRC64NVME); + } + + } // namespace Checksum + } // namespace Crt +} // namespace Aws diff --git a/tests/CRCTest.cpp b/tests/CRCTest.cpp new file mode 100644 index 000000000..464fe4862 --- /dev/null +++ b/tests/CRCTest.cpp @@ -0,0 +1,46 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +#include +#include +#include + +static int s_TestCRC32Piping(struct aws_allocator *allocator, void *) +{ + Aws::Crt::ApiHandle apiHandle(allocator); + uint8_t data[32] = {0}; + + Aws::Crt::ByteCursor dataCur = aws_byte_cursor_from_array(data, sizeof(data)); + + ASSERT_UINT_EQUALS(0x190A55AD, Aws::Crt::Checksum::ComputeCRC32(dataCur)); + + return AWS_OP_SUCCESS; +} +AWS_TEST_CASE(CRC32Piping, s_TestCRC32Piping) + +static int s_TestCRC32CPiping(struct aws_allocator *allocator, void *) +{ + Aws::Crt::ApiHandle apiHandle(allocator); + uint8_t data[32] = {0}; + + Aws::Crt::ByteCursor dataCur = aws_byte_cursor_from_array(data, sizeof(data)); + + ASSERT_UINT_EQUALS(0x8A9136AA, Aws::Crt::Checksum::ComputeCRC32C(dataCur)); + + return AWS_OP_SUCCESS; +} +AWS_TEST_CASE(CRC32CPiping, s_TestCRC32CPiping) + +static int s_TestCRC64NVMEPiping(struct aws_allocator *allocator, void *) +{ + Aws::Crt::ApiHandle apiHandle(allocator); + uint8_t data[32] = {0}; + + Aws::Crt::ByteCursor dataCur = aws_byte_cursor_from_array(data, sizeof(data)); + + ASSERT_UINT_EQUALS(0xCF3473434D4ECF3B, Aws::Crt::Checksum::ComputeCRC64NVME(dataCur)); + + return AWS_OP_SUCCESS; +} +AWS_TEST_CASE(CRC64NVMEPiping, s_TestCRC64NVMEPiping) From 83aacf7ae3a79c1cd1d2e1fe901a8ac9c427a199 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Fri, 13 Sep 2024 14:54:18 -0700 Subject: [PATCH 10/11] AutoTag PR for v0.28.3 (#663) Co-authored-by: GitHub Actions --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a37255a85..b79f04f44 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.28.2 +0.28.3 From 188cff7c288e34ed076ea7cd637615a0b74bafc8 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 8 Oct 2024 11:59:31 -0700 Subject: [PATCH 11/11] Prebuild aws-lc (#648) --- CMakeLists.txt | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cab5f4f4..048f1eec9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,35 +84,36 @@ if(BUILD_DEPS) if(UNIX AND NOT APPLE AND NOT BYO_CRYPTO) if(NOT USE_OPENSSL) - set(DISABLE_PERL ON CACHE BOOL "Disable Perl for AWS-LC.") - set(DISABLE_GO ON CACHE BOOL "Disable Go for AWS-LC.") - set(BUILD_LIBSSL OFF CACHE BOOL "Build libssl for AWS-LC.") + include(AwsPrebuildDependency) - # temporarily disable certain warnings as errors for the aws-lc build - set(OLD_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set(AWSLC_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + # temporarily disable certain warnings as errors for the aws-lc build if(NOT MSVC) check_c_compiler_flag(-Wno-stringop-overflow HAS_WNO_STRINGOP_OVERFLOW) if(HAS_WNO_STRINGOP_OVERFLOW) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-stringop-overflow") + set(AWSLC_CMAKE_C_FLAGS "${AWSLC_CMAKE_C_FLAGS} -Wno-stringop-overflow") endif() check_c_compiler_flag(-Wno-array-parameter HAS_WNO_ARRAY_PARAMETER) if(HAS_WNO_ARRAY_PARAMETER) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-array-parameter") + set(AWSLC_CMAKE_C_FLAGS "${AWSLC_CMAKE_C_FLAGS} -Wno-array-parameter") endif() endif() - add_subdirectory(crt/aws-lc) - - # restore previous build flags - set(CMAKE_C_FLAGS "${OLD_CMAKE_C_FLAGS}") - - set(SEARCH_LIBCRYPTO OFF CACHE BOOL "Let S2N use libcrypto from AWS-LC.") - else() - set(SEARCH_LIBCRYPTO ON CACHE BOOL "Let S2N search libcrypto in the system.") + # s2n-tls uses libcrypto during its configuration, so we need to prebuild aws-lc. + prebuild_dependency( + DEPENDENCY_NAME AWSLC + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/crt/aws-lc + CMAKE_ARGUMENTS + -DDISABLE_GO=ON + -DDISABLE_PERL=ON + -DBUILD_LIBSSL=OFF + -DBUILD_TESTING=OFF + -DCMAKE_C_FLAGS=${AWSLC_CMAKE_C_FLAGS} + ) endif() set(UNSAFE_TREAT_WARNINGS_AS_ERRORS OFF CACHE BOOL "Disable warnings-as-errors when building S2N")