Skip to content

Commit f4cf41e

Browse files
committed
Add ability to build sourcekit-lsp in a unified build
1 parent 5845e68 commit f4cf41e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Utilities/build-script-helper.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def get_swiftpm_options(swift_exec: str, args: argparse.Namespace) -> List[str]:
7373
'--configuration', args.configuration,
7474
]
7575

76+
if args.multiroot_data_file:
77+
swiftpm_args += ['--multiroot-data-file', args.multiroot_data_file]
78+
7679
if args.verbose:
7780
swiftpm_args += ['--verbose']
7881

@@ -157,13 +160,13 @@ def get_swiftpm_environment_variables(swift_exec: str, args: argparse.Namespace)
157160
return env
158161

159162

160-
def build(swift_exec: str, args: argparse.Namespace) -> None:
163+
def build_single_product(product: str, swift_exec: str, args: argparse.Namespace) -> None:
161164
"""
162165
Build one product in the package
163166
"""
164167
swiftpm_args = get_swiftpm_options(swift_exec, args)
165168
env = get_swiftpm_environment_variables(swift_exec, args)
166-
cmd = [swift_exec, 'build'] + swiftpm_args
169+
cmd = [swift_exec, 'build', '--product', product] + swiftpm_args
167170
check_call(cmd, env=env, verbose=args.verbose)
168171

169172

@@ -215,7 +218,11 @@ def handle_invocation(swift_exec: str, args: argparse.Namespace) -> None:
215218
Depending on the action in 'args', build the package, installs the package or run tests.
216219
"""
217220
if args.action == 'build':
218-
build(swift_exec, args)
221+
# These products are listed in dependency order. Lower-level targets are listed first.
222+
products = ["LSPBindings", "_SourceKitLSP", "sourcekit-lsp"]
223+
# Build in reverse dependency order so we can build lower-level targets in parallel.
224+
for product in reversed(products):
225+
build_single_product(product, swift_exec, args)
219226
elif args.action == 'test':
220227
run_tests(swift_exec, args)
221228
elif args.action == 'install':
@@ -243,6 +250,7 @@ def add_common_args(parser: argparse.ArgumentParser) -> None:
243250
parser.add_argument('--verbose', '-v', action='store_true', help='enable verbose output')
244251
parser.add_argument('--cross-compile-host', help='cross-compile for another host instead')
245252
parser.add_argument('--cross-compile-config', help='an SPM JSON destination file containing Swift cross-compilation flags')
253+
parser.add_argument('--multiroot-data-file', help='path to an Xcode workspace to create a unified build of all of Swift\'s SwiftPM projects')
246254

247255
if sys.version_info >= (3, 7, 0):
248256
subparsers = parser.add_subparsers(title='subcommands', dest='action', required=True, metavar='action')

0 commit comments

Comments
 (0)