Skip to content

[Build Script Helper] Setup environment variables for the specified toolchain's executables #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Utilities/build-script-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import subprocess
import sys

driver_tools = ['swift', 'swift-frontend', 'ld', 'libtool', 'clang',
'swift-autolink-extract', 'lldb', 'dwarfdump', 'swift-help']

def swiftpm(action, swift_exec, swiftpm_args, env=None):
cmd = [swift_exec, action] + swiftpm_args
print(' '.join(cmd))
Expand Down Expand Up @@ -91,9 +94,11 @@ def should_test_parallel():
return True


def handle_invocation(swift_exec, swift_frontend_exec, args):
def handle_invocation(toolchain_bin, args):
swiftpm_args = get_swiftpm_options(args)

swift_exec = os.path.join(toolchain_bin, 'swift')

env = os.environ
# Use local dependencies (i.e. checked out next to swift-driver).
if not args.no_local_deps:
Expand All @@ -108,7 +113,8 @@ def handle_invocation(swift_exec, swift_frontend_exec, args):
if args.action == 'build':
swiftpm('build', swift_exec, swiftpm_args, env)
elif args.action == 'test':
env['SWIFT_DRIVER_SWIFT_FRONTEND_EXEC'] = '%s' % (swift_frontend_exec)
for tool in driver_tools:
env['SWIFT_DRIVER_' + tool.upper().replace('-','_') + '_EXEC'] = '%s' % (os.path.join(toolchain_bin, tool))
env['SWIFT_EXEC'] = '%sc' % (swift_exec)
test_args = swiftpm_args
if should_test_parallel():
Expand Down Expand Up @@ -151,13 +157,11 @@ def add_common_args(parser):
args.toolchain = os.path.abspath(args.toolchain)

if args.toolchain:
swift_exec = os.path.join(args.toolchain, 'bin', 'swift')
swift_frontend_exec = os.path.join(args.toolchain, 'bin', 'swift-frontend')
toolchain_bin = os.path.join(args.toolchain, 'bin')
else:
swift_exec = 'swift'
swift_frontend_exec = 'swift-frontend'
toolchain_bin = ''

handle_invocation(swift_exec, swift_frontend_exec, args)
handle_invocation(toolchain_bin, args)

if __name__ == '__main__':
main()