Skip to content

Commit 9ebc8a3

Browse files
committed
[utils/build-script] Introduce '--extra-cmake-vars' to allow setting any CMake veriables when configuring the targets.
1 parent 239b71c commit 9ebc8a3

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-vars", help=textwrap.dedent("""
705+
Pass through extra variables to CMake in the form of comma separated vars
706+
'CMAKE_VAR1=YES,CMAKE_VAR2=/tmp'. Can be called multiple times to add
707+
multiple such vars."""),
708+
action="append", dest="extra_cmake_vars", 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_vars:
1121+
build_script_impl_args += [
1122+
"--extra-cmake-vars",
1123+
",".join(args.extra_cmake_vars)]
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
@@ -190,6 +190,7 @@ KNOWN_SETTINGS=(
190190
darwin-deployment-version-tvos "9.0" "minimum deployment target version for tvOS"
191191
darwin-deployment-version-watchos "2.0" "minimum deployment target version for watchOS"
192192

193+
extra-cmake-vars "" "Extra variables to pass to CMake for all targets"
193194
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, ...]"
194195
sil-verify-all "0" "If enabled, run the SIL verifier after each transform when building Swift files during this build process"
195196
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"
@@ -1197,6 +1198,16 @@ if [[ "${EXPORT_COMPILE_COMMANDS}" ]] ; then
11971198
)
11981199
fi
11991200

1201+
if [[ "${EXTRA_CMAKE_VARS}" ]] ; then
1202+
for cmake_var in $(echo "${EXTRA_CMAKE_VARS}" | tr "," "\n")
1203+
do
1204+
COMMON_CMAKE_OPTIONS=(
1205+
"${COMMON_CMAKE_OPTIONS[@]}"
1206+
"-D${cmake_var}"
1207+
)
1208+
done
1209+
fi
1210+
12001211
if [[ "${DISTCC}" ]] ; then
12011212
# On some platforms, 'pump' may be unrelated to distcc, in which case it's
12021213
# called 'distcc-pump'.

0 commit comments

Comments
 (0)