Skip to content

Commit fb7b717

Browse files
committed
Merge pull request #2146 from apple/buildscript-extra-cmake-vars
[utils/build-script] Introduce '--extra-cmake-vars' option
2 parents 4fd9f81 + abecb2f commit fb7b717

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

utils/build-script

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,13 @@ the number of parallel build jobs to use""",
700700
a '\'"""),
701701
action="append", dest="extra_swift_args", default=[])
702702

703+
parser.add_argument(
704+
"--extra-cmake-options", help=textwrap.dedent("""
705+
Pass through extra options to CMake in the form of comma separated options
706+
'-DCMAKE_VAR1=YES,-DCMAKE_VAR2=/tmp'. Can be called multiple times to add
707+
multiple such options."""),
708+
action="append", dest="extra_cmake_options", default=[])
709+
703710
parser.add_argument(
704711
"build_script_impl_args",
705712
help="",
@@ -1108,6 +1115,13 @@ the number of parallel build jobs to use""",
11081115
"--extra-swift-args",
11091116
";".join(args.extra_swift_args)]
11101117

1118+
# If we have extra_cmake_args, combine all of them together and then add
1119+
# them as one command.
1120+
if args.extra_cmake_options:
1121+
build_script_impl_args += [
1122+
"--extra-cmake-options",
1123+
",".join(args.extra_cmake_options)]
1124+
11111125
build_script_impl_args += args.build_script_impl_args
11121126

11131127
# Unset environment variables that might affect how tools behave.

utils/build-script-impl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ KNOWN_SETTINGS=(
191191
darwin-deployment-version-tvos "9.0" "minimum deployment target version for tvOS"
192192
darwin-deployment-version-watchos "2.0" "minimum deployment target version for watchOS"
193193

194+
extra-cmake-options "" "Extra options to pass to CMake for all targets"
194195
extra-swift-args "" "Extra arguments to pass to swift modules which match regex. Assumed to be a flattened cmake list consisting of [module_regexp, args, module_regexp, args, ...]"
195196
sil-verify-all "0" "If enabled, run the SIL verifier after each transform when building Swift files during this build process"
196197
swift-enable-ast-verifier "1" "If enabled, and the assertions are enabled, the built Swift compiler will run the AST verifier every time it is invoked"
@@ -1206,6 +1207,16 @@ if [[ "${EXPORT_COMPILE_COMMANDS}" ]] ; then
12061207
)
12071208
fi
12081209

1210+
if [[ "${EXTRA_CMAKE_OPTIONS}" ]] ; then
1211+
for cmake_opt in $(echo "${EXTRA_CMAKE_OPTIONS}" | tr "," "\n")
1212+
do
1213+
COMMON_CMAKE_OPTIONS=(
1214+
"${COMMON_CMAKE_OPTIONS[@]}"
1215+
"${cmake_opt}"
1216+
)
1217+
done
1218+
fi
1219+
12091220
if [[ "${DISTCC}" ]] ; then
12101221
# On some platforms, 'pump' may be unrelated to distcc, in which case it's
12111222
# called 'distcc-pump'.

0 commit comments

Comments
 (0)