|
27 | 27 | from . import swiftsyntax
|
28 | 28 | from . import xctest
|
29 | 29 | from .. import shell
|
| 30 | +from .. import targets |
30 | 31 |
|
31 | 32 |
|
32 | 33 | class SwiftFormat(product.Product):
|
@@ -57,23 +58,41 @@ def run_build_script_helper(self, action, host_target, additional_params=[]):
|
57 | 58 | script_path = os.path.join(
|
58 | 59 | self.source_dir, 'build-script-helper.py')
|
59 | 60 |
|
60 |
| - install_destdir = self.host_install_destdir(host_target) |
61 |
| - |
62 | 61 | helper_cmd = [
|
63 | 62 | script_path,
|
64 | 63 | action,
|
65 | 64 | '--toolchain', self.install_toolchain_path(host_target),
|
66 | 65 | '--configuration', self.configuration(),
|
67 | 66 | '--build-path', self.build_dir,
|
68 | 67 | '--multiroot-data-file', MULTIROOT_DATA_FILE_PATH,
|
69 |
| - # There might have been a Package.resolved created by other builds |
70 |
| - # or by the package being opened using Xcode. Discard that and |
71 |
| - # reset the dependencies to be local. |
72 |
| - '--update' |
73 | 68 | ]
|
74 |
| - helper_cmd.extend([ |
75 |
| - '--prefix', install_destdir + self.args.install_prefix |
76 |
| - ]) |
| 69 | + |
| 70 | + install_destdir = self.host_install_destdir(host_target) |
| 71 | + toolchain_path = self.native_toolchain_path(host_target) |
| 72 | + |
| 73 | + # Pass Cross compile host info unless we're testing. |
| 74 | + # It doesn't make sense to run tests of the cross compile host. |
| 75 | + if self.has_cross_compile_hosts() and action != 'test': |
| 76 | + if self.is_darwin_host(host_target): |
| 77 | + if len(self.args.cross_compile_hosts) != 1: |
| 78 | + raise RuntimeError("Cross-Compiling swift-format to multiple " + |
| 79 | + "targets is not supported") |
| 80 | + helper_cmd += ['--cross-compile-host', self.args.cross_compile_hosts[0]] |
| 81 | + elif self.is_cross_compile_target(host_target): |
| 82 | + helper_cmd.extend(['--cross-compile-host', host_target]) |
| 83 | + build_toolchain_path = install_destdir + self.args.install_prefix |
| 84 | + resource_dir = f'{build_toolchain_path}/lib/swift' |
| 85 | + cross_compile_config = targets.StdlibDeploymentTarget \ |
| 86 | + .get_target_for_name(host_target) \ |
| 87 | + .platform \ |
| 88 | + .swiftpm_config( |
| 89 | + self.args, |
| 90 | + output_dir=build_toolchain_path, |
| 91 | + swift_toolchain=toolchain_path, |
| 92 | + resource_path=resource_dir |
| 93 | + ) |
| 94 | + helper_cmd += ['--cross-compile-config', cross_compile_config] |
| 95 | + |
77 | 96 | if self.args.verbose_build:
|
78 | 97 | helper_cmd.append('--verbose')
|
79 | 98 | helper_cmd.extend(additional_params)
|
@@ -139,7 +158,12 @@ def should_install(self, host_target):
|
139 | 158 | return self.args.install_swiftformat
|
140 | 159 |
|
141 | 160 | def install(self, host_target):
|
142 |
| - self.run_build_script_helper('install', host_target) |
| 161 | + install_destdir = self.host_install_destdir(host_target) |
| 162 | + self.run_build_script_helper( |
| 163 | + 'install', |
| 164 | + host_target, |
| 165 | + additional_params=['--prefix', install_destdir + self.args.install_prefix] |
| 166 | + ) |
143 | 167 |
|
144 | 168 | @classmethod
|
145 | 169 | def get_dependencies(cls):
|
|
0 commit comments