Skip to content

Commit e296b6b

Browse files
committed
Add cmake-c-launcher and cmake-cxx-launcher flag to build-script
1 parent 34f8670 commit e296b6b

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

utils/build-script

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,14 @@ def main_preset():
10361036
"--distcc",
10371037
help="use distcc",
10381038
action=arguments.action.optional_bool)
1039+
parser.add_argument(
1040+
"--cmake-c-launcher",
1041+
help="the absolute path to set CMAKE_C_COMPILER_LAUNCHER",
1042+
metavar="PATH")
1043+
parser.add_argument(
1044+
"--cmake-cxx-launcher",
1045+
help="the absolute path to set CMAKE_CXX_COMPILER_LAUNCHER",
1046+
metavar="PATH")
10391047
parser.add_argument(
10401048
"-j", "--jobs",
10411049
help="the number of parallel build jobs to use",
@@ -1098,6 +1106,11 @@ def main_preset():
10981106

10991107
preset_args = migrate_swift_sdks(preset.format_args())
11001108

1109+
if args.distcc and (args.cmake_c_launcher or args.cmake_cxx_launcher):
1110+
diagnostics.fatal(
1111+
'--distcc can not be used with' +
1112+
' --cmake-c-launcher or --cmake-cxx-launcher')
1113+
11011114
build_script_args = [sys.argv[0]]
11021115
if args.dry_run:
11031116
build_script_args += ["--dry-run"]
@@ -1113,6 +1126,10 @@ def main_preset():
11131126
args.swiftsyntax_install_prefix]
11141127
if args.build_dir:
11151128
build_script_args += ["--build-dir", args.build_dir]
1129+
if args.cmake_c_launcher:
1130+
build_script_args += ["--cmake-c-launcher", args.cmake_c_launcher]
1131+
if args.cmake_cxx_launcher:
1132+
build_script_args += ["--cmake-cxx-launcher", args.cmake_cxx_launcher]
11161133

11171134
diagnostics.note('using preset "{}", which expands to \n\n{}\n'.format(
11181135
args.preset, shell.quote_command(build_script_args)))

utils/build_swift/driver_arguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ def create_argument_parser():
357357
option('--host-cxx', store_path(executable=True),
358358
help='the absolute path to CXX, the "clang++" compiler for the '
359359
'host platform. Default is auto detected.')
360+
option('--cmake-c-launcher', store_path(executable=True),
361+
help='the absolute path to set CMAKE_C_COMPILER_LAUNCHER')
362+
option('--cmake-cxx-launcher', store_path(executable=True),
363+
help='the absolute path to set CMAKE_CXX_COMPILER_LAUNCHER')
360364
option('--host-lipo', store_path(executable=True),
361365
help='the absolute path to lipo. Default is auto detected.')
362366
option('--host-libtool', store_path(executable=True),

utils/build_swift/tests/expected_options.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
'build_watchos_device': False,
9797
'build_watchos_simulator': False,
9898
'build_xctest': False,
99+
'cmake_c_launcher': None,
100+
'cmake_cxx_launcher': None,
99101
'clang_compiler_version': None,
100102
'clang_profile_instr_use': None,
101103
'clang_user_visible_version': defaults.CLANG_USER_VISIBLE_VERSION,
@@ -537,6 +539,8 @@ class IgnoreOption(_BaseOption):
537539
PathOption('--install-symroot'),
538540
PathOption('--install-destdir'),
539541
PathOption('--symbols-package'),
542+
PathOption('--cmake-c-launcher'),
543+
PathOption('--cmake-cxx-launcher'),
540544

541545
IntOption('--benchmark-num-o-iterations'),
542546
IntOption('--benchmark-num-onone-iterations'),

utils/swift_build_support/swift_build_support/cmake.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ def common_options(self):
107107
define("CMAKE_C_COMPILER_LAUNCHER:PATH", toolchain.distcc)
108108
define("CMAKE_CXX_COMPILER_LAUNCHER:PATH", toolchain.distcc)
109109

110+
if args.cmake_c_launcher:
111+
define("CMAKE_C_COMPILER_LAUNCHER:PATH", args.cmake_c_launcher)
112+
if args.cmake_cxx_launcher:
113+
define("CMAKE_CXX_COMPILER_LAUNCHER:PATH", args.cmake_cxx_launcher)
114+
110115
define("CMAKE_C_COMPILER:PATH", toolchain.cc)
111116
define("CMAKE_CXX_COMPILER:PATH", toolchain.cxx)
112117
define("CMAKE_LIBTOOL:PATH", toolchain.libtool)

utils/swift_build_support/tests/test_cmake.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def default_args(self):
3939
export_compile_commands=False,
4040
distcc=False,
4141
cmake_generator="Ninja",
42+
cmake_c_launcher=None,
43+
cmake_cxx_launcher=None,
4244
clang_compiler_version=None,
4345
clang_user_visible_version=None,
4446
build_jobs=8,
@@ -212,6 +214,23 @@ def test_common_options_distcc(self):
212214
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
213215
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
214216

217+
def test_common_options_launcher(self):
218+
args = self.default_args()
219+
cmake_c_launcher = "/path/to/c_launcher"
220+
cmake_cxx_launcher = "/path/to/cxx_launcher"
221+
args.cmake_c_launcher = cmake_c_launcher
222+
args.cmake_cxx_launcher = cmake_cxx_launcher
223+
cmake = self.cmake(args)
224+
self.assertEqual(
225+
list(cmake.common_options()),
226+
["-G", "Ninja",
227+
"-DCMAKE_C_COMPILER_LAUNCHER:PATH=" + cmake_c_launcher,
228+
"-DCMAKE_CXX_COMPILER_LAUNCHER:PATH=" + cmake_cxx_launcher,
229+
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
230+
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
231+
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
232+
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
233+
215234
def test_common_options_xcode(self):
216235
args = self.default_args()
217236
args.cmake_generator = 'Xcode'

0 commit comments

Comments
 (0)