diff --git a/configure.py b/configure.py index 8c1da8f781d..be0dc23a5f2 100755 --- a/configure.py +++ b/configure.py @@ -3440,6 +3440,8 @@ def link_headers(headers, visibility, directory): build_paths.lib_sources = amalg_cpp_files template_vars['generated_files'] = ' '.join(amalg_cpp_files + amalg_headers) + link_headers(amalg_headers, 'public', build_paths.public_include_dir) + # Inserting an amalgamation generated using DLL visibility flags into a # binary project will either cause errors (on Windows) or unnecessary overhead. # Provide a hint diff --git a/src/examples/amalgamation_header.cpp b/src/examples/amalgamation_header.cpp new file mode 100644 index 00000000000..0fd1c2a6052 --- /dev/null +++ b/src/examples/amalgamation_header.cpp @@ -0,0 +1,13 @@ +#include +#if __has_include() + #include +#else + // if the amalgamation header isn't available, you have to IWYU. + #include +#endif + +int main() { + std::cout << "With an amalgamation build you can include everything using the botan_all header.\n"; + std::cout << "That's " << Botan::hex_encode(std::vector{0xC0, 0x01}) << "\n"; + return 0; +} diff --git a/src/examples/hybrid_key_encapsulation.cpp b/src/examples/hybrid_key_encapsulation.cpp index 5b459d416ca..39d3a17672c 100644 --- a/src/examples/hybrid_key_encapsulation.cpp +++ b/src/examples/hybrid_key_encapsulation.cpp @@ -101,6 +101,9 @@ class Hybrid_PublicKey : public virtual Botan::Public_Key { std::unique_ptr m_kem_pk; }; +BOTAN_DIAGNOSTIC_PUSH +BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE + /** * This is the private key class for the custom public-key algorithm. */ @@ -147,6 +150,8 @@ class Hybrid_PrivateKey : public virtual Botan::Private_Key, std::unique_ptr m_kem_sk; }; +BOTAN_DIAGNOSTIC_POP + namespace { /** diff --git a/src/examples/tls_ssl_key_log_file.cpp b/src/examples/tls_ssl_key_log_file.cpp index b47e8bd4312..b81589cd39f 100644 --- a/src/examples/tls_ssl_key_log_file.cpp +++ b/src/examples/tls_ssl_key_log_file.cpp @@ -23,6 +23,9 @@ #include #include #endif +#if defined(BOTAN_TARGET_OS_HAS_POSIX1) + #include +#endif namespace { @@ -142,6 +145,8 @@ class DtlsConnection : public Botan::TLS::Callbacks { remote_addr.sin_family = AF_INET; inet_aton(r_addr.c_str(), &remote_addr.sin_addr); remote_addr.sin_port = htons(r_port); +#else + BOTAN_UNUSED(r_addr, r_port); #endif auto tls_callbacks_proxy = std::make_shared(*this); auto rng = std::make_shared(); @@ -169,6 +174,7 @@ class DtlsConnection : public Botan::TLS::Callbacks { #if defined(BOTAN_TARGET_OS_HAS_SOCKETS) sendto(fd, data.data(), data.size(), 0, reinterpret_cast(&remote_addr), sizeof(sockaddr_in)); #else + BOTAN_UNUSED(data); // send data to the other side // ... #endif @@ -201,7 +207,9 @@ class DtlsConnection : public Botan::TLS::Callbacks { if(fd) { #if defined(BOTAN_TARGET_OS_HAS_SOCKETS) shutdown(fd, SHUT_RDWR); + #if defined(BOTAN_TARGET_OS_HAS_POSIX1) ::close(fd); + #endif #endif } } diff --git a/src/examples/tls_stream_coroutine_client.cpp b/src/examples/tls_stream_coroutine_client.cpp index 8f4f9fcc308..b1ebfadf2e7 100644 --- a/src/examples/tls_stream_coroutine_client.cpp +++ b/src/examples/tls_stream_coroutine_client.cpp @@ -7,6 +7,10 @@ // in clang 14 and newer. Older versions of Boost might work with other // compilers, though. #if defined(BOTAN_FOUND_COMPATIBLE_BOOST_ASIO_VERSION) && BOOST_VERSION >= 108100 + #define BOOST_VERSION_IS_COMPATIBLE +#endif + +#if defined(BOOST_VERSION_IS_COMPATIBLE) && defined(BOTAN_HAS_HAS_DEFAULT_TLS_CONTEXT) #include #include @@ -106,8 +110,13 @@ int main(int argc, char* argv[]) { #else int main() { + #if !defined(BOOST_VERSION_IS_COMPATIBLE) std::cout << "Your boost version is too old, sorry.\n" << "Or did you compile Botan without --with-boost?\n"; + #endif + #if !defined(BOTAN_HAS_HAS_DEFAULT_TLS_CONTEXT) + std::cout << "Your system needs an auto seeded RNG and a certificate store.\n"; + #endif return 1; } diff --git a/src/lib/tls/asio/asio_stream.h b/src/lib/tls/asio/asio_stream.h index 3b97b737c76..0bb11477ad2 100644 --- a/src/lib/tls/asio/asio_stream.h +++ b/src/lib/tls/asio/asio_stream.h @@ -214,7 +214,7 @@ class Stream { std::shared_ptr callbacks = std::make_shared()) : Stream(std::move(context), std::move(callbacks), std::forward(arg)) {} - #if defined(BOTAN_HAS_AUTO_SEEDING_RNG) + #if defined(BOTAN_HAS_HAS_DEFAULT_TLS_CONTEXT) /** * @brief Conveniently construct a new Stream with default settings * diff --git a/src/scripts/ci/setup_gh_actions.sh b/src/scripts/ci/setup_gh_actions.sh index 1dd4b8b7bb3..089bf360710 100755 --- a/src/scripts/ci/setup_gh_actions.sh +++ b/src/scripts/ci/setup_gh_actions.sh @@ -77,7 +77,7 @@ if type -p "apt-get"; then sudo apt-get -qq install libboost-dev "${tpm2_specific_packages[@]}" echo "BOTAN_TPM2_ENABLED=${ci_support_of_tpm2}" >> "$GITHUB_ENV" - elif [ "$TARGET" = "examples" ] || [ "$TARGET" = "tlsanvil" ] || [ "$TARGET" = "clang-tidy" ] ; then + elif [ "$TARGET" = "examples" ] || [ "$TARGET" = "amalgamation" ] || [ "$TARGET" = "tlsanvil" ] || [ "$TARGET" = "clang-tidy" ] ; then sudo apt-get -qq install libboost-dev libtss2-dev build_and_install_jitterentropy @@ -186,7 +186,7 @@ else export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install ccache - if [ "$TARGET" = "shared" ]; then + if [ "$TARGET" = "shared" ] || [ "$TARGET" = "amalgamation" ] ; then brew install boost # On Apple Silicon we need to specify the include directory diff --git a/src/scripts/ci/setup_gh_actions_after_vcvars.ps1 b/src/scripts/ci/setup_gh_actions_after_vcvars.ps1 index 06dd072ab0d..290db6340ea 100644 --- a/src/scripts/ci/setup_gh_actions_after_vcvars.ps1 +++ b/src/scripts/ci/setup_gh_actions_after_vcvars.ps1 @@ -6,7 +6,9 @@ # # Botan is released under the Simplified BSD License (see license.txt) -if ($args[0] -in @('shared')) { +$targets_with_boost = @("shared", "amalgamation") + +if ($targets_with_boost -contains $args[0]) { nuget install -NonInteractive -OutputDirectory $env:DEPENDENCIES_LOCATION -Version 1.79.0 boost $boostincdir = Join-Path -Path $env:DEPENDENCIES_LOCATION -ChildPath "boost.1.79.0/lib/native/include" diff --git a/src/scripts/ci_build.py b/src/scripts/ci_build.py index 57376125d99..b51dc24c7c9 100755 --- a/src/scripts/ci_build.py +++ b/src/scripts/ci_build.py @@ -121,7 +121,7 @@ def build_targets(target, target_os): yield 'bogo_shim' if target in ['sanitizer'] and target_os not in ['windows']: yield 'bogo_shim' - if target in ['examples']: + if target in ['examples', 'amalgamation']: yield 'examples' if target in ['valgrind', 'valgrind-full']: yield 'ct_selftest' @@ -425,7 +425,7 @@ def sanitize_kv(some_string): flags += ['--with-commoncrypto'] def add_boost_support(target, target_os): - if target in ['coverage', 'shared']: + if target in ['coverage', 'shared', 'amalgamation']: return True if target == 'sanitizer' and target_os == 'linux': @@ -803,7 +803,7 @@ def main(args=None): if target in ['coverage', 'fuzzers']: make_targets += ['fuzzer_corpus_zip', 'fuzzers'] - if target in ['examples']: + if target in ['examples', 'amalgamation']: make_targets += ['examples'] if target in ['valgrind', 'valgrind-full']: