Skip to content

Commit 1afba63

Browse files
authored
Miscellaneous Improvements to EVG Config (#1049)
* Remove obsolete tar_options anchor * Remove obsolete poly_mnmlstc anchor * Replace use of mongoc_version_default with minimum * Expand the integration test matrix into explicit variants * Substitute use of mongodb_version anchors * Substitute use of example project anchors * Substitute use of polyfill library flags * Substitute CMake path anchors with in-script search * Substitute use of test param anchors with in-script variables * Substitute use of code coverage anchor with in-script variables * Remove Make-dependent commands in distcheck routines * Ensure distcheck is configured with correct polyfill library * CXX-2772 Move ubuntu1804 MongoDB Latest and 7.0 tasks to ubuntu2004 * Remove redundant use of distros field in variant task list * Remove obsolete -Wno-aligned-new warning from compile flags * Update clang-tidy task * Move clang-tidy task to Clang variant * Fix GCC vs. Clang compiler selection via env vars * Move GCC vs. Clang variants to Ubuntu 20.04 * Move test commands into .evergreen/test.sh * Tidy test.sh * Substitute use of CMake flag anchors with in-script variables * Move compile commands into .evergreen/compile.sh * Tidy compile.sh * Remove minimum libmongoc variant * Merge else branches for CSFLE test setup commands
1 parent ed06ab8 commit 1afba63

File tree

7 files changed

+1178
-834
lines changed

7 files changed

+1178
-834
lines changed

.evergreen/compile.sh

Lines changed: 223 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,247 @@
66
# This script should be run from the root of the repository. This script will run the build from
77
# the default build directory './build'. The following environment variables will change the
88
# behavior of this script:
9-
# - BUILD_TYPE: must be set to "Release" or "Debug"
9+
# - build_type: must be set to "Release" or "Debug"
1010

1111
set -o errexit
1212
set -o pipefail
1313

14-
if [ "$BUILD_TYPE" != "Debug" -a "$BUILD_TYPE" != "Release" ]; then
15-
echo "$0: expected BUILD_TYPE environment variable to be set to 'Debug' or 'Release'" >&2
14+
: "${branch_name:?}"
15+
: "${build_type:?}"
16+
: "${distro_id:?}" # Required by find-cmake-latest.sh.
17+
18+
: "${COMPILE_MACRO_GUARD_TESTS:-}"
19+
: "${ENABLE_CODE_COVERAGE:-}"
20+
: "${ENABLE_TESTS:-}"
21+
: "${generator:-}"
22+
: "${REQUIRED_CXX_STANDARD:-}"
23+
: "${RUN_DISTCHECK:-}"
24+
: "${USE_POLYFILL_BOOST:-}"
25+
: "${USE_POLYFILL_STD_EXPERIMENTAL:-}"
26+
: "${USE_SANITIZER_ASAN:-}"
27+
: "${USE_SANITIZER_UBSAN:-}"
28+
: "${USE_STATIC_LIBS:-}"
29+
30+
# Add MSBuild.exe to path.
31+
if [[ "${OSTYPE:?}" == "cygwin" ]]; then
32+
case "${generator:-}" in
33+
*2015*)
34+
PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/MSBuild/14.0/Bin:$PATH"
35+
;;
36+
*2017*)
37+
PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin:$PATH"
38+
;;
39+
*)
40+
echo "missing explicit CMake Generator on Windows distro" 1>&2
1641
exit 1
42+
;;
43+
esac
1744
fi
45+
export PATH
1846

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

21-
if [ -f /proc/cpuinfo ]; then
22-
CMAKE_BUILD_PARALLEL_LEVEL=$(grep -c ^processor /proc/cpuinfo)
23-
elif which sysctl; then
24-
CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)
25-
else
26-
echo "$0: can't figure out what build parallel level to use" >&2
27-
exit 1
50+
if [[ "${OSTYPE:?}" =~ cygwin ]]; then
51+
mongoc_prefix=$(cygpath -m "${mongoc_prefix:?}")
52+
fi
53+
54+
# shellcheck source=/dev/null
55+
. "${mongoc_prefix:?}/.evergreen/scripts/find-cmake-latest.sh"
56+
export cmake_binary
57+
cmake_binary="$(find_cmake_latest)"
58+
command -v "$cmake_binary"
59+
60+
if [ ! -d ../drivers-evergreen-tools ]; then
61+
git clone --depth 1 [email protected]:mongodb-labs/drivers-evergreen-tools.git ../drivers-evergreen-tools
2862
fi
63+
# shellcheck source=/dev/null
64+
. ../drivers-evergreen-tools/.evergreen/find-python3.sh
65+
# shellcheck source=/dev/null
66+
. ../drivers-evergreen-tools/.evergreen/venv-utils.sh
67+
68+
venvcreate "$(find_python3)" venv
69+
python -m pip install GitPython
70+
71+
if [[ "${build_type:?}" != "Debug" && "${build_type:?}" != "Release" ]]; then
72+
echo "$0: expected build_type environment variable to be set to 'Debug' or 'Release'" >&2
73+
exit 1
74+
fi
75+
76+
if [[ "${OSTYPE}" == darwin* ]]; then
77+
# MacOS does not have nproc.
78+
nproc() {
79+
sysctl -n hw.logicalcpu
80+
}
81+
fi
82+
CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)"
2983
export CMAKE_BUILD_PARALLEL_LEVEL
3084

31-
case "$OS" in
32-
darwin|linux)
33-
GENERATOR=${GENERATOR:-"Unix Makefiles"}
34-
CMAKE_EXAMPLES_TARGET=examples
35-
if [ "$RUN_DISTCHECK" ]; then
36-
_RUN_DISTCHECK=$RUN_DISTCHECK
37-
fi
38-
;;
39-
40-
cygwin*)
41-
GENERATOR=${GENERATOR:-"Visual Studio 14 2015 Win64"}
42-
CMAKE_BUILD_OPTS="/verbosity:minimal"
43-
CMAKE_EXAMPLES_TARGET=examples/examples
44-
;;
45-
46-
*)
47-
echo "$0: unsupported platform '$OS'" >&2
48-
exit 2
49-
;;
85+
# Use ccache if available.
86+
if command -v ccache >/dev/null; then
87+
echo "Enabling ccache as CMake compiler launcher"
88+
export CMAKE_C_COMPILER_LAUNCHER=ccache
89+
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
90+
fi
91+
92+
cmake_build_opts=()
93+
case "${OSTYPE:?}" in
94+
cygwin)
95+
cmake_build_opts+=("/verbosity:minimal")
96+
cmake_examples_target="examples/examples"
97+
;;
98+
99+
darwin* | linux*)
100+
cmake_examples_target="examples"
101+
;;
102+
103+
*)
104+
echo "unrecognized operating system ${OSTYPE:?}" 1>&2
105+
exit 1
106+
;;
50107
esac
108+
: "${cmake_examples_target:?}"
51109

52110
cd build
53-
"${cmake_binary}" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DBUILD_TESTING=ON -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON "$@" ..
111+
112+
cmake_flags=(
113+
"-DCMAKE_BUILD_TYPE=${build_type:?}"
114+
"-DCMAKE_PREFIX_PATH=${mongoc_prefix:?}"
115+
-DBUILD_TESTING=ON
116+
-DMONGOCXX_ENABLE_SLOW_TESTS=ON
117+
-DCMAKE_INSTALL_PREFIX=install
118+
-DENABLE_UNINSTALL=ON
119+
)
120+
121+
_RUN_DISTCHECK=""
122+
case "${OSTYPE:?}" in
123+
cygwin)
124+
case "${generator:-}" in
125+
*2015*) cmake_flags+=("-DBOOST_ROOT=C:/local/boost_1_60_0") ;;
126+
*2017*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;;
127+
*)
128+
echo "missing explicit CMake Generator on Windows distro" 1>&2
129+
exit 1
130+
;;
131+
esac
132+
;;
133+
darwin* | linux*)
134+
: "${generator:="Unix Makefiles"}"
135+
136+
# If enabled, limit distcheck to Unix-like systems only.
137+
_RUN_DISTCHECK="${RUN_DISTCHECK:-}"
138+
;;
139+
*)
140+
echo "unrecognized operating system ${OSTYPE:?}" 1>&2
141+
exit 1
142+
;;
143+
esac
144+
export CMAKE_GENERATOR="${generator:?}"
145+
146+
if [[ "${USE_POLYFILL_STD_EXPERIMENTAL:-}" == "ON" ]]; then
147+
cmake_flags+=(
148+
"-DCMAKE_CXX_STANDARD=14"
149+
"-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=ON"
150+
)
151+
fi
152+
153+
if [[ "${USE_POLYFILL_BOOST:-}" == "ON" ]]; then
154+
cmake_flags+=("-DBSONCXX_POLY_USE_BOOST=ON")
155+
fi
156+
157+
cc_flags_init=(-Wall -Wextra -Wno-attributes -Werror -Wno-missing-field-initializers)
158+
cxx_flags_init=(-Wall -Wextra -Wconversion -Wnarrowing -pedantic -Werror)
159+
cc_flags=()
160+
cxx_flags=()
161+
162+
case "${OSTYPE:?}" in
163+
cygwin) ;;
164+
darwin*)
165+
cc_flags+=("${cc_flags_init[@]}")
166+
cxx_flags+=("${cxx_flags_init[@]}" -stdlib=libc++)
167+
;;
168+
linux*)
169+
cc_flags+=("${cc_flags_init[@]}")
170+
cxx_flags+=("${cxx_flags_init[@]}" -Wno-expansion-to-defined -Wno-missing-field-initializers)
171+
;;
172+
*)
173+
echo "unrecognized operating system ${OSTYPE:?}" 1>&2
174+
exit 1
175+
;;
176+
esac
177+
178+
# Sanitizers overwrite the usual compiler flags.
179+
if [[ "${USE_SANITIZER_ASAN:-}" == "ON" ]]; then
180+
cxx_flags=(
181+
"${cxx_flags_init[@]}"
182+
-D_GLIBCXX_USE_CXX11_ABI=0
183+
-fsanitize=address
184+
-O1 -g -fno-omit-frame-pointer
185+
)
186+
fi
187+
if [[ "${USE_SANITIZER_UBSAN:-}" == "ON" ]]; then
188+
cxx_flags=(
189+
"${cxx_flags_init[@]}"
190+
-D_GLIBCXX_USE_CXX11_ABI=0
191+
-fsanitize=undefined
192+
-fsanitize-blacklist="$(pwd)/../etc/ubsan.ignorelist"
193+
-fno-sanitize-recover=undefined
194+
-O1 -g -fno-omit-frame-pointer
195+
)
196+
fi
197+
198+
# Ignore warnings generated by core::optional in mnmlstc/core.
199+
if [[ "${OSTYPE:?}" == linux* && "${HOSTTYPE:?}" == powerpc64le ]]; then
200+
cxx_flags+=(-Wno-error=maybe-uninitialized)
201+
fi
202+
203+
# Ignore deprecation warnings when building on a release branch.
204+
if [ "$(echo "${branch_name:?}" | cut -f2 -d'/')" != "${branch_name:?}" ]; then
205+
cc_flags+=(-Wno-deprecated-declarations)
206+
cxx_flags+=(-Wno-deprecated-declarations)
207+
fi
208+
209+
if [[ "${#cc_flags[@]}" -gt 0 ]]; then
210+
cmake_flags+=("-DCMAKE_C_FLAGS=${cc_flags[*]}")
211+
fi
212+
213+
if [[ "${#cxx_flags[@]}" -gt 0 ]]; then
214+
cmake_flags+=("-DCMAKE_CXX_FLAGS=${cxx_flags[*]}")
215+
fi
216+
217+
if [[ "${ENABLE_CODE_COVERAGE:-}" == "ON" ]]; then
218+
cmake_flags+=("-DENABLE_CODE_COVERAGE=ON")
219+
fi
220+
221+
if [ "${USE_STATIC_LIBS:-}" ]; then
222+
cmake_flags+=("-DBUILD_SHARED_LIBS=OFF")
223+
fi
224+
225+
if [ "${ENABLE_TESTS:-}" = "OFF" ]; then
226+
cmake_flags+=("-DENABLE_TESTS=OFF")
227+
fi
228+
229+
if [[ -n "${REQUIRED_CXX_STANDARD:-}" ]]; then
230+
cmake_flags+=("-DCMAKE_CXX_STANDARD=${REQUIRED_CXX_STANDARD:?}")
231+
cmake_flags+=("-DCMAKE_CXX_STANDARD_REQUIRED=ON")
232+
fi
233+
234+
echo "Configuring with CMake flags: ${cmake_flags[*]}"
235+
236+
"${cmake_binary}" "${cmake_flags[@]}" ..
54237

55238
if [[ "${COMPILE_MACRO_GUARD_TESTS:-"OFF"}" == "ON" ]]; then
56-
# We only need to compile the macro guard tests.
57-
"${cmake_binary}" -DENABLE_MACRO_GUARD_TESTS=ON ..
58-
"${cmake_binary}" --build . --config $BUILD_TYPE --target test_bsoncxx_macro_guards test_mongocxx_macro_guards -- $CMAKE_BUILD_OPTS
59-
exit # Nothing else to be done.
239+
# We only need to compile the macro guard tests.
240+
"${cmake_binary}" -DENABLE_MACRO_GUARD_TESTS=ON ..
241+
"${cmake_binary}" --build . --config "${build_type:?}" --target test_bsoncxx_macro_guards test_mongocxx_macro_guards -- "${cmake_build_opts[@]}"
242+
exit # Nothing else to be done.
60243
fi
61244

62245
# Regular build and install routine.
63-
"${cmake_binary}" --build . --config $BUILD_TYPE -- $CMAKE_BUILD_OPTS
64-
"${cmake_binary}" --build . --config $BUILD_TYPE --target install -- $CMAKE_BUILD_OPTS
65-
"${cmake_binary}" --build . --config $BUILD_TYPE --target $CMAKE_EXAMPLES_TARGET -- $CMAKE_BUILD_OPTS
246+
"${cmake_binary}" --build . --config "${build_type:?}" -- "${cmake_build_opts[@]}"
247+
"${cmake_binary}" --build . --config "${build_type:?}" --target install -- "${cmake_build_opts[@]}"
248+
"${cmake_binary}" --build . --config "${build_type:?}" --target "${cmake_examples_target:?}" -- "${cmake_build_opts[@]}"
66249

67-
if [ "$_RUN_DISTCHECK" ]; then
68-
DISTCHECK_BUILD_OPTS="-j$CONCURRENCY" "${cmake_binary}" --build . --config $BUILD_TYPE --target distcheck
250+
if [[ "${_RUN_DISTCHECK:-}" ]]; then
251+
"${cmake_binary}" --build . --config "${build_type:?}" --target distcheck
69252
fi

.evergreen/install_c_driver.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -o errexit
44
set -o pipefail
55

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

99
# Usage:

0 commit comments

Comments
 (0)