From 120398bc40a80302681f1985b7caf30ef917e4f7 Mon Sep 17 00:00:00 2001 From: Fabian Albert Date: Thu, 15 Aug 2024 10:54:19 +0200 Subject: [PATCH] CI: examples in amalgamation build --- configure.py | 2 ++ src/examples/amalgamation_header.cpp | 13 +++++++++++++ src/scripts/ci/setup_gh_actions.sh | 4 ++-- src/scripts/ci/setup_gh_actions_after_vcvars.ps1 | 4 +++- src/scripts/ci_build.py | 6 +++--- 5 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 src/examples/amalgamation_header.cpp diff --git a/configure.py b/configure.py index 8c1da8f781..be0dc23a5f 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 0000000000..0fd1c2a605 --- /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/scripts/ci/setup_gh_actions.sh b/src/scripts/ci/setup_gh_actions.sh index 1dd4b8b7bb..089bf36071 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 06dd072ab0..290db6340e 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 57376125d9..b51dc24c7c 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']: