Skip to content

Commit a66e92b

Browse files
committed
[build-script] Accept --ninja-bin and sync with sourcekit's build-script-helper
For now, just thread ninja_bin through as an environment variable. Future commits will make use of this during testing. Also pass the toolchain path and remove unnecessary differences with the sourcekit-lsp build-script-helper script.
1 parent 15a961b commit a66e92b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Utilities/build-script-helper.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def get_swiftpm_options(args):
2626
if platform.system() != 'Darwin':
2727
swiftpm_args += [
2828
# Dispatch headers
29-
'-Xcxx', '-I', '-Xcxx', os.path.join(args.toolchain, 'usr', 'lib', 'swift'),
29+
'-Xcxx', '-I', '-Xcxx',
30+
os.path.join(args.toolchain, 'usr', 'lib', 'swift'),
3031
]
3132

3233
return swiftpm_args
@@ -36,6 +37,7 @@ def main():
3637
def add_common_args(parser):
3738
parser.add_argument('--package-path', metavar='PATH', help='directory of the package to build', default='.')
3839
parser.add_argument('--toolchain', required=True, metavar='PATH', help='build using the toolchain at PATH')
40+
parser.add_argument('--ninja-bin', metavar='PATH', help='ninja binary to use for testing')
3941
parser.add_argument('--build-path', metavar='PATH', default='.build', help='build in the given path')
4042
parser.add_argument('--configuration', '-c', default='debug', help='build using configuration (release|debug)')
4143
parser.add_argument('--verbose', '-v', action='store_true', help='enable verbose output')
@@ -61,12 +63,19 @@ def add_common_args(parser):
6163

6264
swiftpm_args = get_swiftpm_options(args)
6365

66+
env = os.environ
67+
# Set the toolchain used in tests at runtime
68+
env['INDEXSTOREDB_TOOLCHAIN_PATH'] = args.toolchain
69+
70+
if args.ninja_bin:
71+
env['NINJA_BIN'] = args.ninja_bin
72+
6473
if args.action == 'build':
65-
swiftpm('build', swift_exec, swiftpm_args)
74+
swiftpm('build', swift_exec, swiftpm_args, env)
6675
elif args.action == 'test':
67-
swiftpm('test', swift_exec, swiftpm_args)
76+
swiftpm('test', swift_exec, swiftpm_args, env)
6877
else:
6978
assert False, 'unknown action \'{}\''.format(args.action)
7079

7180
if __name__ == '__main__':
72-
main()
81+
main()

0 commit comments

Comments
 (0)