Skip to content

[build-script] Cross-compile sourcekit-lsp for arm64 #59046

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
Jun 1, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def should_install(self, host_target):
def install(self, host_target):
pass

def has_cross_compile_hosts(self):
return False

@classmethod
def get_dependencies(cls):
return [cmark.CMark,
Expand Down Expand Up @@ -108,18 +111,24 @@ def run_build_script_helper(action, host_target, product, args,
if not clean:
helper_cmd.append('--no-clean')

if not product.is_darwin_host(
host_target) and product.is_cross_compile_target(host_target):
helper_cmd.extend(['--cross-compile-host', host_target])
build_toolchain_path = install_destdir + args.install_prefix
resource_dir = '%s/lib/swift' % build_toolchain_path
helper_cmd += [
'--cross-compile-config',
targets.StdlibDeploymentTarget.get_target_for_name(host_target).platform
.swiftpm_config(args, output_dir=build_toolchain_path,
swift_toolchain=toolchain_path,
resource_path=resource_dir)
]
# Pass Cross compile host info
if product.has_cross_compile_hosts():
if product.is_darwin_host(host_target):
if len(args.cross_compile_hosts) != 1:
raise RuntimeError("Cross-Compiling indexstoredb to multiple " +
"targets is not supported")
helper_cmd += ['--cross-compile-host', args.cross_compile_hosts[0]]
elif product.is_cross_compile_target(host_target):
helper_cmd.extend(['--cross-compile-host', host_target])
build_toolchain_path = install_destdir + args.install_prefix
resource_dir = '%s/lib/swift' % build_toolchain_path
helper_cmd += [
'--cross-compile-config',
targets.StdlibDeploymentTarget.get_target_for_name(host_target).platform
.swiftpm_config(args, output_dir=build_toolchain_path,
swift_toolchain=toolchain_path,
resource_path=resource_dir)
]

if action == 'install' and product.product_name() == "sourcekitlsp":
helper_cmd.extend([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ def is_cross_compile_target(self, host_target):
return self.args.cross_compile_hosts and \
host_target in self.args.cross_compile_hosts

def has_cross_compile_hosts(self):
return self.args.cross_compile_hosts

def generate_darwin_toolchain_file(self, platform, arch):
shell.makedirs(self.build_dir)
toolchain_file = os.path.join(self.build_dir, 'BuildScriptToolchain.cmake')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from . import llvm
from . import product
from . import swift
from . import swiftpm
from . import xctest
from .. import shell
from .. import targets
Expand Down Expand Up @@ -128,7 +127,7 @@ def run_build_script_helper(action, host_target, product, args):
'--lit-test-dir', lit_test_dir
]
# Pass Cross compile host info
if swiftpm.SwiftPM.has_cross_compile_hosts(args):
if product.has_cross_compile_hosts():
if product.is_darwin_host(host_target):
helper_cmd += ['--cross-compile-hosts']
for cross_compile_host in args.cross_compile_hosts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def run_bootstrap_script(self, action, host_target, additional_params=[]):
]

# Pass Cross compile host info
if self.has_cross_compile_hosts(self.args):
if self.has_cross_compile_hosts():
if self.is_darwin_host(host_target):
helper_cmd += ['--cross-compile-hosts']
for cross_compile_host in self.args.cross_compile_hosts:
Expand Down Expand Up @@ -133,10 +133,6 @@ def clean(self, host_target):
def should_install(self, host_target):
return self.args.install_swiftpm

@classmethod
def has_cross_compile_hosts(self, args):
return args.cross_compile_hosts

def install(self, host_target):
install_destdir = self.host_install_destdir(host_target)
install_prefix = install_destdir + self.args.install_prefix
Expand Down