Skip to content

Build sourcekit-lsp for multiple arches and lipo them #1717

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
Oct 11, 2024
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
27 changes: 10 additions & 17 deletions Utilities/build-script-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,15 @@ def swiftpm_bin_path(swift_exec: str, swiftpm_args: List[str], additional_env: D

def get_build_target(swift_exec: str, args: argparse.Namespace, cross_compile: bool = False) -> str:
"""Returns the target-triple of the current machine or for cross-compilation."""
try:
command = [swift_exec, '-print-target-info']
if cross_compile:
cross_compile_json = json.load(open(args.cross_compile_config))
command += ['-target', cross_compile_json["target"]]
target_info_json = subprocess.check_output(command, stderr=subprocess.PIPE, universal_newlines=True).strip()
args.target_info = json.loads(target_info_json)
if '-apple-macosx' in args.target_info["target"]["unversionedTriple"]:
return args.target_info["target"]["unversionedTriple"]
return args.target_info["target"]["triple"]
except Exception as e:
# Temporary fallback for Darwin.
if platform.system() == 'Darwin':
return 'x86_64-apple-macosx'
else:
fatal_error(str(e))
command = [swift_exec, '-print-target-info']
if cross_compile:
cross_compile_json = json.load(open(args.cross_compile_config))
command += ['-target', cross_compile_json["target"]]
target_info_json = subprocess.check_output(command, stderr=subprocess.PIPE, universal_newlines=True).strip()
args.target_info = json.loads(target_info_json)
if '-apple-macosx' in args.target_info["target"]["unversionedTriple"]:
return args.target_info["target"]["unversionedTriple"]
return args.target_info["target"]["triple"]

# -----------------------------------------------------------------------------
# Build SourceKit-LSP
Expand Down Expand Up @@ -144,7 +137,7 @@ def get_swiftpm_options(swift_exec: str, args: argparse.Namespace, suppress_verb

if args.cross_compile_host:
if build_os.startswith('macosx') and args.cross_compile_host.startswith('macosx-'):
swiftpm_args += ["--arch", "x86_64", "--arch", "arm64"]
swiftpm_args += ["--arch", args.cross_compile_host[7:]]
elif args.cross_compile_host.startswith('android-'):
print('Cross-compiling for %s' % args.cross_compile_host)
swiftpm_args += ['--destination', args.cross_compile_config]
Expand Down