From 1efb112a77507c630133324a228748bd679227ce Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 12 Dec 2024 11:49:33 -0700 Subject: [PATCH 01/16] Compat with older {fmt} versions --- src/amongoc/uri.cpp | 20 +++++++++++--------- src/amongoc/wire/proto.cpp | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/amongoc/uri.cpp b/src/amongoc/uri.cpp index 1520d4d..c6ec6ee 100644 --- a/src/amongoc/uri.cpp +++ b/src/amongoc/uri.cpp @@ -146,8 +146,10 @@ result connection_uri::parse(std::string_view auto res = std::from_chars(sv.data(), sv.data() + sv.size(), ret); if (res.ec != std::errc{}) { warn.fire(defer_convert([&] { - return uri_warning_event( - format(alloc, "URI parameter {}: Invalid integer value '{}'", qp.key, sv)); + return uri_warning_event(format(alloc, + "URI parameter {}: Invalid integer value '{}'", + std::string_view(qp.key), + std::string_view(sv))); })); return {}; } @@ -174,8 +176,8 @@ result connection_uri::parse(std::string_view return uri_warning_event( format(alloc, "URI parameter {}: Invalid boolean constant “{}”", - qp.key, - val)); + std::string_view(qp.key), + std::string_view(val))); })); } return {}; // nullopt @@ -203,7 +205,7 @@ result connection_uri::parse(std::string_view format(alloc, "URI parameter “{}”: Value {} is outside the supported range " "(min: {}, max: {})", - qp.key, + std::string_view(qp.key), ival, min, max)); @@ -218,12 +220,12 @@ result connection_uri::parse(std::string_view return [&](T value) { if (out.has_value()) { warn.fire(defer_convert([&] { - if constexpr (fmt::formattable) { + if constexpr (fmt::is_formattable::value) { return uri_warning_event( format(alloc, "URI parameter “{}” was specified multiple " "times (previously “{}”, now “{}”)", - qp.key, + std::string_view(qp.key), *out, value)); } else { @@ -231,7 +233,7 @@ result connection_uri::parse(std::string_view format(alloc, "URI parameter “{}” was specified multiple " "times", - qp.key)); + std::string_view(qp.key))); } })); } @@ -310,7 +312,7 @@ result connection_uri::parse(std::string_view // Unknown parameter name warn.fire(defer_convert([&] -> uri_warning_event { return uri_warning_event{ - amongoc::format(alloc, "Unknown URI parameter “{}”", qp.key)}; + amongoc::format(alloc, "Unknown URI parameter “{}”", std::string_view(qp.key))}; })); } if (param_parse_status.is_error()) { diff --git a/src/amongoc/wire/proto.cpp b/src/amongoc/wire/proto.cpp index 87eca68..b3538e1 100644 --- a/src/amongoc/wire/proto.cpp +++ b/src/amongoc/wire/proto.cpp @@ -7,7 +7,7 @@ #include -#include +#include mlib_diagnostic_push(); mlib_gcc_warning_disable("-Wstringop-overflow"); From fce37ed2bb091dc4d997370d83ac9c837e0bfb38 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 12 Dec 2024 11:49:55 -0700 Subject: [PATCH 02/16] Disable message tracing by default --- src/amongoc/wire/proto.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/amongoc/wire/proto.hpp b/src/amongoc/wire/proto.hpp index ecbfb5d..0b939cd 100644 --- a/src/amongoc/wire/proto.hpp +++ b/src/amongoc/wire/proto.hpp @@ -31,7 +31,7 @@ namespace amongoc::wire { namespace trace { // Global toggle for enabling message tracing -constexpr bool enabled = true; +constexpr bool enabled = false; // Print information for a message header void message_header(std::string_view prefix, From fd0c310ef3362f68a2fe18fe7407b5a9ec0949d6 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 13 Dec 2024 11:33:08 -0700 Subject: [PATCH 03/16] Set certain deps to download using FetchContent --- CMakeLists.txt | 23 ++++++++--- tools/DeclareFetchContentDeps.cmake | 60 +++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 tools/DeclareFetchContentDeps.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fefb482..8774b97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,18 +10,24 @@ if(AMONGOC_USE_PMM) pmm(VCPKG REVISION 2024.08.23) endif() -find_package(asio CONFIG REQUIRED) -find_package(neo-fun CONFIG REQUIRED) +# Set up `find_package()` to trigger FetchContent for certain deps +include(DeclareFetchContentDeps) + +find_package(asio 1.25.0 REQUIRED) find_package(Boost CONFIG REQUIRED URL Container) find_package(fmt CONFIG REQUIRED) +find_package(neo-fun REQUIRED) find_package(OpenSSL REQUIRED) - find_package(Threads REQUIRED) # Enable testing with CTest # Note: We respect the BUILD_TESTING option from CTest.cmake include(CTest) +if(BUILD_TESTING) + find_package(Catch2 CONFIG REQUIRED) +endif() + # Support modules include(CMakePackageConfigHelpers) @@ -131,12 +137,17 @@ target_link_libraries(amongoc ) if(BUILD_TESTING) # Add Catch integrations - find_package(Catch2 CONFIG REQUIRED) include(Catch) # Add tests add_executable(amongoc-test ${test_sources}) - target_link_libraries(amongoc-test PRIVATE amongoc Catch2::Catch2) + target_link_libraries(amongoc-test PRIVATE + amongoc::amongoc + Catch2::Catch2 + $ + $ + Boost::container + ) target_include_directories(amongoc-test PRIVATE src) catch_discover_tests(amongoc-test DISCOVERY_MODE PRE_TEST PROPERTIES SKIP_REGULAR_EXPRESSION ":[0-9]+: SKIPPED:" @@ -163,7 +174,7 @@ if(BUILD_TESTING) # tests will use these same packages when importing amongoc. # TODO: Add test cases that don't share dependencies with the parent build set(passthru_args - PASSTHRU_VARS neo-fun_DIR asio_DIR fmt_DIR + PASSTHRU_VARS fmt_DIR # Boost has a lot of variables that need to be forwarded: PASSTHRU_VARS_REGEX "[bB]oost.*(_DIR|_PATH)" ) diff --git a/tools/DeclareFetchContentDeps.cmake b/tools/DeclareFetchContentDeps.cmake new file mode 100644 index 0000000..59b816e --- /dev/null +++ b/tools/DeclareFetchContentDeps.cmake @@ -0,0 +1,60 @@ +#[[ + + This file announces some dependencies to FetchContent in a way that a + subsequent `find_package` will invoke `FetchContent_MakeAvailable` to + automatically download and include the packages as part of the build. + + This is only used for packages that do not need to be transitively imported + into dependees. Other dependencies should be installed by the system + packager. + + Inclusion of this file has no immediate effect. This will only be triggered + by appropriate calls to `find_package` + +]] +include_guard() +include(FetchContent) + +FetchContent_Declare( + neo-fun + GIT_REPOSITORY https://github.com/vector-of-bool/neo-fun.git + GIT_TAG 0.14.1 + OVERRIDE_FIND_PACKAGE +) +file(WRITE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/neo-funExtra.cmake" [=[ + cmake_path(SET __neo_fun_src_dir NORMALIZE "${neo-fun_SOURCE_DIR}/src") + file(GLOB_RECURSE __nf_sources ${__neo_fun_src_dir}/*.c*) + file(GLOB_RECURSE __nf_headers ${__neo_fun_src_dir}/*.h*) + file(GLOB_RECURSE __nf_tests ${__neo_fun_src_dir}/*.test.c*) + list(REMOVE_ITEM __nf_sources ~~~ ${__nf_tests}) + + add_library(neo-fun STATIC EXCLUDE_FROM_ALL) + add_library(neo::fun ALIAS neo-fun) + target_sources(neo-fun + PRIVATE ${__nf_sources} + PUBLIC FILE_SET HEADERS BASE_DIRS ${__neo_fun_src_dir} FILES ${__nf_headers} + ) + target_compile_features(neo-fun PUBLIC cxx_std_20) +]=]) + +FetchContent_Declare( + asio + GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git + GIT_TAG asio-1-32-0 + OVERRIDE_FIND_PACKAGE +) +file(WRITE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/asioExtra.cmake" [[ + set(__asio_src_dir "${asio_SOURCE_DIR}/asio/include") + cmake_path(NORMAL_PATH __asio_src_dir) + add_library(asio INTERFACE EXCLUDE_FROM_ALL) + add_library(asio::asio ALIAS asio) + # Add the header root as SYSTEM, to inhibit warnings on GNU compilers + target_include_directories(asio SYSTEM INTERFACE ${__asio_src_dir}) +]]) + +FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.7.1 + OVERRIDE_FIND_PACKAGE +) From 27f8f5839f52bb2a4b460940d21236da3a5aed2d Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 13 Dec 2024 11:33:32 -0700 Subject: [PATCH 04/16] Stray wrong #include --- src/amongoc/format.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/amongoc/format.hpp b/src/amongoc/format.hpp index 8ad1b64..8ba2b41 100644 --- a/src/amongoc/format.hpp +++ b/src/amongoc/format.hpp @@ -4,7 +4,6 @@ #include -#include #include #include From 60baaf199834b73bafd05aaaf263766df61c9cf1 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Mon, 16 Dec 2024 13:19:28 -0700 Subject: [PATCH 05/16] Update details on build dependencies --- docs/ref/building.rst | 128 +++++++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 52 deletions(-) diff --git a/docs/ref/building.rst b/docs/ref/building.rst index 5f1be89..b56ddc7 100644 --- a/docs/ref/building.rst +++ b/docs/ref/building.rst @@ -14,6 +14,73 @@ Building |amongoc| is supported with the following build tools: .. _CMake: https://cmake.org/ .. _Earthly: https://earthly.dev/ +.. _building.cmake-deps: + +Third-Party Dependencies +######################## + +When configuring and building |amongoc| with CMake, the configuration script +will attempt to automatically obtain build-time dependencies using vcpkg_. This +behavior can be disabled by setting :cmake:variable:`AMONGOC_USE_PMM` to +``OFF``. Relying on vcpkg_ will attempt to build the third-party dependencies +during project configuration, which may require additional configure-time +dependencies. + +The following external libraries are required when **building** |amongoc|. If +not relying vcpkg_, then they will need to be installed and available before +configuring the project: + +- OpenSSL +- Boost.URL and Boost.Container +- `{fmt}`_ +- **If using vcpkg to install dependencies** (the default), then you will also + need to have Tar, cURL, Perl, Zip/Unzip, pkg-config, Make, and Bash. On Linux, + you will also need the linux development headers. + +The following packages are downloaded using CMake's FetchContent, and need not +be manually installed: + +- Catch2_ - Only required for testing and only imported if + :cmake:variable:`BUILD_TESTING` is enabled. +- Asio_ - Used for asynchronous I/O (Build-time only) (Note: Not ``Boost.Asio``!) +- neo-fun_ (Build-time only) + +.. _Catch2: https://github.com/catchorg/Catch2 +.. _Asio: https://think-async.com/Asio/ +.. _{fmt}: https://fmt.dev/ +.. _neo-fun: https://github.com/vector-of-bool/neo-fun + +The following table details the dependencies of the imported +``amongoc::amongoc`` target, along with the common Linux packages that contain +them: + +.. list-table:: + :header-rows: 1 + :widths: 1, 2, 2, 2 + + - - Targets + - RedHat + - Debian + - Alpine + + - - ``fmt::fmt`` + - ``fmt-devel`` (may require EPEL) + - ``libfmt-dev`` + - ``fmt-dev`` + - - ``Boost::url`` + ``Boost::container`` + - ``boost-devel`` + - ``libboost-{url,container}-dev`` (may require a version infix) + - ``boost-dev`` + - - ``OpenSSL::SSL`` + - ``openssl-devel`` + - ``libssl-dev`` + - ``openssl-dev`` + - - ``Threads::Threads`` + - CMake built-in + - CMake built-in + - CMake built-in + + Build Configuration ################### @@ -65,12 +132,13 @@ The following CMake_ configuration options are supported: AMONGOC_USE_PMM Toggle usage of PMM_ to automatically download and import dependencies at - configure-time. + configure-time using vcpkg_. .. _PMM: https://github.com/vector-of-bool/pmm .. _vcpkg: https://vcpkg.io/ - :default: ``ON`` + :default: ``ON`` if configuring |amongoc| as the top-level project, ``OFF`` + otherwise (e.g. when added as a sub-project) If this toggle is enabled, then vcpkg_ will be executed during CMake configuration to download and build the dependencies required by |amongoc|. @@ -81,41 +149,13 @@ The following CMake_ configuration options are supported: :external:cmake:command:`find_package `. -.. _building.cmake-deps: - -Third-Party Dependencies -######################## - -.. sidebar:: - - .. note:: - - At time of writing, neo-fun_ does not ship an installable CMake package and - is installed using a custom vcpkg_ port in ``etc/vcpkg-ports/neo-fun``. - -The following external libraries are required by |amongoc|: - -- OpenSSL -- Boost.URL_ -- `{fmt}`_ -- Catch2_ - Only required for testing and only imported if - :cmake:variable:`BUILD_TESTING` is enabled. -- Asio_ - Used for asynchronous I/O (Build-time only) (Note: Not ``Boost.Asio``!) -- neo-fun_ (Build-time only) - -.. _Catch2: https://github.com/catchorg/Catch2 -.. _Asio: https://think-async.com/Asio/ -.. _Boost.URL: https://www.boost.io/libraries/url/ -.. _{fmt}: https://fmt.dev/ -.. _neo-fun: https://github.com/vector-of-bool/neo-fun - - .. _building.earthly: Building with Earthly ##################### Earthly_ is a container-based build automation tool. |amongoc| ships with an +Earthfile that eases building by using containerization. .. file:: Earthfile @@ -144,15 +184,6 @@ Earthly_ is a container-based build automation tool. |amongoc| ships with an archive, a ``.zip`` archive, and a self-extracting shell script ``.sh``. The ``/install`` artifact contains an install tree from the build. - .. earthly-target:: +build-multi - - Builds all of `+build-alpine`, `+build-debian`, and `+build-rl` at once. - - .. earthly-artifact:: +build-multi/ - - The root artifact directory contains all artifacts from all other build - targets. - Importing in CMake ################## @@ -179,13 +210,15 @@ can be linked into an application:: add_executbale(my-program main.c) target_link_libraries(my-program PRIVATE amongoc::amongoc) -Dependency Imports -****************** - By default, the |amongoc| CMake package will attempt to import dependencies using :cmake:command:`find_dependency `. This import can be disabled by changing :cmake:variable:`AMONGOC_FIND_DEPENDENCIES`. +**If you build** |amongoc| using vcpkg_ (the default) it is highly recommended +to use vcpkg in your own project to install |amongoc|'s dependencies, as it is +not guaranteed that the packages provided elsewhere will be compatible with the +packages that were used in the |amongoc| build. + .. cmake:variable:: AMONGOC_FIND_DEPENDENCIES :default: ``ON`` @@ -200,12 +233,3 @@ can be disabled by changing :cmake:variable:`AMONGOC_FIND_DEPENDENCIES`. during import. If disabled, then |amongoc| will assume that the necessary imported targets will be defined elsewhere by the importing package. - The following imported targets are used by the imported ``amongoc::amongoc`` - target: - - - ``fmt::fmt`` - - ``Boost::url`` - - ``Boost::container`` - - ``OpenSSL::SSL`` - - ``Threads::Threads`` (from the - :cmake:module:`FindThreads ` module) From 105abdc64e1e02598490396f500d041087bd9e10 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Mon, 16 Dec 2024 13:35:38 -0700 Subject: [PATCH 06/16] Note the redhat issue. Add the fedora target --- docs/ref/building.rst | 53 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/docs/ref/building.rst b/docs/ref/building.rst index b56ddc7..81681c8 100644 --- a/docs/ref/building.rst +++ b/docs/ref/building.rst @@ -5,16 +5,19 @@ Configuring, Building, & Using .. default-domain:: std .. default-role:: any -Building |amongoc| is supported with the following build tools: +Building |amongoc| requires a C++20 compiler. The following tools are known to +work: - CMake_ 3.25 or newer -- GCC ≥12.0 **or** Clang ≥17.0 +- GCC ≥12.0\ [#fn-redhat-issue]_ **or** Clang ≥17.0 - Earthly_ 0.8 or newer (for :ref:`building with Earthly `) +Building on Windows or with MSVC is not currently supported. + .. _CMake: https://cmake.org/ .. _Earthly: https://earthly.dev/ -.. _building.cmake-deps: +.. _building.deps: Third-Party Dependencies ######################## @@ -144,9 +147,8 @@ The following CMake_ configuration options are supported: configuration to download and build the dependencies required by |amongoc|. If you want to manage dependencies yourself, disable this toggle. You will - need to ensure that the - :ref:`configure-time dependencies ` are available to - :external:cmake:command:`find_package `. + need to ensure that the :ref:`configure-time dependencies ` are + available to :external:cmake:command:`find_package `. .. _building.earthly: @@ -166,14 +168,15 @@ Earthfile that eases building by using containerization. .. earthly-target:: +build-alpine +build-debian + +build-fedora +build-rl - Build targets that build for Alpine Linux (with libmusl), Debian, and - RockyLinux (for RedHat-compatible binaries). + Build targets that build for Alpine Linux (with libmusl), Debian, Fedora, + and RockyLinux (for RedHat-compatible binaries). - The Alpine and Debian build uses the system's default toolchain. The - RockyLinux build uses the RedHat devtoolset to obtain an up-to-date compiler - for producing RedHat-compatible binaries. + The Alpine, Fedora, and Debian build uses the system's default toolchain. + The RockyLinux build uses the RedHat devtoolset\ [#fn-redhat-issue]_ to + obtain an up-to-date compiler for producing RedHat-compatible binaries. .. earthly-artifact:: +build-xyz/pkg @@ -185,6 +188,27 @@ Earthfile that eases building by using containerization. The ``/install`` artifact contains an install tree from the build. + .. rubric:: Example + + To build and obtain a package for Debian-compatible systems, the following + command can be used to obtain the packages for the `+build-debian` target: + + .. code-block:: console + + $ earthly -a +build-debian/pkg deb-pkg + ## [Earthly output] ## + $ ls deb-pkg + amongoc-0.1.0-linux-x86_64.sh* + amongoc-0.1.0-linux-x86_64.tar.gz + amongoc-0.1.0-linux-x86_64.zip + + The resuling ``.sh`` script can be used to install the built library and + headers. + + The same command can work for the `+build-alpine`, `+build-fedora`, and + `+build-rl` targets. + + Importing in CMake ################## @@ -233,3 +257,10 @@ packages that were used in the |amongoc| build. during import. If disabled, then |amongoc| will assume that the necessary imported targets will be defined elsewhere by the importing package. + +.. rubric:: Footnotes + +.. [#fn-redhat-issue] + + There is a known issue with the RedHat dev toolset that result in certain + internal symbols being incorrectly discarded and producing link-time errors. From c6a07e8824bf766eacaf64588f96ecb0f336abd6 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Mon, 16 Dec 2024 17:20:06 -0700 Subject: [PATCH 07/16] Add more Earthfile targets, remove some vcpkg deps --- Earthfile | 120 +++++++++++++++++++++++++++++++++++++++-------------- vcpkg.json | 8 ---- 2 files changed, 88 insertions(+), 40 deletions(-) diff --git a/Earthfile b/Earthfile index 1f8e90c..10553fa 100644 --- a/Earthfile +++ b/Earthfile @@ -2,23 +2,23 @@ VERSION 0.8 build-alpine: FROM alpine:3.20 - # Install build deps. Some deps are for vcpkg bootstrapping - RUN apk add build-base git cmake gcc g++ ninja make curl zip unzip tar \ - pkgconfig linux-headers ccache python3 perl bash - DO +BOOTSTRAP_BUILD_INSTALL_EXPORT + DO --pass-args +BOOTSTRAP_BUILD_INSTALL_EXPORT \ + --build_deps "build-base git cmake gcc g++ ninja make ccache python3" \ + --vcpkg_bs_deps "pkgconfig linux-headers perl bash tar zip unzip curl" \ + --third_deps "fmt-dev boost-dev openssl-dev" build-debian: FROM debian:12 - RUN apt-get update && \ - apt-get -y install build-essential cmake git curl zip unzip tar ninja-build \ - pkg-config python3 ccache - # Spec test generation requires a Python newer than what is on Debian 12 - DO +BOOTSTRAP_BUILD_INSTALL_EXPORT --BUILD_SPEC_TESTS=FALSE + DO --pass-args +BOOTSTRAP_BUILD_INSTALL_EXPORT \ + # Spec test generation requires a Python newer than what is on Debian 12 + --BUILD_SPEC_TESTS=FALSE \ + --build_deps "build-essential cmake git ninja-build python3 ccache" \ + --vcpkg_bs_deps "perl pkg-config linux-libc-dev curl zip unzip" \ + --third_deps "libfmt-dev libboost-url1.81-dev libboost-container1.81-dev libssl-dev" build-rl: FROM rockylinux:8 - RUN dnf -y install zip unzip git gcc-toolset-12 python3.12 epel-release && \ - dnf -y install ccache + RUN dnf -y install epel-release unzip LET cmake_url = "https://github.com/Kitware/CMake/releases/download/v3.30.3/cmake-3.30.3-linux-x86_64.sh" RUN curl "$cmake_url" -Lo cmake.sh && \ sh cmake.sh --exclude-subdir --prefix=/usr/local/ --skip-license @@ -26,15 +26,42 @@ build-rl: RUN curl -L "$ninja_url" -o ninja.zip && \ unzip ninja.zip -d /usr/local/bin/ CACHE ~/.ccache # Epel Ccache still uses the old cache location - DO +BOOTSTRAP_BUILD_INSTALL_EXPORT --launcher "scl run gcc-toolset-12 --" + DO --pass-args +BOOTSTRAP_BUILD_INSTALL_EXPORT \ + --launcher "scl run gcc-toolset-12 --" \ + --build_deps "gcc-toolset-12 python3.12 ccache" \ + --vcpkg_bs_deps "zip unzip git perl" + +build-fedora: + FROM fedora:41 + DO --pass-args +BOOTSTRAP_BUILD_INSTALL_EXPORT \ + --build_deps "cmake ninja-build git gcc gcc-c++ python3.12 ccache" \ + --vcpkg_bs_deps "zip unzip perl" \ + --third_deps "boost-devel boost-url fmt-devel openssl-devel" build-multi: FROM alpine # COPY +build-rl/ out/rl/ ## XXX: Redhat build is broken: Investigate GCC linker issues COPY +build-debian/ out/debian/ COPY +build-alpine/ out/alpine/ + COPY +build-fedora/ out/fedora/ SAVE ARTIFACT out/* / +matrix: + BUILD +run \ + --target +build-debian --target +build-alpine --target +build-fedora \ + --use_vcpkg=true --use_vcpkg=false \ + --test=false --test=true + +run: + LOCALLY + ARG --required target + BUILD --pass-args $target + +# Miscellaneous system init +INIT: + FUNCTION + COPY --chmod=755 tools/__install /usr/local/bin/__install + BOOTSTRAP_BUILD_INSTALL_EXPORT: FUNCTION # Bootstrap @@ -45,26 +72,47 @@ BOOTSTRAP_BUILD_INSTALL_EXPORT: SAVE ARTIFACT /tmp/pkg/* /pkg/ SAVE ARTIFACT /opt/amongoc/* /install/ -# Warms-up the user-local vcpkg cache of packages based on the packages we install for our build +# Install dependencies, possibly warming up the user-local vcpkg cache if vcpkg is used BOOTSTRAP_DEPS: FUNCTION - ARG launcher - # Required when bootstrapping vcpkg on Alpine: - ENV VCPKG_FORCE_SYSTEM_BINARIES=1 - # Bootstrap dependencies - LET src_tmp=/s-tmp - WORKDIR $src_tmp - COPY --dir vcpkg*.json $src_tmp - COPY tools/pmm.cmake $src_tmp/tools/ - COPY --dir etc/vcpkg-ports $src_tmp/etc/ - RUN printf %s "cmake_minimum_required(VERSION 3.20) - project(tmp) - include(tools/pmm.cmake) - pmm(VCPKG REVISION 2024.08.23) - " > $src_tmp/CMakeLists.txt - # Running CMake now will prepare our dependencies without configuring the rest of the project - CACHE ~/.cache/vcpkg - RUN $launcher cmake -S $src_tmp -B $src_tmp/_build/vcpkg-bootstrapping + DO +INIT + # Dependencies that are required for the build. Always installed + ARG build_deps + RUN __install $build_deps + # Switch behavior based on whether we use vcpkg + ARG use_vcpkg=true + IF ! $use_vcpkg + # No vcpkg. Install system dependencies + ARG third_deps + RUN __install $third_deps + # Install system deps for testing, if needed + ARG test_deps + ARG test=true + IF $test + RUN __install $test_deps + END + ELSE + # vcpkg may have dependencies that need to be installed to bootstrap + ARG vcpkg_bs_deps + RUN __install $vcpkg_bs_deps + # Required when bootstrapping vcpkg on Alpine: + ENV VCPKG_FORCE_SYSTEM_BINARIES=1 + # Bootstrap dependencies + LET src_tmp=/s-tmp + WORKDIR $src_tmp + COPY --dir vcpkg*.json $src_tmp + COPY tools/pmm.cmake $src_tmp/tools/ + COPY --dir etc/vcpkg-ports $src_tmp/etc/ + RUN printf %s "cmake_minimum_required(VERSION 3.20) + project(tmp) + include(tools/pmm.cmake) + pmm(VCPKG REVISION 2024.08.23) + " > $src_tmp/CMakeLists.txt + # Running CMake now will prepare our dependencies without configuring the rest of the project + CACHE ~/.cache/vcpkg + ARG launcher + RUN $launcher cmake -S $src_tmp -B $src_tmp/_build/vcpkg-bootstrapping + END COPY_SRC: FUNCTION @@ -77,14 +125,22 @@ BUILD: ARG launcher DO +COPY_SRC CACHE ~/.cache/ccache - ARG BUILD_TESTING=TRUE + # Toggle testing + ARG test=true + LET __test=$(echo $test | tr [:lower:] [:upper:]) ARG BUILD_SPEC_TESTS=TRUE + # Toggle PMM in the build + ARG use_vcpkg=true + LET __use_vcpkg=$(echo "$use_vcpkg" | tr "[:lower:]" "[:upper:]") + # Configure RUN $launcher cmake -S . -B _build -G "Ninja Multi-Config" \ -D CMAKE_CROSS_CONFIGS="Debug;Release" \ -D CMAKE_INSTALL_PREFIX=$prefix \ - -D BUILD_TESTING=$BUILD_TESTING \ + -D AMONGOC_USE_PMM=$__use_vcpkg \ + -D BUILD_TESTING=$__test \ -D BUILD_SPEC_TESTS=$BUILD_SPEC_TESTS \ -D CMAKE_DEFAULT_CONFIGS=all + # Build RUN $launcher cmake --build _build IF test "$install_prefix" != "" RUN cmake --install _build --prefix="$install_prefix" --config Debug diff --git a/vcpkg.json b/vcpkg.json index d8b5e1a..c6190dc 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -2,17 +2,9 @@ "name": "amongoc", "version": "0.1.0", "dependencies": [ - { - "name": "asio", - "features": [ - "openssl" - ] - }, "boost-container", "boost-url", - "catch2", "fmt", - "neo-fun", "openssl" ] } \ No newline at end of file From bca7fc738d0fd2285becd90d1c7bf3c26dab703f Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Mon, 16 Dec 2024 17:21:26 -0700 Subject: [PATCH 08/16] Remove custom vcpkg port --- etc/vcpkg-ports/neo-fun/CMakeLists.txt | 30 -------------------------- etc/vcpkg-ports/neo-fun/portfile.cmake | 22 ------------------- etc/vcpkg-ports/neo-fun/vcpkg.json | 14 ------------ vcpkg-configuration.json | 12 ----------- 4 files changed, 78 deletions(-) delete mode 100644 etc/vcpkg-ports/neo-fun/CMakeLists.txt delete mode 100644 etc/vcpkg-ports/neo-fun/portfile.cmake delete mode 100644 etc/vcpkg-ports/neo-fun/vcpkg.json delete mode 100644 vcpkg-configuration.json diff --git a/etc/vcpkg-ports/neo-fun/CMakeLists.txt b/etc/vcpkg-ports/neo-fun/CMakeLists.txt deleted file mode 100644 index d20c0fe..0000000 --- a/etc/vcpkg-ports/neo-fun/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -cmake_minimum_required(VERSION 3.12) -project(neo-fun VERSION "@__pkg_version@") - -file(GLOB_RECURSE sources CONFIGURE_DEPENDS src/*.cpp) -file(GLOB_RECURSE tests CONFIGURE_DEPENDS src/*.test.cpp) -file(GLOB_RECURSE headers CONFIGURE_DEPENDS src/*.hpp src/*.h) -list(REMOVE_ITEM sources ${tests}) - -add_library(neo-fun STATIC) -target_sources(neo-fun - PRIVATE ${sources} - PUBLIC FILE_SET HEADERS BASE_DIRS src/ FILES ${headers} -) -target_compile_features(neo-fun PUBLIC cxx_std_20) -set_target_properties( - neo-fun PROPERTIES - DEBUG_POSTFIX -dbg - EXPORT_NAME neo::fun -) -install( - TARGETS neo-fun - EXPORT neo-fun-targets - ARCHIVE DESTINATION lib - FILE_SET HEADERS DESTINATION include -) -install( - EXPORT neo-fun-targets - DESTINATION lib/cmake - FILE neo-funConfig.cmake -) diff --git a/etc/vcpkg-ports/neo-fun/portfile.cmake b/etc/vcpkg-ports/neo-fun/portfile.cmake deleted file mode 100644 index b20726d..0000000 --- a/etc/vcpkg-ports/neo-fun/portfile.cmake +++ /dev/null @@ -1,22 +0,0 @@ -vcpkg_check_linkage(ONLY_STATIC_LIBRARY) - -vcpkg_from_github( - OUT_SOURCE_PATH source_dir - REPO vector-of-bool/neo-fun - REF "${VERSION}" - SHA512 a203fcc3e532c6ce6a4a179392d22c6b454d3164ba73cec04ab3f21ed4c6c74c32ae157a586afa1afff89a8964c35d7ae5515c9b7d15f6350cabf0d993bc5974 - HEAD_REF develop -) - -set(__pkg_version "${VERSION}") - -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" "${source_dir}" @ONLY) - -vcpkg_cmake_configure( - SOURCE_PATH "${source_dir}" -) -vcpkg_cmake_build() -vcpkg_cmake_install() -vcpkg_install_copyright(FILE_LIST LICENSE.txt) -vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake) -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") diff --git a/etc/vcpkg-ports/neo-fun/vcpkg.json b/etc/vcpkg-ports/neo-fun/vcpkg.json deleted file mode 100644 index 96bc07a..0000000 --- a/etc/vcpkg-ports/neo-fun/vcpkg.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "neo-fun", - "version": "0.14.1", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ] -} \ No newline at end of file diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json deleted file mode 100644 index e3fa8a0..0000000 --- a/vcpkg-configuration.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "registries": [ - { - "kind": "artifact", - "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", - "name": "microsoft" - } - ], - "overlay-ports": [ - "etc/vcpkg-ports" - ] -} \ No newline at end of file From fa5a9d4ac982934b94d5971ae6d35056fafde7ef Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Mon, 16 Dec 2024 17:23:18 -0700 Subject: [PATCH 09/16] Add a basic README --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..96f266f --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# `amongoc` - An Asynchronous MongoDB C Client Library + +> [!IMPORTANT] +> This is NOT a supported MongoDB product! +> +> The content of this repository should be considered experimental and subject +> to breaking changes at any time. + + + +This is `amongoc`, a C11 MongoDB asynchronous client library. It implements a +subset of the MongoDB driver APIs. + + +`amongoc` is written in C++20 and requires an up-to-date compiler. The following +are recommended: + +- CMake 3.25 or newer +- GCC ≥12.0 or Clang ≥17.0 +- Earthly 0.8 or newer (for building with Earthly) + +Building on Windows or with MSVC is not currently supported. + +For more information on building, refer to +[the reference documentation][docs-building]. + + +## Links + +- [Documentation Home][docs] + - [Tutorials][docs-learn] + - [Reference: Configuring, Building, and Using][docs-building] + +[docs]: https://mongodb-labs.github.io/mongo-c-driver-async/ +[docs-learn]: https://mongodb-labs.github.io/mongo-c-driver-async/learn/ +[docs-building]: https://mongodb-labs.github.io/mongo-c-driver-async/ref/building/ From 786703429bd1dbaab60639d093cdb80c2bd7b8c2 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Mon, 16 Dec 2024 17:27:57 -0700 Subject: [PATCH 10/16] Fix missing file being copied --- Earthfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Earthfile b/Earthfile index 10553fa..b719dc4 100644 --- a/Earthfile +++ b/Earthfile @@ -102,7 +102,6 @@ BOOTSTRAP_DEPS: WORKDIR $src_tmp COPY --dir vcpkg*.json $src_tmp COPY tools/pmm.cmake $src_tmp/tools/ - COPY --dir etc/vcpkg-ports $src_tmp/etc/ RUN printf %s "cmake_minimum_required(VERSION 3.20) project(tmp) include(tools/pmm.cmake) From ac833549143a28dd388963e3b257a6dfca8fafbc Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 17 Dec 2024 13:29:28 -0700 Subject: [PATCH 11/16] Change FetchContent to use HTTP rather than Git --- tools/DeclareFetchContentDeps.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/DeclareFetchContentDeps.cmake b/tools/DeclareFetchContentDeps.cmake index 59b816e..dc80e82 100644 --- a/tools/DeclareFetchContentDeps.cmake +++ b/tools/DeclareFetchContentDeps.cmake @@ -17,8 +17,8 @@ include(FetchContent) FetchContent_Declare( neo-fun - GIT_REPOSITORY https://github.com/vector-of-bool/neo-fun.git - GIT_TAG 0.14.1 + URL https://github.com/vector-of-bool/neo-fun/archive/refs/tags/0.14.1.tar.gz + URL_HASH SHA256=bff0fbc5244f8e0148f41e9322206e1af217a819b9dae487c691db04e38aac32 OVERRIDE_FIND_PACKAGE ) file(WRITE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/neo-funExtra.cmake" [=[ @@ -39,8 +39,8 @@ file(WRITE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/neo-funExtra.cmake" [=[ FetchContent_Declare( asio - GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git - GIT_TAG asio-1-32-0 + URL https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-32-0.tar.gz + URL_HASH SHA256=f1b94b80eeb00bb63a3c8cef5047d4e409df4d8a3fe502305976965827d95672 OVERRIDE_FIND_PACKAGE ) file(WRITE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/asioExtra.cmake" [[ @@ -54,7 +54,7 @@ file(WRITE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/asioExtra.cmake" [[ FetchContent_Declare( Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v3.7.1 + URL https://github.com/catchorg/Catch2/archive/refs/tags/v3.7.1.tar.gz + URL_HASH SHA256=c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c OVERRIDE_FIND_PACKAGE ) From e40a9eb81082089a3e8549166643cd27f80b179c Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 17 Dec 2024 13:36:09 -0700 Subject: [PATCH 12/16] Link to GitHub in the README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 96f266f..15d14a3 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,12 @@ For more information on building, refer to ## Links +- [GitHub Repository][github] - [Documentation Home][docs] - [Tutorials][docs-learn] - [Reference: Configuring, Building, and Using][docs-building] +[github]: https://github.com/mongodb-labs/mongo-c-driver-async [docs]: https://mongodb-labs.github.io/mongo-c-driver-async/ [docs-learn]: https://mongodb-labs.github.io/mongo-c-driver-async/learn/ [docs-building]: https://mongodb-labs.github.io/mongo-c-driver-async/ref/building/ From 777ebb7b95441356c955201f6ba3679a9b7af1ea Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 17 Dec 2024 14:34:36 -0700 Subject: [PATCH 13/16] Enable GitHub links in the doc pages --- docs/conf.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 1cf6e0d..785db3b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -185,6 +185,15 @@ def generate_sphinx_inventory( # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output html_theme = "sphinx_book_theme" +html_theme_options = { + "path_to_docs": "docs", + "repository_branch": "develop", + "repository_url": "https://github.com/mongodb-labs/mongo-c-driver-async", + "use_edit_page_button": True, + "use_issues_button": True, + "use_repository_button": True, + "use_source_button": True, +} html_static_path = ["_static"] From 6425d05095840e11fbb5d2c82f48acaae6f9d34d Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 9 Jan 2025 13:44:33 -0700 Subject: [PATCH 14/16] Spelling erors Co-authored-by: Kevin Albertson --- README.md | 2 +- docs/ref/building.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 15d14a3..24d4e08 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ > to breaking changes at any time. +documentation pages, noted in comments. --> This is `amongoc`, a C11 MongoDB asynchronous client library. It implements a subset of the MongoDB driver APIs. diff --git a/docs/ref/building.rst b/docs/ref/building.rst index 81681c8..f19a37f 100644 --- a/docs/ref/building.rst +++ b/docs/ref/building.rst @@ -202,7 +202,7 @@ Earthfile that eases building by using containerization. amongoc-0.1.0-linux-x86_64.tar.gz amongoc-0.1.0-linux-x86_64.zip - The resuling ``.sh`` script can be used to install the built library and + The resulting ``.sh`` script can be used to install the built library and headers. The same command can work for the `+build-alpine`, `+build-fedora`, and @@ -262,5 +262,5 @@ packages that were used in the |amongoc| build. .. [#fn-redhat-issue] - There is a known issue with the RedHat dev toolset that result in certain + There is a known issue with the RedHat dev toolset that results in certain internal symbols being incorrectly discarded and producing link-time errors. From 2a9ae268e60d084a38286ffbb0ece07ec302d7bd Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 9 Jan 2025 13:45:22 -0700 Subject: [PATCH 15/16] Add missing `__install` script --- tools/__install | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 tools/__install diff --git a/tools/__install b/tools/__install new file mode 100755 index 0000000..c72be7e --- /dev/null +++ b/tools/__install @@ -0,0 +1,48 @@ +#!/usr/bin/env sh + +# Install the named packages using the platform's package manager. +# This script "just does the right thing" to install a package as a step in a +# caching container build, as a bare "pkg-tool install" might be insufficient +# or subtly broken, and we only really care about installing a list of packages +# +# Usage: