Skip to content

Commit c7e43c1

Browse files
authored
CDRIVER-4462 Use CMake 3.25.2 and improve compile scripts (#1205)
* CDRIVER-4462 Add find-cmake-version.h and find-cmake-latest.sh * Use find-cmake-latest.sh in compile.sh scripts * Print CMake version after search for verification * Ensure build-and-test-with-toolchain uses the correct CMake version * Ensure consistent CMake binary usage when compiling libmongocrypt * Fix CMake linker selection issue on macos-1014 * Add required Evergreen expansions to tasks * Extract scan-build compile script into compile-scan-build.sh * Extract libmongocrypt compilation scripts into compile-libmongocrypt.sh * Address several compile and scan-build warnings * Reduce output verbosity of build-and-test-with-toolchain * Relocate scan-build matrix to config_generator * Use compile-libmongocrypt.sh in compile-std.sh
1 parent 79627c2 commit c7e43c1

29 files changed

+877
-302
lines changed

.evergreen/config_generator/components/abi_compliance_check.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class CheckABICompliance(Function):
1111
commands = [
1212
bash_exec(
1313
command_type=EvgCommandType.SETUP,
14+
add_expansions_to_env=True,
1415
working_dir='mongoc',
1516
script='.evergreen/scripts/abi-compliance-check.sh'
1617
),
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
from shrub.v3.evg_build_variant import BuildVariant
2+
from shrub.v3.evg_command import EvgCommandType
3+
from shrub.v3.evg_command import FunctionCall
4+
from shrub.v3.evg_task import EvgTaskRef
5+
6+
from config_generator.etc.distros import find_large_distro
7+
from config_generator.etc.distros import make_distro_str
8+
from config_generator.etc.distros import to_cc
9+
from config_generator.etc.function import Function
10+
from config_generator.etc.utils import bash_exec
11+
from config_generator.etc.utils import Task
12+
13+
14+
TAG = 'scan-build-matrix'
15+
16+
17+
# pylint: disable=line-too-long
18+
# fmt: off
19+
MATRIX = [
20+
('macos-1014', 'clang', None ),
21+
('ubuntu1404', 'clang', None ),
22+
('ubuntu1604-arm64', 'clang', None ),
23+
('ubuntu1604', 'clang', 'i686'),
24+
('ubuntu1604', 'clang', None ),
25+
('ubuntu1804-arm64', 'clang', None ),
26+
('ubuntu1804', 'clang', 'i686'),
27+
]
28+
# fmt: on
29+
# pylint: enable=line-too-long
30+
31+
32+
class ScanBuild(Function):
33+
name = 'scan-build'
34+
commands = [
35+
bash_exec(
36+
command_type=EvgCommandType.TEST,
37+
add_expansions_to_env=True,
38+
redirect_standard_error_to_output=True,
39+
working_dir='mongoc',
40+
script='.evergreen/scripts/compile-scan-build.sh',
41+
),
42+
]
43+
44+
@classmethod
45+
def call(cls, **kwargs):
46+
return cls.default_call(**kwargs)
47+
48+
49+
def functions():
50+
return ScanBuild.defn()
51+
52+
53+
def tasks():
54+
res = []
55+
56+
for distro_name, compiler, arch in MATRIX:
57+
tags = [TAG, distro_name, compiler]
58+
59+
distro = find_large_distro(distro_name)
60+
61+
compile_vars = None
62+
compile_vars = {'CC': to_cc(compiler)}
63+
64+
if arch:
65+
tags.append(arch)
66+
compile_vars.update({'MARCH': arch})
67+
68+
distro_str = make_distro_str(distro_name, compiler, arch)
69+
70+
task_name = f'scan-build-{distro_str}'
71+
72+
res.append(
73+
Task(
74+
name=task_name,
75+
run_on=distro.name,
76+
tags=tags,
77+
commands=[
78+
ScanBuild.call(vars=compile_vars),
79+
FunctionCall(func='upload scan artifacts'),
80+
],
81+
)
82+
)
83+
84+
# TODO: remove once BUILD-16814 is resolved.
85+
for task in res:
86+
if task.run_on == 'macos-1014':
87+
task.disable = True
88+
89+
return res
90+
91+
92+
def variants():
93+
return [
94+
BuildVariant(
95+
name=TAG,
96+
display_name=TAG,
97+
tasks=[EvgTaskRef(name=f'.{TAG}')],
98+
),
99+
]

.evergreen/generated_configs/functions.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ functions:
55
params:
66
binary: bash
77
working_dir: mongoc
8+
add_expansions_to_env: true
89
args:
910
- -c
1011
- .evergreen/scripts/abi-compliance-check.sh
@@ -406,6 +407,17 @@ functions:
406407
args:
407408
- -c
408409
- .evergreen/scripts/compile.sh
410+
scan-build:
411+
- command: subprocess.exec
412+
type: test
413+
params:
414+
binary: bash
415+
working_dir: mongoc
416+
add_expansions_to_env: true
417+
redirect_standard_error_to_output: true
418+
args:
419+
- -c
420+
- .evergreen/scripts/compile-scan-build.sh
409421
std-compile:
410422
- command: subprocess.exec
411423
type: test

.evergreen/generated_configs/legacy-config.yml

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -472,34 +472,6 @@ tasks:
472472
set -o errexit
473473
env CFLAGS="-fno-omit-frame-pointer" CHECK_LOG="ON" DEBUG="ON" EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF" SANITIZE="address" SNAPPY="OFF" SSL="OPENSSL" ZLIB="BUNDLED" ZSTD="OFF" bash .evergreen/scripts/compile.sh
474474
- func: upload-build
475-
- name: debug-compile-scan-build
476-
tags:
477-
- clang
478-
- debug-compile
479-
- scan-build
480-
- special
481-
commands:
482-
- command: shell.exec
483-
type: test
484-
params:
485-
working_dir: mongoc
486-
add_expansions_to_env: true
487-
shell: bash
488-
script: |-
489-
set -o errexit
490-
env ANALYZE="ON" CC="clang" DEBUG="ON" bash .evergreen/scripts/compile.sh
491-
- func: upload-build
492-
- func: upload scan artifacts
493-
- command: shell.exec
494-
type: test
495-
params:
496-
working_dir: mongoc
497-
shell: bash
498-
script: |-
499-
set -o errexit
500-
if find scan -name \*.html | grep -q html; then
501-
exit 123
502-
fi
503475
- name: compile-tracing
504476
commands:
505477
- command: shell.exec
@@ -9025,6 +8997,7 @@ tasks:
90258997
- func: fetch-source
90268998
- command: shell.exec
90278999
params:
9000+
add_expansions_to_env: true
90289001
shell: bash
90299002
script: |-
90309003
set -o errexit
@@ -9066,6 +9039,7 @@ tasks:
90669039
- func: fetch-source
90679040
- command: shell.exec
90689041
params:
9042+
add_expansions_to_env: true
90699043
shell: bash
90709044
script: |-
90719045
set -o errexit
@@ -9089,6 +9063,7 @@ tasks:
90899063
- func: fetch-source
90909064
- command: shell.exec
90919065
params:
9066+
add_expansions_to_env: true
90929067
shell: bash
90939068
script: |-
90949069
set -o errexit
@@ -9127,6 +9102,7 @@ tasks:
91279102
commands:
91289103
- command: shell.exec
91299104
params:
9105+
add_expansions_to_env: true
91309106
shell: bash
91319107
script: |-
91329108
set -o errexit
@@ -9287,7 +9263,6 @@ buildvariants:
92879263
CC: clang
92889264
run_on: ubuntu1404-build
92899265
tasks:
9290-
- debug-compile-scan-build
92919266
- release-compile
92929267
- debug-compile-rdtscp
92939268
- name: clang35
@@ -9337,7 +9312,6 @@ buildvariants:
93379312
MARCH: i686
93389313
run_on: ubuntu1804-test
93399314
tasks:
9340-
- debug-compile-scan-build
93419315
- release-compile
93429316
- debug-compile-nosasl-nossl
93439317
- debug-compile-no-align
@@ -9350,7 +9324,6 @@ buildvariants:
93509324
MARCH: i686
93519325
run_on: ubuntu1604-test
93529326
tasks:
9353-
- debug-compile-scan-build
93549327
- release-compile
93559328
- debug-compile-no-align
93569329
- name: clang38ubuntu
@@ -9360,7 +9333,6 @@ buildvariants:
93609333
run_on: ubuntu1604-test
93619334
tasks:
93629335
- .compression !.zstd
9363-
- debug-compile-scan-build
93649336
- release-compile
93659337
- debug-compile-sasl-openssl
93669338
- debug-compile-nosasl-openssl
@@ -9503,7 +9475,6 @@ buildvariants:
95039475
- debug-compile-nosrv
95049476
- debug-compile-sasl-darwinssl
95059477
- debug-compile-nosasl-nossl
9506-
- .debug-compile .clang
95079478
- .authentication-tests .darwinssl
95089479
- .latest .nossl
95099480
- test-dns-darwinssl
@@ -9616,7 +9587,6 @@ buildvariants:
96169587
run_on: ubuntu1804-arm64-large
96179588
tasks:
96189589
- .compression !.snappy !.zstd
9619-
- debug-compile-scan-build
96209590
- debug-compile-no-align
96219591
- release-compile
96229592
- debug-compile-nosasl-nossl
@@ -9633,7 +9603,6 @@ buildvariants:
96339603
run_on: ubuntu1604-arm64-large
96349604
tasks:
96359605
- .compression !.snappy !.zstd
9636-
- debug-compile-scan-build
96379606
- debug-compile-no-align
96389607
- release-compile
96399608
batchtime: 1440

.evergreen/generated_configs/tasks.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,6 +3194,65 @@ tasks:
31943194
- func: fetch-det
31953195
- func: bootstrap-mongo-orchestration
31963196
- func: run-tests
3197+
- name: scan-build-macos-1014-clang
3198+
run_on: macos-1014
3199+
tags: [scan-build-matrix, macos-1014, clang]
3200+
disable: true
3201+
commands:
3202+
- func: scan-build
3203+
vars:
3204+
CC: clang
3205+
- func: upload scan artifacts
3206+
- name: scan-build-ubuntu1404-clang
3207+
run_on: ubuntu1404-large
3208+
tags: [scan-build-matrix, ubuntu1404, clang]
3209+
commands:
3210+
- func: scan-build
3211+
vars:
3212+
CC: clang
3213+
- func: upload scan artifacts
3214+
- name: scan-build-ubuntu1604-arm64-clang
3215+
run_on: ubuntu1604-arm64-large
3216+
tags: [scan-build-matrix, ubuntu1604-arm64, clang]
3217+
commands:
3218+
- func: scan-build
3219+
vars:
3220+
CC: clang
3221+
- func: upload scan artifacts
3222+
- name: scan-build-ubuntu1604-clang
3223+
run_on: ubuntu1604-large
3224+
tags: [scan-build-matrix, ubuntu1604, clang]
3225+
commands:
3226+
- func: scan-build
3227+
vars:
3228+
CC: clang
3229+
- func: upload scan artifacts
3230+
- name: scan-build-ubuntu1604-clang-i686
3231+
run_on: ubuntu1604-large
3232+
tags: [scan-build-matrix, ubuntu1604, clang, i686]
3233+
commands:
3234+
- func: scan-build
3235+
vars:
3236+
CC: clang
3237+
MARCH: i686
3238+
- func: upload scan artifacts
3239+
- name: scan-build-ubuntu1804-arm64-clang
3240+
run_on: ubuntu1804-arm64-large
3241+
tags: [scan-build-matrix, ubuntu1804-arm64, clang]
3242+
commands:
3243+
- func: scan-build
3244+
vars:
3245+
CC: clang
3246+
- func: upload scan artifacts
3247+
- name: scan-build-ubuntu1804-clang-i686
3248+
run_on: ubuntu1804-large
3249+
tags: [scan-build-matrix, ubuntu1804, clang, i686]
3250+
commands:
3251+
- func: scan-build
3252+
vars:
3253+
CC: clang
3254+
MARCH: i686
3255+
- func: upload scan artifacts
31973256
- name: std-c11-archlinux-clang-compile
31983257
run_on: archlinux-large
31993258
tags: [std-matrix, archlinux, clang, compile, std-c11]

.evergreen/generated_configs/variants.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ buildvariants:
6767
DEBUG: "ON"
6868
tasks:
6969
- name: .sasl-matrix-winssl
70+
- name: scan-build-matrix
71+
display_name: scan-build-matrix
72+
tasks:
73+
- name: .scan-build-matrix
7074
- name: std-matrix
7175
display_name: std-matrix
7276
tasks:

.evergreen/legacy_config_generator/evergreen_config_generator/functions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def shell_exec(script,
5656
working_dir=None,
5757
background=False,
5858
add_expansions_to_env=False,
59+
redirect_standard_error_to_output=False,
5960
):
6061
dedented = ''
6162
if errexit:
@@ -85,6 +86,9 @@ def shell_exec(script,
8586
if add_expansions_to_env:
8687
command['params']['add_expansions_to_env'] = True
8788

89+
if redirect_standard_error_to_output:
90+
command['params']['redirect_standard_error_to_output'] = True
91+
8892
command['params']['shell'] = 'bash'
8993
command['params']['script'] = dedented
9094
return command

.evergreen/legacy_config_generator/evergreen_config_lib/tasks.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,6 @@ def __init__(self, task_name, suffix_commands, orchestration=True, **kwargs):
184184
sanitize=['address'],
185185
EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF",
186186
SSL='OPENSSL'),
187-
SpecialTask('debug-compile-scan-build',
188-
tags=['clang', 'debug-compile', 'scan-build'],
189-
continue_on_err=True,
190-
ANALYZE='ON',
191-
CC='clang',
192-
suffix_commands=[
193-
func('upload scan artifacts'),
194-
shell_mongoc('''
195-
if find scan -name \*.html | grep -q html; then
196-
exit 123
197-
fi''')]),
198187
CompileTask('compile-tracing',
199188
TRACING='ON', CFLAGS='-Werror -Wno-cast-align'),
200189
CompileTask('release-compile',

.evergreen/legacy_config_generator/evergreen_config_lib/testazurekms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _create_tasks():
5151
AZUREKMS_CMD="tar xf testazurekms.tgz" \
5252
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
5353
echo "Untarring file ... end"
54-
''', test=False),
54+
''', test=False, add_expansions_to_env=True),
5555
shell_exec (r'''
5656
export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup}
5757
export AZUREKMS_VMNAME=${AZUREKMS_VMNAME}
@@ -69,7 +69,7 @@ def _create_tasks():
6969
pushd mongoc
7070
./.evergreen/scripts/compile-test-azurekms.sh
7171
popd
72-
''', test=False),
72+
''', test=False, add_expansions_to_env=True),
7373
shell_exec (r'''
7474
LD_LIBRARY_PATH=$PWD/install \
7575
MONGODB_URI='mongodb://localhost:27017' \

0 commit comments

Comments
 (0)