Skip to content

Miscellaneous Improvements to EVG Config #1049

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 29 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
29263b7
Remove obsolete tar_options anchor
eramongodb Oct 24, 2023
6bd6d03
Remove obsolete poly_mnmlstc anchor
eramongodb Oct 24, 2023
6742672
Replace use of mongoc_version_default with minimum
eramongodb Oct 24, 2023
1d7924c
Expand the integration test matrix into explicit variants
eramongodb Oct 24, 2023
de0c171
Substitute use of mongodb_version anchors
eramongodb Oct 24, 2023
8ae08ce
Substitute use of example project anchors
eramongodb Oct 24, 2023
5ff43bf
Substitute use of polyfill library flags
eramongodb Oct 24, 2023
c2ff76e
Substitute CMake path anchors with in-script search
eramongodb Oct 24, 2023
3ed5c9a
Substitute use of test param anchors with in-script variables
eramongodb Oct 24, 2023
8f83716
Substitute use of code coverage anchor with in-script variables
eramongodb Oct 24, 2023
fca7aef
Remove Make-dependent commands in distcheck routines
eramongodb Oct 25, 2023
81d67f6
Ensure distcheck is configured with correct polyfill library
eramongodb Oct 25, 2023
1199f1d
CXX-2772 Move ubuntu1804 MongoDB Latest and 7.0 tasks to ubuntu2004
eramongodb Oct 26, 2023
7c147d8
Remove redundant use of distros field in variant task list
eramongodb Oct 26, 2023
1791da7
Remove obsolete -Wno-aligned-new warning from compile flags
eramongodb Oct 26, 2023
ceb686d
Update clang-tidy task
eramongodb Oct 26, 2023
e07fabf
Move clang-tidy task to Clang variant
eramongodb Oct 26, 2023
3d74e3f
Fix GCC vs. Clang compiler selection via env vars
eramongodb Oct 26, 2023
40dcdeb
Move GCC vs. Clang variants to Ubuntu 20.04
eramongodb Oct 26, 2023
cf1fcd6
Move test commands into .evergreen/test.sh
eramongodb Oct 26, 2023
5e3e26c
Tidy test.sh
eramongodb Oct 26, 2023
8e2bd99
Substitute use of CMake flag anchors with in-script variables
eramongodb Oct 27, 2023
ce5e145
Move compile commands into .evergreen/compile.sh
eramongodb Oct 30, 2023
8d13623
Tidy compile.sh
eramongodb Oct 30, 2023
c65d3dc
Remove minimum libmongoc variant
eramongodb Nov 2, 2023
2c302fb
Add error handling for MSBuild path selection
eramongodb Nov 2, 2023
83aa493
Add note for indirect requirement of distro_id env var
eramongodb Nov 2, 2023
a056418
Merge else branches for CSFLE test setup commands
eramongodb Nov 2, 2023
2f71c5e
Merge remote-tracking branch 'upstream/master' into cxx-evg
eramongodb Nov 6, 2023
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
263 changes: 223 additions & 40 deletions .evergreen/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,247 @@
# This script should be run from the root of the repository. This script will run the build from
# the default build directory './build'. The following environment variables will change the
# behavior of this script:
# - BUILD_TYPE: must be set to "Release" or "Debug"
# - build_type: must be set to "Release" or "Debug"

set -o errexit
set -o pipefail

if [ "$BUILD_TYPE" != "Debug" -a "$BUILD_TYPE" != "Release" ]; then
echo "$0: expected BUILD_TYPE environment variable to be set to 'Debug' or 'Release'" >&2
: "${branch_name:?}"
: "${build_type:?}"
: "${distro_id:?}" # Required by find-cmake-latest.sh.

: "${COMPILE_MACRO_GUARD_TESTS:-}"
: "${ENABLE_CODE_COVERAGE:-}"
: "${ENABLE_TESTS:-}"
: "${generator:-}"
: "${REQUIRED_CXX_STANDARD:-}"
: "${RUN_DISTCHECK:-}"
: "${USE_POLYFILL_BOOST:-}"
: "${USE_POLYFILL_STD_EXPERIMENTAL:-}"
: "${USE_SANITIZER_ASAN:-}"
: "${USE_SANITIZER_UBSAN:-}"
: "${USE_STATIC_LIBS:-}"

# Add MSBuild.exe to path.
if [[ "${OSTYPE:?}" == "cygwin" ]]; then
case "${generator:-}" in
*2015*)
PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/MSBuild/14.0/Bin:$PATH"
;;
*2017*)
PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin:$PATH"
;;
*)
echo "missing explicit CMake Generator on Windows distro" 1>&2
exit 1
;;
esac
fi
export PATH

OS=$(uname -s | tr '[:upper:]' '[:lower:]')
mongoc_prefix="$(pwd)/../mongoc"
echo "mongoc_prefix=${mongoc_prefix:?}"

if [ -f /proc/cpuinfo ]; then
CMAKE_BUILD_PARALLEL_LEVEL=$(grep -c ^processor /proc/cpuinfo)
elif which sysctl; then
CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)
else
echo "$0: can't figure out what build parallel level to use" >&2
exit 1
if [[ "${OSTYPE:?}" =~ cygwin ]]; then
mongoc_prefix=$(cygpath -m "${mongoc_prefix:?}")
fi

# shellcheck source=/dev/null
. "${mongoc_prefix:?}/.evergreen/scripts/find-cmake-latest.sh"
export cmake_binary
cmake_binary="$(find_cmake_latest)"
command -v "$cmake_binary"

if [ ! -d ../drivers-evergreen-tools ]; then
git clone --depth 1 [email protected]:mongodb-labs/drivers-evergreen-tools.git ../drivers-evergreen-tools
fi
# shellcheck source=/dev/null
. ../drivers-evergreen-tools/.evergreen/find-python3.sh
# shellcheck source=/dev/null
. ../drivers-evergreen-tools/.evergreen/venv-utils.sh

venvcreate "$(find_python3)" venv
python -m pip install GitPython

if [[ "${build_type:?}" != "Debug" && "${build_type:?}" != "Release" ]]; then
echo "$0: expected build_type environment variable to be set to 'Debug' or 'Release'" >&2
exit 1
fi

if [[ "${OSTYPE}" == darwin* ]]; then
# MacOS does not have nproc.
nproc() {
sysctl -n hw.logicalcpu
}
fi
CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)"
export CMAKE_BUILD_PARALLEL_LEVEL

case "$OS" in
darwin|linux)
GENERATOR=${GENERATOR:-"Unix Makefiles"}
CMAKE_EXAMPLES_TARGET=examples
if [ "$RUN_DISTCHECK" ]; then
_RUN_DISTCHECK=$RUN_DISTCHECK
fi
;;

cygwin*)
GENERATOR=${GENERATOR:-"Visual Studio 14 2015 Win64"}
CMAKE_BUILD_OPTS="/verbosity:minimal"
CMAKE_EXAMPLES_TARGET=examples/examples
;;

*)
echo "$0: unsupported platform '$OS'" >&2
exit 2
;;
# Use ccache if available.
if command -v ccache >/dev/null; then
echo "Enabling ccache as CMake compiler launcher"
export CMAKE_C_COMPILER_LAUNCHER=ccache
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
fi

cmake_build_opts=()
case "${OSTYPE:?}" in
cygwin)
cmake_build_opts+=("/verbosity:minimal")
cmake_examples_target="examples/examples"
;;

darwin* | linux*)
cmake_examples_target="examples"
;;

*)
echo "unrecognized operating system ${OSTYPE:?}" 1>&2
exit 1
;;
esac
: "${cmake_examples_target:?}"

cd build
"${cmake_binary}" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DBUILD_TESTING=ON -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON "$@" ..

cmake_flags=(
"-DCMAKE_BUILD_TYPE=${build_type:?}"
"-DCMAKE_PREFIX_PATH=${mongoc_prefix:?}"
-DBUILD_TESTING=ON
-DMONGOCXX_ENABLE_SLOW_TESTS=ON
-DCMAKE_INSTALL_PREFIX=install
-DENABLE_UNINSTALL=ON
)

_RUN_DISTCHECK=""
case "${OSTYPE:?}" in
cygwin)
case "${generator:-}" in
*2015*) cmake_flags+=("-DBOOST_ROOT=C:/local/boost_1_60_0") ;;
*2017*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;;
*)
echo "missing explicit CMake Generator on Windows distro" 1>&2
exit 1
;;
esac
;;
darwin* | linux*)
: "${generator:="Unix Makefiles"}"

# If enabled, limit distcheck to Unix-like systems only.
_RUN_DISTCHECK="${RUN_DISTCHECK:-}"
;;
*)
echo "unrecognized operating system ${OSTYPE:?}" 1>&2
exit 1
;;
esac
export CMAKE_GENERATOR="${generator:?}"

if [[ "${USE_POLYFILL_STD_EXPERIMENTAL:-}" == "ON" ]]; then
cmake_flags+=(
"-DCMAKE_CXX_STANDARD=14"
"-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=ON"
)
fi

if [[ "${USE_POLYFILL_BOOST:-}" == "ON" ]]; then
cmake_flags+=("-DBSONCXX_POLY_USE_BOOST=ON")
fi

cc_flags_init=(-Wall -Wextra -Wno-attributes -Werror -Wno-missing-field-initializers)
cxx_flags_init=(-Wall -Wextra -Wconversion -Wnarrowing -pedantic -Werror)
cc_flags=()
cxx_flags=()

case "${OSTYPE:?}" in
cygwin) ;;
darwin*)
cc_flags+=("${cc_flags_init[@]}")
cxx_flags+=("${cxx_flags_init[@]}" -stdlib=libc++)
;;
linux*)
cc_flags+=("${cc_flags_init[@]}")
cxx_flags+=("${cxx_flags_init[@]}" -Wno-expansion-to-defined -Wno-missing-field-initializers)
;;
*)
echo "unrecognized operating system ${OSTYPE:?}" 1>&2
exit 1
;;
esac

# Sanitizers overwrite the usual compiler flags.
if [[ "${USE_SANITIZER_ASAN:-}" == "ON" ]]; then
cxx_flags=(
"${cxx_flags_init[@]}"
-D_GLIBCXX_USE_CXX11_ABI=0
-fsanitize=address
-O1 -g -fno-omit-frame-pointer
)
fi
if [[ "${USE_SANITIZER_UBSAN:-}" == "ON" ]]; then
cxx_flags=(
"${cxx_flags_init[@]}"
-D_GLIBCXX_USE_CXX11_ABI=0
-fsanitize=undefined
-fsanitize-blacklist="$(pwd)/../etc/ubsan.ignorelist"
-fno-sanitize-recover=undefined
-O1 -g -fno-omit-frame-pointer
)
fi

# Ignore warnings generated by core::optional in mnmlstc/core.
if [[ "${OSTYPE:?}" == linux* && "${HOSTTYPE:?}" == powerpc64le ]]; then
cxx_flags+=(-Wno-error=maybe-uninitialized)
fi

# Ignore deprecation warnings when building on a release branch.
if [ "$(echo "${branch_name:?}" | cut -f2 -d'/')" != "${branch_name:?}" ]; then
cc_flags+=(-Wno-deprecated-declarations)
cxx_flags+=(-Wno-deprecated-declarations)
fi

if [[ "${#cc_flags[@]}" -gt 0 ]]; then
cmake_flags+=("-DCMAKE_C_FLAGS=${cc_flags[*]}")
fi

if [[ "${#cxx_flags[@]}" -gt 0 ]]; then
cmake_flags+=("-DCMAKE_CXX_FLAGS=${cxx_flags[*]}")
fi

if [[ "${ENABLE_CODE_COVERAGE:-}" == "ON" ]]; then
cmake_flags+=("-DENABLE_CODE_COVERAGE=ON")
fi

if [ "${USE_STATIC_LIBS:-}" ]; then
cmake_flags+=("-DBUILD_SHARED_LIBS=OFF")
fi

if [ "${ENABLE_TESTS:-}" = "OFF" ]; then
cmake_flags+=("-DENABLE_TESTS=OFF")
fi

if [[ -n "${REQUIRED_CXX_STANDARD:-}" ]]; then
cmake_flags+=("-DCMAKE_CXX_STANDARD=${REQUIRED_CXX_STANDARD:?}")
cmake_flags+=("-DCMAKE_CXX_STANDARD_REQUIRED=ON")
fi

echo "Configuring with CMake flags: ${cmake_flags[*]}"

"${cmake_binary}" "${cmake_flags[@]}" ..

if [[ "${COMPILE_MACRO_GUARD_TESTS:-"OFF"}" == "ON" ]]; then
# We only need to compile the macro guard tests.
"${cmake_binary}" -DENABLE_MACRO_GUARD_TESTS=ON ..
"${cmake_binary}" --build . --config $BUILD_TYPE --target test_bsoncxx_macro_guards test_mongocxx_macro_guards -- $CMAKE_BUILD_OPTS
exit # Nothing else to be done.
# We only need to compile the macro guard tests.
"${cmake_binary}" -DENABLE_MACRO_GUARD_TESTS=ON ..
"${cmake_binary}" --build . --config "${build_type:?}" --target test_bsoncxx_macro_guards test_mongocxx_macro_guards -- "${cmake_build_opts[@]}"
exit # Nothing else to be done.
fi

# Regular build and install routine.
"${cmake_binary}" --build . --config $BUILD_TYPE -- $CMAKE_BUILD_OPTS
"${cmake_binary}" --build . --config $BUILD_TYPE --target install -- $CMAKE_BUILD_OPTS
"${cmake_binary}" --build . --config $BUILD_TYPE --target $CMAKE_EXAMPLES_TARGET -- $CMAKE_BUILD_OPTS
"${cmake_binary}" --build . --config "${build_type:?}" -- "${cmake_build_opts[@]}"
"${cmake_binary}" --build . --config "${build_type:?}" --target install -- "${cmake_build_opts[@]}"
"${cmake_binary}" --build . --config "${build_type:?}" --target "${cmake_examples_target:?}" -- "${cmake_build_opts[@]}"

if [ "$_RUN_DISTCHECK" ]; then
DISTCHECK_BUILD_OPTS="-j$CONCURRENCY" "${cmake_binary}" --build . --config $BUILD_TYPE --target distcheck
if [[ "${_RUN_DISTCHECK:-}" ]]; then
"${cmake_binary}" --build . --config "${build_type:?}" --target distcheck
fi
2 changes: 1 addition & 1 deletion .evergreen/install_c_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -o errexit
set -o pipefail

declare -r mongoc_version="${mongoc_version:-"${mongoc_version_default:?"missing mongoc version"}"}"
declare -r mongoc_version="${mongoc_version:-"${mongoc_version_minimum:?"missing mongoc version"}"}"
: "${mongoc_version:?}"

# Usage:
Expand Down
Loading