Skip to content

Find-SASL cleanup #1405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .evergreen/config_generator/components/earthly.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Iterable
from shrub.v3.evg_build_variant import BuildVariant
from shrub.v3.evg_task import EvgTaskRef
from ..etc.utils import Task
Expand All @@ -7,7 +8,7 @@


class EarthlyTask(Task):
def __init__(self, *, suffix: str, target: str) -> None:
def __init__(self, *, suffix: str, target: str, sasl: str) -> None:
super().__init__(
name=f"earthly-{suffix}",
commands=[
Expand All @@ -17,6 +18,7 @@ def __init__(self, *, suffix: str, target: str) -> None:
"tools/earthly.sh",
f"+{target}",
f"--env=${{{_ENV_PARAM_NAME}}}",
f"--enable_sasl={sasl}",
],
working_dir="mongoc",
command_type=EvgCommandType.TEST,
Expand Down Expand Up @@ -47,9 +49,17 @@ def __init__(self, *, suffix: str, target: str) -> None:
"amazon2",
]

# Other options: SSPI (Windows only), AUTO (not reliably test-able without more environments)
_SASL_OPTIONS = ["CYRUS", "OFF"]

def tasks() -> list[Task]:
return [EarthlyTask(suffix="build-check", target="test-example")]

def tasks() -> Iterable[Task]:
for sasl in _SASL_OPTIONS:
yield EarthlyTask(
suffix=f"build-check-sasl:{sasl}".lower(),
target="test-example",
sasl=sasl,
)


def variants() -> list[BuildVariant]:
Expand Down
26 changes: 25 additions & 1 deletion .evergreen/generated_configs/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,7 @@ tasks:
- func: bootstrap-mongo-orchestration
- func: run-mock-kms-servers
- func: run-tests
- name: earthly-build-check
- name: earthly-build-check-sasl:cyrus
run_on:
- ubuntu2204-small
- ubuntu2204-large
Expand All @@ -1983,6 +1983,30 @@ tasks:
- tools/earthly.sh
- +test-example
- --env=${MONGOC_EARTHLY_ENV}
- --enable_sasl=CYRUS
- name: earthly-build-check-sasl:off
run_on:
- ubuntu2204-small
- ubuntu2204-large
- ubuntu2004-small
- ubuntu2004
- ubuntu1804
- ubuntu1804-medium
- debian10
- debian11
- amazon2
tags: [earthly, pr-merge-gate]
commands:
- command: subprocess.exec
type: test
params:
binary: bash
working_dir: mongoc
args:
- tools/earthly.sh
- +test-example
- --env=${MONGOC_EARTHLY_ENV}
- --enable_sasl=OFF
- name: kms-divergence-check
commands:
- func: kms-divergence-check
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/scripts/link-sample-program-mingw-bson.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ robocopy "%SRCROOT%" "%BUILD_DIR%" /E /XD ".git" "%BUILD_DIR%" "_build" "cmake-b

rem Build libmongoc, with flags that the downstream R driver mongolite uses
%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_CFLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake -DENABLE_STATIC=ON .
%CMAKE% --build .
%CMAKE% --build . --parallel
if errorlevel 1 (
exit /B 1
)
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/scripts/link-sample-program-mingw.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ robocopy "%SRCROOT%" "%BUILD_DIR%" /E /XD ".git" "%BUILD_DIR%" "_build" "cmake-b

rem Build libmongoc, with flags that the downstream R driver mongolite uses
%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_CFLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %CMAKE_FLAGS% .
%CMAKE% --build .
%CMAKE% --build . --parallel
if errorlevel 1 (
exit /B 1
)
Expand Down
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ LoadVersion (VERSION_CURRENT MONGOC)
set(mongo-c-driver_VERSION_PRERELEASE ${MONGOC_PRERELEASE_VERSION})
set(mongo-c-driver_VERSION_FULL ${MONGOC_VERSION})

include(FeatureSummary)

include (MongoSettings)
include (MongoPlatform)
include (GeneratePkgConfig)
Expand Down Expand Up @@ -318,13 +320,13 @@ if ( (ENABLE_BUILD_DEPENDECIES STREQUAL OFF) AND (NOT CMAKE_CURRENT_SOURCE_DIR S
set (ENABLE_BUILD_DEPENDECIES ON)
endif ()

_mongo_pick(BSON_EXTRA_ALIGN 1 0 ENABLE_EXTRA_ALIGNMENT)
mongo_pick(BSON_EXTRA_ALIGN 1 0 ENABLE_EXTRA_ALIGNMENT)

_mongo_pick(MONGOC_ENABLE_RDTSCP 1 0 ENABLE_RDTSCP)
mongo_pick(MONGOC_ENABLE_RDTSCP 1 0 ENABLE_RDTSCP)

_mongo_pick(MONGOC_ENABLE_STATIC_BUILD 1 0 ENABLE_STATIC)
_mongo_pick(MONGOC_ENABLE_STATIC_INSTALL 1 0
[[ENABLE_STATIC AND NOT ENABLE_STATIC STREQUAL "BUILD_ONLY"]])
mongo_pick(MONGOC_ENABLE_STATIC_BUILD 1 0 ENABLE_STATIC)
mongo_pick(MONGOC_ENABLE_STATIC_INSTALL 1 0
[[ENABLE_STATIC AND NOT ENABLE_STATIC STREQUAL "BUILD_ONLY"]])

if (USE_SYSTEM_LIBBSON)
# The input variable BSON_ROOT_DIR is respected for backwards compatibility,
Expand Down Expand Up @@ -620,3 +622,5 @@ endif ()
if (CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND PROJECT_IS_TOP_LEVEL)
set (CMAKE_CROSS_CONFIGS "all")
endif ()

feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
100 changes: 78 additions & 22 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
VERSION --arg-scope-and-set 0.7
VERSION --arg-scope-and-set --pass-args 0.7
LOCALLY

# For target names, descriptions, and build options, run the "doc" Earthly subcommand.

# PREP_CMAKE "warms up" the CMake installation cache for the current environment
PREP_CMAKE:
COMMAND
Expand All @@ -20,7 +22,8 @@ PREP_CMAKE:
# Executing any CMake command will warm the cache:
RUN cmake --version

# version-current creates the VERSION_CURRENT file using Git. This file is exported as an artifact at /
# version-current :
# Create the VERSION_CURRENT file using Git. This file is exported as an artifact at /
version-current:
# Run on Alpine, which does this work the fastest
FROM alpine:3.18
Expand All @@ -29,14 +32,15 @@ version-current:
COPY --dir .git/ build/calc_release_version.py /s/
# Calculate it:
RUN cd /s/ && \
python calc_release_version.py > VERSION_CURRENT
python calc_release_version.py --next-minor > VERSION_CURRENT
SAVE ARTIFACT /s/VERSION_CURRENT

# BUILD_AND_INSTALL executes the mongo-c-driver build and installs it to a prefix
BUILD_AND_INSTALL:
COMMAND
ARG config=RelWithDebInfo
ARG install_prefix=/opt/mongo-c-driver
ARG enable_sasl=CYRUS
LET source_dir=/opt/mongoc/source
LET build_dir=/opt/mongoc/build
COPY --dir \
Expand All @@ -55,7 +59,7 @@ BUILD_AND_INSTALL:
-D ENABLE_MAINTAINER_FLAGS=ON \
-D ENABLE_SHM_COUNTERS=ON \
-D ENABLE_EXTRA_ALIGNMENT=OFF \
-D ENABLE_SASL=CYRUS \
-D ENABLE_SASL=$enable_sasl \
-D ENABLE_SNAPPY=ON \
-D ENABLE_SRV=ON \
-D ENABLE_ZLIB=BUNDLED \
Expand All @@ -71,23 +75,36 @@ BUILD_AND_INSTALL:
alpine-base:
ARG --required version
FROM alpine:$version
RUN apk add cmake ninja-is-really-ninja gcc musl-dev
RUN apk add cmake ninja-is-really-ninja gcc musl-dev g++ cyrus-sasl-dev

alpine-build-env-base:
ARG --required version
FROM +alpine-base --version=$version
RUN apk add openssl-dev cyrus-sasl-dev snappy-dev ccache

alpine-test-env-base:
ARG --required version
FROM +alpine-base --version=$version
RUN apk add snappy

# alpine3.18-build-env :
# A build environment based on Alpine Linux version 3.18
alpine3.18-build-env:
FROM +alpine-base --version=3.18
RUN apk add openssl-dev cyrus-sasl-dev snappy-dev
FROM +alpine-build-env-base --version=3.18

alpine3.18-test-env:
FROM +alpine-base --version=3.18
RUN apk add libsasl snappy
FROM +alpine-test-env-base --version=3.18

archlinux-base:
FROM archlinux
RUN pacman --sync --refresh --sysupgrade --noconfirm --quiet ninja gcc snappy

# archlinux-build-env :
# A build environment based on Arch Linux
archlinux-build-env:
FROM +archlinux-base
DO +PREP_CMAKE
RUN pacman --sync --refresh --sysupgrade --noconfirm --quiet ccache

archlinux-test-env:
FROM +archlinux-base
Expand All @@ -96,42 +113,43 @@ archlinux-test-env:
ubuntu-base:
ARG --required version
FROM ubuntu:$version
RUN apt-get update && apt-get -y install curl build-essential
RUN apt-get update && apt-get -y install curl build-essential libsasl2-dev

# u22-build-env :
# A build environment based on Ubuntu 22.04
u22-build-env:
FROM +ubuntu-base --version=22.04
# Build dependencies:
RUN apt-get update && apt-get -y install \
ninja-build gcc ccache libssl-dev libsnappy-dev zlib1g-dev \
libsasl2-dev
ninja-build gcc ccache libssl-dev libsnappy-dev zlib1g-dev
DO +PREP_CMAKE

u22-test-env:
FROM +ubuntu-base --version=22.04
RUN apt-get update && apt-get -y install libsnappy1v5 libsasl2-2 ninja-build
DO +PREP_CMAKE

# build will build libmongoc and libbson using the specified environment.
# build :
# Build libmongoc and libbson using the specified environment.
#
# The --env argument specifies the build environment, which must be one of:
# • u22 (Ubuntu 22.04)
# • archlinux
# • alpine3.18
# The --env argument specifies the build environment, using “+${env}-build-env”
# as the build environment target. Refer to the list of targets for a list of
# available environments.
build:
# env is an argument
ARG --required env
FROM +$env-build-env
DO +BUILD_AND_INSTALL --config=RelWithDebInfo
FROM --pass-args +$env-build-env
DO --pass-args +BUILD_AND_INSTALL
SAVE ARTIFACT /opt/mongoc/build/* /build-tree/
SAVE ARTIFACT /opt/mongo-c-driver/* /root/

# test-example will build one of the libmongoc example projects using the build
# that comes from the +build target.
test-example:
ARG --required env
FROM +$env-test-env
FROM --pass-args +$env-test-env
# Grab the built
COPY (+build/root --env=$env) /opt/mongo-c-driver
COPY --pass-args +build/root /opt/mongo-c-driver
COPY --dir \
src/libmongoc/examples/cmake \
src/libmongoc/examples/cmake-deprecated \
Expand All @@ -144,6 +162,44 @@ test-example:
-D CMAKE_PREFIX_PATH=/opt/mongo-c-driver
RUN cmake --build /bld

# test-cxx-driver :
# Clone and build the mongo-cxx-driver project, using the current mongo-c-driver
# for the build.
#
# The “--cxx_driver_ref” argument must be a clone-able Git ref. The driver source
# will be cloned at this point and built.
#
# The “--cxx_version_current” argument will be inserted into the VERSION_CURRENT
# file for the cxx-driver build.
test-cxx-driver:
ARG --required env
ARG --required cxx_driver_ref
ARG cxx_version_current=0.0.0
FROM --pass-args +$env-build-env
COPY --pass-args +build/root /opt/mongo-c-driver
LET source=/opt/mongo-cxx-driver/src
LET build=/opt/mongo-cxx-driver/bld
GIT CLONE --branch=$cxx_driver_ref https://github.com/mongodb/mongo-cxx-driver.git $source
RUN echo $cxx_version_current > $source/build/VERSION_CURRENT
RUN cmake -S $source -B $build -G Ninja -D CMAKE_PREFIX_PATH=/opt/mongo-c-driver -D CMAKE_CXX_STANDARD=17
ENV CCACHE_HOME=/root/.cache/ccache
ENV CCACHE_BASE=$source
RUN --mount=type=cache,target=$CCACHE_HOME cmake --build $build

# Simultaneously builds and tests multiple different platforms
multibuild:
BUILD +test-example --env=u22 --env=archlinux --env=alpine3.18
BUILD --pass-args +test-example --env=u22 --env=archlinux --env=alpine3.18

# run :
# Run one or more targets simultaneously.
#
# The “--targets” argument should be a single-string space-separated list of
# target names (not including a leading ‘+’) identifying targets to mark for
# execution. Targets will be executed concurrently. Other build arguments
# will be forwarded to the executed targets.
run:
LOCALLY
ARG --required targets
FOR __target IN $targets
BUILD --pass-args +$__target
END
Loading