Skip to content

Commit 69c5fc2

Browse files
authored
CXX-3103 bump minimum required C Driver version to 2.0.0 (#1379)
1 parent d896795 commit 69c5fc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+861
-303
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
from config_generator.components.funcs.fetch_c_driver_source import FetchCDriverSource
2+
from config_generator.components.funcs.install_c_driver import InstallCDriver
3+
from config_generator.components.funcs.install_uv import InstallUV
4+
from config_generator.components.funcs.setup import Setup
5+
6+
from config_generator.etc.distros import find_small_distro
7+
from config_generator.etc.function import Function
8+
from config_generator.etc.utils import bash_exec
9+
10+
from shrub.v3.evg_build_variant import BuildVariant
11+
from shrub.v3.evg_command import EvgCommandType
12+
from shrub.v3.evg_task import EvgTask, EvgTaskRef
13+
14+
TAG = 'cmake-compat'
15+
16+
# pylint: disable=line-too-long
17+
# fmt: off
18+
MATRIX = [
19+
("min", [3, 15, 4]),
20+
("max-v3", [3, 31, 7]),
21+
("max", [4, 0, 1]),
22+
]
23+
# fmt: on
24+
25+
26+
class CMakeCompat(Function):
27+
name = TAG
28+
commands = [
29+
bash_exec(
30+
command_type=EvgCommandType.TEST,
31+
working_dir='mongo-cxx-driver',
32+
include_expansions_in_env=[
33+
'CMAKE_MAJOR_VERSION',
34+
'CMAKE_MINOR_VERSION',
35+
'CMAKE_PATCH_VERSION',
36+
'INSTALL_C_DRIVER',
37+
],
38+
script='.evergreen/scripts/cmake-compat.sh',
39+
),
40+
bash_exec(
41+
command_type=EvgCommandType.TEST,
42+
include_expansions_in_env=[
43+
'CMAKE_MAJOR_VERSION',
44+
'CMAKE_MINOR_VERSION',
45+
'CMAKE_PATCH_VERSION',
46+
'INSTALL_C_DRIVER',
47+
],
48+
script='mongo-cxx-driver/.evergreen/scripts/cmake-compat-check.sh',
49+
),
50+
]
51+
52+
53+
def functions():
54+
return CMakeCompat.defn()
55+
56+
57+
def tasks():
58+
distro_name = 'rhel80'
59+
distro = find_small_distro(distro_name)
60+
61+
# Test importing C Driver libraries via both add_subdirectory() and find_package().
62+
install_c_driver_modes = [False, True]
63+
64+
for name, version in MATRIX:
65+
for install_c_driver in install_c_driver_modes:
66+
commands = [
67+
Setup.call(),
68+
InstallUV.call(),
69+
(InstallCDriver.call() if install_c_driver else FetchCDriverSource.call()),
70+
CMakeCompat.call(
71+
vars={
72+
'CMAKE_MAJOR_VERSION': version[0],
73+
'CMAKE_MINOR_VERSION': version[1],
74+
'CMAKE_PATCH_VERSION': version[2],
75+
'INSTALL_C_DRIVER': int(install_c_driver),
76+
},
77+
),
78+
]
79+
80+
if install_c_driver:
81+
c_mode = 'find-c'
82+
else:
83+
c_mode = 'add-c'
84+
85+
yield EvgTask(
86+
name=f'{TAG}-{name}-{c_mode}',
87+
tags=[TAG, f'cmake-{name}', f'cmake-{c_mode}'],
88+
run_on=distro.name,
89+
commands=commands,
90+
)
91+
92+
93+
def variants():
94+
return [
95+
BuildVariant(
96+
name=f'{TAG}-matrix',
97+
display_name='CMake Compatibility Matrix',
98+
tasks=[EvgTaskRef(name=f'.{TAG}')],
99+
),
100+
]

.evergreen/config_generator/components/funcs/install_c_driver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99

1010
# If updating mongoc_version_minimum, also update:
11-
# - LIBBSON_REQUIRED_VERSION and LIBMONGOC_REQUIRED_VERSION in CMakeLists.txt
11+
# - BSON_REQUIRED_VERSION and MONGOC_REQUIRED_VERSION in CMakeLists.txt
1212
# - the version of pkg:github/mongodb/mongo-c-driver in etc/purls.txt
1313
# - the default value of --c-driver-build-ref in etc/make_release.py
14-
# Only LIBMONGOC_DOWNLOAD_VERSION needs to be updated when pinning to an unreleased commit.
14+
# Only MONGOC_DOWNLOAD_VERSION needs to be updated when pinning to an unreleased commit.
1515
# If pinning to an unreleased commit, create a "Blocked" JIRA ticket with
1616
# a "depends on" link to the appropriate C Driver version release ticket.
17-
MONGOC_VERSION_MINIMUM = 'f1e2b54090ea28b169b7d9949bd318615188d81d' # CXX-3103: bump to 2.0.0 once released.
17+
MONGOC_VERSION_MINIMUM = '2.0.0'
1818

1919

2020
class InstallCDriver(Function):

.evergreen/generated_configs/functions.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,32 @@ functions:
253253
args:
254254
- -c
255255
- etc/run-clang-tidy.sh
256+
cmake-compat:
257+
- command: subprocess.exec
258+
type: test
259+
params:
260+
binary: bash
261+
working_dir: mongo-cxx-driver
262+
include_expansions_in_env:
263+
- CMAKE_MAJOR_VERSION
264+
- CMAKE_MINOR_VERSION
265+
- CMAKE_PATCH_VERSION
266+
- INSTALL_C_DRIVER
267+
args:
268+
- -c
269+
- .evergreen/scripts/cmake-compat.sh
270+
- command: subprocess.exec
271+
type: test
272+
params:
273+
binary: bash
274+
include_expansions_in_env:
275+
- CMAKE_MAJOR_VERSION
276+
- CMAKE_MINOR_VERSION
277+
- CMAKE_PATCH_VERSION
278+
- INSTALL_C_DRIVER
279+
args:
280+
- -c
281+
- mongo-cxx-driver/.evergreen/scripts/cmake-compat-check.sh
256282
compile:
257283
command: subprocess.exec
258284
type: test
@@ -461,7 +487,7 @@ functions:
461487
type: setup
462488
params:
463489
updates:
464-
- { key: mongoc_version_minimum, value: f1e2b54090ea28b169b7d9949bd318615188d81d }
490+
- { key: mongoc_version_minimum, value: 2.0.0 }
465491
- command: subprocess.exec
466492
type: setup
467493
params:

.evergreen/generated_configs/tasks.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,84 @@ tasks:
166166
vars:
167167
cc_compiler: clang
168168
cxx_compiler: clang++
169+
- name: cmake-compat-max-add-c
170+
run_on: rhel80-small
171+
tags: [cmake-compat, cmake-max, cmake-add-c]
172+
commands:
173+
- func: setup
174+
- func: install-uv
175+
- func: fetch_c_driver_source
176+
- func: cmake-compat
177+
vars:
178+
CMAKE_MAJOR_VERSION: 4
179+
CMAKE_MINOR_VERSION: 0
180+
CMAKE_PATCH_VERSION: 1
181+
INSTALL_C_DRIVER: 0
182+
- name: cmake-compat-max-find-c
183+
run_on: rhel80-small
184+
tags: [cmake-compat, cmake-max, cmake-find-c]
185+
commands:
186+
- func: setup
187+
- func: install-uv
188+
- func: install_c_driver
189+
- func: cmake-compat
190+
vars:
191+
CMAKE_MAJOR_VERSION: 4
192+
CMAKE_MINOR_VERSION: 0
193+
CMAKE_PATCH_VERSION: 1
194+
INSTALL_C_DRIVER: 1
195+
- name: cmake-compat-max-v3-add-c
196+
run_on: rhel80-small
197+
tags: [cmake-compat, cmake-max-v3, cmake-add-c]
198+
commands:
199+
- func: setup
200+
- func: install-uv
201+
- func: fetch_c_driver_source
202+
- func: cmake-compat
203+
vars:
204+
CMAKE_MAJOR_VERSION: 3
205+
CMAKE_MINOR_VERSION: 31
206+
CMAKE_PATCH_VERSION: 7
207+
INSTALL_C_DRIVER: 0
208+
- name: cmake-compat-max-v3-find-c
209+
run_on: rhel80-small
210+
tags: [cmake-compat, cmake-max-v3, cmake-find-c]
211+
commands:
212+
- func: setup
213+
- func: install-uv
214+
- func: install_c_driver
215+
- func: cmake-compat
216+
vars:
217+
CMAKE_MAJOR_VERSION: 3
218+
CMAKE_MINOR_VERSION: 31
219+
CMAKE_PATCH_VERSION: 7
220+
INSTALL_C_DRIVER: 1
221+
- name: cmake-compat-min-add-c
222+
run_on: rhel80-small
223+
tags: [cmake-compat, cmake-min, cmake-add-c]
224+
commands:
225+
- func: setup
226+
- func: install-uv
227+
- func: fetch_c_driver_source
228+
- func: cmake-compat
229+
vars:
230+
CMAKE_MAJOR_VERSION: 3
231+
CMAKE_MINOR_VERSION: 15
232+
CMAKE_PATCH_VERSION: 4
233+
INSTALL_C_DRIVER: 0
234+
- name: cmake-compat-min-find-c
235+
run_on: rhel80-small
236+
tags: [cmake-compat, cmake-min, cmake-find-c]
237+
commands:
238+
- func: setup
239+
- func: install-uv
240+
- func: install_c_driver
241+
- func: cmake-compat
242+
vars:
243+
CMAKE_MAJOR_VERSION: 3
244+
CMAKE_MINOR_VERSION: 15
245+
CMAKE_PATCH_VERSION: 4
246+
INSTALL_C_DRIVER: 1
169247
- name: compile-only-macos-14-arm64-cxx11-debug-shared
170248
run_on: macos-14-arm64
171249
tags: [compile-only, macos-14-arm64, cxx11, debug, shared]

.evergreen/generated_configs/variants.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ buildvariants:
2020
display_name: Clang Tidy
2121
tasks:
2222
- name: .clang-tidy
23+
- name: cmake-compat-matrix
24+
display_name: CMake Compatibility Matrix
25+
tasks:
26+
- name: .cmake-compat
2327
- name: compile-only-matrix
2428
display_name: compile-only-matrix
2529
tasks:
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
6+
: "${CMAKE_MAJOR_VERSION:?}"
7+
: "${CMAKE_MINOR_VERSION:?}"
8+
: "${CMAKE_PATCH_VERSION:?}"
9+
: "${INSTALL_C_DRIVER:?}"
10+
11+
[[ -d mongoc ]] || {
12+
echo "missing mongoc directory"
13+
exit 1
14+
} >&2
15+
16+
[[ -d mongo-cxx-driver/install ]] || {
17+
echo "missing mongo-cxx-driver install directory"
18+
exit 1
19+
} >&2
20+
21+
mongoc_prefix="$(pwd)/mongoc"
22+
mongocxx_prefix="$(pwd)/mongo-cxx-driver/install"
23+
if [[ "${OSTYPE:?}" =~ cygwin ]]; then
24+
mongoc_prefix="$(cygpath -m "${mongoc_prefix:?}")"
25+
mongocxx_prefix="$(cygpath -m "${mongocxx_prefix:?}")"
26+
fi
27+
28+
# shellcheck source=/dev/null
29+
. "${mongoc_prefix:?}/.evergreen/scripts/find-cmake-version.sh"
30+
export cmake_binary
31+
cmake_binary="$(find_cmake_version "${CMAKE_MAJOR_VERSION:?}" "${CMAKE_MINOR_VERSION:?}" "${CMAKE_PATCH_VERSION:?}")"
32+
"${cmake_binary:?}" --version
33+
34+
CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)"
35+
export CMAKE_BUILD_PARALLEL_LEVEL
36+
37+
# Use ccache if available.
38+
if [[ -f "${mongoc_prefix:?}/.evergreen/scripts/find-ccache.sh" ]]; then
39+
# shellcheck source=/dev/null
40+
. "${mongoc_prefix:?}/.evergreen/scripts/find-ccache.sh"
41+
find_ccache_and_export_vars "$(pwd)" || true
42+
fi
43+
44+
cmake_flags=(
45+
"-Werror=dev"
46+
"-Werror=deprecated"
47+
"-DCMAKE_BUILD_TYPE=Debug"
48+
"-DCMAKE_FIND_NO_INSTALL_PREFIX=ON"
49+
)
50+
51+
cat >main.cpp <<DOC
52+
#include <bsoncxx/config/version.hpp>
53+
#include <mongocxx/config/version.hpp>
54+
55+
#include <mongocxx/instance.hpp>
56+
57+
#include <iostream>
58+
59+
int main() {
60+
mongocxx::instance instance;
61+
62+
std::cout << "bsoncxx: " << BSONCXX_VERSION_STRING << std::endl;
63+
std::cout << "mongocxx: " << MONGOCXX_VERSION_STRING << std::endl;
64+
}
65+
DOC
66+
67+
# Support C Driver libraries obtained via both add_subdirectory() and find_package().
68+
if [[ "${INSTALL_C_DRIVER:?}" == 1 ]]; then
69+
# Different install prefixes.
70+
cmake_flags+=("-DCMAKE_PREFIX_PATH=${mongocxx_prefix:?};${mongoc_prefix:?}")
71+
else
72+
# Same install prefix.
73+
cmake_flags+=("-DCMAKE_PREFIX_PATH=${mongocxx_prefix:?}")
74+
fi
75+
76+
echo "Configuring with CMake flags:"
77+
printf " - %s\n" "${cmake_flags[@]:?}"
78+
79+
# Test importing C++ Driver libraries using find_package().
80+
echo "Importing C++ Driver via find_package()..."
81+
{
82+
cat >|CMakeLists.txt <<DOC
83+
cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION:?}.${CMAKE_MINOR_VERSION:?})
84+
project(cmake-compat)
85+
86+
find_package(mongocxx REQUIRED)
87+
88+
add_executable(main main.cpp)
89+
target_link_libraries(main PRIVATE mongo::mongocxx_shared) # + mongo::bsoncxx_shared
90+
DOC
91+
92+
"${cmake_binary:?}" -S . -B build-find "${cmake_flags[@]:?}"
93+
"${cmake_binary:?}" --build build-find --target main
94+
./build-find/main
95+
} &>output.txt || {
96+
cat output.txt >&2
97+
exit 1
98+
}
99+
echo "Importing C++ Driver via find_package()... done."
100+
101+
echo "Importing C++ Driver via add_subdirectory()..."
102+
{
103+
cat >|CMakeLists.txt <<DOC
104+
cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION:?}.${CMAKE_MINOR_VERSION:?})
105+
project(cmake-compat)
106+
107+
add_subdirectory(mongoc)
108+
add_subdirectory(mongo-cxx-driver)
109+
110+
add_executable(main main.cpp)
111+
target_link_libraries(main PRIVATE mongocxx_shared) # + bsoncxx_shared
112+
DOC
113+
114+
"${cmake_binary:?}" -S . -B build-add "${cmake_flags[@]:?}"
115+
"${cmake_binary:?}" --build build-add --target main
116+
./build-add/main
117+
} &>output.txt || {
118+
cat output.txt >&2
119+
exit 1
120+
}
121+
echo "Importing C++ Driver via add_subdirectory()... done."

0 commit comments

Comments
 (0)