|
9 | 9 | import subprocess |
10 | 10 | import sys |
11 | 11 |
|
12 | | -driver_tools = ['swift', 'swift-frontend', 'ld', 'libtool', 'clang', |
13 | | - 'swift-autolink-extract', 'lldb', 'dwarfdump', 'swift-help'] |
| 12 | +# Tools constructed as a part of the a development build toolchain |
| 13 | +driver_toolchain_tools = ['swift', 'swift-frontend', 'clang', 'swift-help'] |
| 14 | + |
| 15 | +def call_output(cmd, cwd=None, stderr=False, verbose=False): |
| 16 | + """Calls a subprocess for its return data.""" |
| 17 | + if verbose: |
| 18 | + print(' '.join(cmd)) |
| 19 | + try: |
| 20 | + return subprocess.check_output(cmd, cwd=cwd, stderr=stderr, universal_newlines=True).strip() |
| 21 | + except Exception as e: |
| 22 | + if not verbose: |
| 23 | + print(' '.join(cmd)) |
| 24 | + error(str(e)) |
14 | 25 |
|
15 | 26 | def swiftpm(action, swift_exec, swiftpm_args, env=None): |
16 | 27 | cmd = [swift_exec, action] + swiftpm_args |
@@ -107,13 +118,16 @@ def handle_invocation(toolchain_bin, args): |
107 | 118 | if args.ninja_bin: |
108 | 119 | env['NINJA_BIN'] = args.ninja_bin |
109 | 120 |
|
| 121 | + if args.sysroot: |
| 122 | + env['SDKROOT'] = args.sysroot |
| 123 | + |
110 | 124 | print('Cleaning ' + args.build_path) |
111 | 125 | shutil.rmtree(args.build_path, ignore_errors=True) |
112 | 126 |
|
113 | 127 | if args.action == 'build': |
114 | 128 | swiftpm('build', swift_exec, swiftpm_args, env) |
115 | 129 | elif args.action == 'test': |
116 | | - for tool in driver_tools: |
| 130 | + for tool in driver_toolchain_tools: |
117 | 131 | env['SWIFT_DRIVER_' + tool.upper().replace('-','_') + '_EXEC'] = '%s' % (os.path.join(toolchain_bin, tool)) |
118 | 132 | env['SWIFT_EXEC'] = '%sc' % (swift_exec) |
119 | 133 | test_args = swiftpm_args |
@@ -156,6 +170,11 @@ def add_common_args(parser): |
156 | 170 | args.build_path = os.path.abspath(args.build_path) |
157 | 171 | args.toolchain = os.path.abspath(args.toolchain) |
158 | 172 |
|
| 173 | + if platform.system() == 'Darwin': |
| 174 | + args.sysroot = call_output(["xcrun", "--sdk", "macosx", "--show-sdk-path"], verbose=args.verbose) |
| 175 | + else: |
| 176 | + args.sysroot = None |
| 177 | + |
159 | 178 | if args.toolchain: |
160 | 179 | toolchain_bin = os.path.join(args.toolchain, 'bin') |
161 | 180 | else: |
|
0 commit comments