termux-packages/packages/swift/swift-build-script.patch

91 lines
4.6 KiB
Diff
Raw Normal View History

diff --git a/swift/utils/build-script b/swift/utils/build-script
index b1d060328bc..218c9215260 100755
--- a/swift/utils/build-script
+++ b/swift/utils/build-script
@@ -221,7 +221,11 @@ class BuildScriptInvocation(object):
android_tgts = [tgt for tgt in args.stdlib_deployment_targets
if StdlibDeploymentTarget.Android.contains(tgt)]
if not args.android and len(android_tgts) > 0:
- args.android = True
+ # If building natively on an Android host, avoid the NDK
+ # cross-compilation configuration.
+ if not StdlibDeploymentTarget.Android.contains(StdlibDeploymentTarget
+ .host_target().name):
+ args.android = True
args.build_android = False
# Include the Darwin supported architectures in the CMake options.
@@ -572,6 +576,10 @@ class BuildScriptInvocation(object):
"--android-icu-i18n-include", args.android_icu_i18n_include,
"--android-icu-data", args.android_icu_data,
]
+ # If building natively on an Android host, only pass the API level.
+ if StdlibDeploymentTarget.Android.contains(StdlibDeploymentTarget
+ .host_target().name):
+ impl_args += ["--android-api-level", args.android_api_level]
if args.android_deploy_device_path:
impl_args += [
"--android-deploy-device-path",
@@ -799,8 +807,7 @@
self._execute_install_action(host_target, product_class)
# Non-build-script-impl products...
- # Note: currently only supports building for the host.
- for host_target in [self.args.host_target]:
+ for host_target in [tgt.name for tgt in all_hosts if StdlibDeploymentTarget.Android.contains(tgt.name)]:
for product_class in product_classes:
if product_class.is_build_script_impl_product():
continue
diff --git a/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py b/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py
index 475483618f1..2bea230012b 100644
--- a/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py
+++ b/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py
@@ -31,8 +31,11 @@ class SwiftPM(product.Product):
def run_bootstrap_script(self, action, host_target, additional_params=[]):
script_path = os.path.join(
self.source_dir, 'Utilities', 'new-bootstrap')
- toolchain_path = self.install_toolchain_path()
- swiftc = os.path.join(toolchain_path, "usr", "bin", "swiftc")
+ if os.getenv("HOST_SWIFTC"):
+ swiftc = os.getenv("HOST_SWIFTC")
+ else:
+ toolchain_path = self.install_toolchain_path()
+ swiftc = os.path.join(toolchain_path, "bin", "swiftc")
# FIXME: We require llbuild build directory in order to build. Is
# there a better way to get this?
diff --git a/swift/utils/swift_build_support/swift_build_support/targets.py b/swift/utils/swift_build_support/swift_build_support/targets.py
index 5e4f30ef194..16ef23f40da 100644
--- a/swift/utils/swift_build_support/swift_build_support/targets.py
+++ b/swift/utils/swift_build_support/swift_build_support/targets.py
@@ -280,4 +280,6 @@ def toolchain_path(install_destdir, install_prefix):
if platform.system() == 'Darwin':
# The prefix is an absolute path, so concatenate without os.path.
built_toolchain_path += darwin_toolchain_prefix(install_prefix)
+ else:
+ built_toolchain_path += install_prefix
return built_toolchain_path
diff --git a/swift/utils/swift_build_support/swift_build_support/which.py b/swift/utils/swift_build_support/swift_build_support/which.py
index 8b329cc95cc..14df9d0aff0 100644
--- a/swift/utils/swift_build_support/swift_build_support/which.py
+++ b/swift/utils/swift_build_support/swift_build_support/which.py
@@ -17,6 +17,7 @@
# ----------------------------------------------------------------------------
from __future__ import absolute_import
+import os
from . import cache_util
from . import shell
@@ -34,7 +35,9 @@ def which(cmd):
We provide our own implementation because shutil.which() has not
been backported to Python 2.7, which we support.
"""
- out = shell.capture(['which', cmd],
+
+ which = 'which' if 'ANDROID_DATA' not in os.environ else '/system/bin/which'
+ out = shell.capture([which, cmd],
dry_run=False, echo=False,
optional=True, stderr=shell.DEVNULL)
if out is None: