in Utilities/build-script-helper.py [0:0]
def handle_invocation(swift_exec, args):
swiftpm_args = get_swiftpm_options(args)
env = os.environ
# Set the toolchain used in tests at runtime
env['SOURCEKIT_TOOLCHAIN_PATH'] = args.toolchain
env['INDEXSTOREDB_TOOLCHAIN_BIN_PATH'] = args.toolchain
# Use local dependencies (i.e. checked out next sourcekit-lsp).
if not args.no_local_deps:
env['SWIFTCI_USE_LOCAL_DEPS'] = "1"
if args.ninja_bin:
env['NINJA_BIN'] = args.ninja_bin
if args.sanitize and 'address' in args.sanitize:
# Workaround reports in Foundation: https://bugs.swift.org/browse/SR-12551
env['ASAN_OPTIONS'] = 'detect_leaks=false'
if args.sanitize and 'undefined' in args.sanitize:
supp = os.path.join(args.package_path, 'Utilities', 'ubsan_supressions.supp')
env['UBSAN_OPTIONS'] = 'halt_on_error=true,suppressions=%s' % supp
if args.sanitize and 'thread' in args.sanitize:
env['TSAN_OPTIONS'] = 'halt_on_error=true'
print('Cleaning ' + args.build_path)
shutil.rmtree(args.build_path, ignore_errors=True)
env['SWIFT_EXEC'] = '%sc' % (swift_exec)
if args.action == 'build':
swiftpm('build', swift_exec, swiftpm_args, env)
elif args.action == 'test':
if not args.skip_long_tests:
env['SOURCEKIT_LSP_ENABLE_LONG_TESTS'] = '1'
bin_path = swiftpm_bin_path(swift_exec, swiftpm_args, env)
tests = os.path.join(bin_path, 'sk-tests')
print('Cleaning ' + tests)
shutil.rmtree(tests, ignore_errors=True)
test_args = swiftpm_args
# Running the tests concurrently doesn't work with glibc 2.24 because of a
# bug with posix_spawn called from Foundation, so it'll need to be disabled
# or fixed when used there, according to @benlangmuir.
test_args += ['--parallel']
swiftpm('test', swift_exec, test_args, env)
elif args.action == 'install':
bin_path = swiftpm_bin_path(swift_exec, swiftpm_args, env)
swiftpm_args += ['-Xswiftc', '-no-toolchain-stdlib-rpath']
swiftpm('build', swift_exec, swiftpm_args, env)
if not args.install_prefixes:
args.install_prefixes = [args.toolchain]
install(bin_path, args.install_prefixes, args.toolchain)
else:
assert False, 'unknown action \'{}\''.format(args.action)