Skip to content

Commit 213b62f

Browse files
authored
Merge pull request swiftlang#1717 from ahoppen/ahoppen/cross-compile-lsp
Build sourcekit-lsp for multiple arches and lipo them
2 parents 1671025 + d232ba7 commit 213b62f

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

Utilities/build-script-helper.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,15 @@ def swiftpm_bin_path(swift_exec: str, swiftpm_args: List[str], additional_env: D
7070

7171
def get_build_target(swift_exec: str, args: argparse.Namespace, cross_compile: bool = False) -> str:
7272
"""Returns the target-triple of the current machine or for cross-compilation."""
73-
try:
74-
command = [swift_exec, '-print-target-info']
75-
if cross_compile:
76-
cross_compile_json = json.load(open(args.cross_compile_config))
77-
command += ['-target', cross_compile_json["target"]]
78-
target_info_json = subprocess.check_output(command, stderr=subprocess.PIPE, universal_newlines=True).strip()
79-
args.target_info = json.loads(target_info_json)
80-
if '-apple-macosx' in args.target_info["target"]["unversionedTriple"]:
81-
return args.target_info["target"]["unversionedTriple"]
82-
return args.target_info["target"]["triple"]
83-
except Exception as e:
84-
# Temporary fallback for Darwin.
85-
if platform.system() == 'Darwin':
86-
return 'x86_64-apple-macosx'
87-
else:
88-
fatal_error(str(e))
73+
command = [swift_exec, '-print-target-info']
74+
if cross_compile:
75+
cross_compile_json = json.load(open(args.cross_compile_config))
76+
command += ['-target', cross_compile_json["target"]]
77+
target_info_json = subprocess.check_output(command, stderr=subprocess.PIPE, universal_newlines=True).strip()
78+
args.target_info = json.loads(target_info_json)
79+
if '-apple-macosx' in args.target_info["target"]["unversionedTriple"]:
80+
return args.target_info["target"]["unversionedTriple"]
81+
return args.target_info["target"]["triple"]
8982

9083
# -----------------------------------------------------------------------------
9184
# Build SourceKit-LSP
@@ -144,7 +137,7 @@ def get_swiftpm_options(swift_exec: str, args: argparse.Namespace, suppress_verb
144137

145138
if args.cross_compile_host:
146139
if build_os.startswith('macosx') and args.cross_compile_host.startswith('macosx-'):
147-
swiftpm_args += ["--arch", "x86_64", "--arch", "arm64"]
140+
swiftpm_args += ["--arch", args.cross_compile_host[7:]]
148141
elif args.cross_compile_host.startswith('android-'):
149142
print('Cross-compiling for %s' % args.cross_compile_host)
150143
swiftpm_args += ['--destination', args.cross_compile_config]

0 commit comments

Comments
 (0)