Skip to content

[build-script] Support for Android aarch64 #20082

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
Nov 27, 2018
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
19 changes: 13 additions & 6 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,14 @@ class BuildScriptInvocation(object):
args.android_icu_uc is None or \
args.android_icu_uc_include is None or \
args.android_icu_i18n is None or \
args.android_icu_i18n_include is None:
args.android_icu_i18n_include is None or \
args.android_icu_data is None:
diagnostics.fatal(
"when building for Android, --android-ndk, "
"--android-ndk-version, --android-icu-uc, "
"--android-icu-uc-include, --android-icu-i18n, "
"and --android-icu-i18n-include must be specified")
"--android-icu-i18n-include, and --android-icu-data "
"must be specified")

@staticmethod
def apply_default_arguments(toolchain, args):
Expand Down Expand Up @@ -292,8 +294,12 @@ class BuildScriptInvocation(object):

# Add optional stdlib-deployment-targets
if args.android:
args.stdlib_deployment_targets.append(
StdlibDeploymentTarget.Android.armv7.name)
if args.android_arch == "armv7":
args.stdlib_deployment_targets.append(
StdlibDeploymentTarget.Android.armv7.name)
elif args.android_arch == "aarch64":
args.stdlib_deployment_targets.append(
StdlibDeploymentTarget.Android.aarch64.name)

# Infer platform flags from manually-specified configure targets.
# This doesn't apply to Darwin platforms, as they are
Expand Down Expand Up @@ -683,14 +689,15 @@ class BuildScriptInvocation(object):

if args.android:
impl_args += [
"--android-arch", args.android_arch,
"--android-ndk", args.android_ndk,
"--android-api-level", args.android_api_level,
"--android-ndk-gcc-version",
args.android_ndk_gcc_version,
"--android-ndk-gcc-version", args.android_ndk_gcc_version,
"--android-icu-uc", args.android_icu_uc,
"--android-icu-uc-include", args.android_icu_uc_include,
"--android-icu-i18n", args.android_icu_i18n,
"--android-icu-i18n-include", args.android_icu_i18n_include,
"--android-icu-data", args.android_icu_data,
]
if args.android_deploy_device_path:
impl_args += [
Expand Down
20 changes: 13 additions & 7 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,13 @@ KNOWN_SETTINGS=(
android-ndk "" "An absolute path to the NDK that will be used as a libc implementation for Android builds"
android-api-level "" "The Android API level to target when building for Android. Currently only 21 or above is supported"
android-ndk-gcc-version "" "The GCC version to use when building for Android. Currently only 4.9 is supported"
android-icu-uc "" "Path to a directory containing libicuuc.so"
android-icu-uc "" "Path to libicuuc.so"
android-icu-uc-include "" "Path to a directory containing headers for libicuuc"
android-icu-i18n "" "Path to a directory containing libicui18n.so"
android-icu-i18n "" "Path to libicui18n.so"
android-icu-i18n-include "" "Path to a directory containing headers libicui18n"
android-icu-data "" "Path to libicudata.so"
android-deploy-device-path "" "Path on an Android device to which built Swift stdlib products will be deployed"
android-arch "armv7" "The Android target architecture when building for Android"
check-args-only "" "set to check all arguments are known. Exit with status 0 if success, non zero otherwise"
common-cmake-options "" "CMake options used for all targets, including LLVM/Clang"
cmark-cmake-options "" "CMake options used for all cmark targets"
Expand Down Expand Up @@ -1622,6 +1624,9 @@ function common_cross_c_flags() {
android-armv7)
echo -n " -arch armv7"
;;
android-arm64)
echo -n " -arch aarch64"
;;
esac
}

Expand Down Expand Up @@ -2093,12 +2098,13 @@ for host in "${ALL_HOSTS[@]}"; do
-DSWIFT_ANDROID_NDK_PATH:STRING="${ANDROID_NDK}"
-DSWIFT_ANDROID_NDK_GCC_VERSION:STRING="${ANDROID_NDK_GCC_VERSION}"
-DSWIFT_ANDROID_API_LEVEL:STRING="${ANDROID_API_LEVEL}"
-DSWIFT_ANDROID_armv7_ICU_UC:STRING="${ANDROID_ICU_UC}"
-DSWIFT_ANDROID_armv7_ICU_UC_INCLUDE:STRING="${ANDROID_ICU_UC_INCLUDE}"
-DSWIFT_ANDROID_armv7_ICU_I18N:STRING="${ANDROID_ICU_I18N}"
-DSWIFT_ANDROID_armv7_ICU_I18N_INCLUDE:STRING="${ANDROID_ICU_I18N_INCLUDE}"
-DSWIFT_SDK_ANDROID_ARCHITECTURES:STRING="armv7"
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC:STRING="${ANDROID_ICU_UC}"
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC_INCLUDE:STRING="${ANDROID_ICU_UC_INCLUDE}"
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_I18N:STRING="${ANDROID_ICU_I18N}"
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_I18N_INCLUDE:STRING="${ANDROID_ICU_I18N_INCLUDE}"
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_DATA:STRING="${ANDROID_ICU_DATA}"
-DSWIFT_ANDROID_DEPLOY_DEVICE_PATH:STRING="${ANDROID_DEPLOY_DEVICE_PATH}"
-DSWIFT_SDK_ANDROID_ARCHITECTURES:STRING="${ANDROID_ARCH}"
)
fi

Expand Down
13 changes: 11 additions & 2 deletions utils/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,20 +898,29 @@ def create_argument_parser():
'Swift')

option('--android-icu-uc', store_path,
help='Path to a directory containing libicuuc.so')
help='Path to libicuuc.so')
option('--android-icu-uc-include', store_path,
help='Path to a directory containing headers for libicuuc')
option('--android-icu-i18n', store_path,
help='Path to a directory containing libicui18n.so')
help='Path to libicui18n.so')
option('--android-icu-i18n-include', store_path,
help='Path to a directory containing headers libicui18n')
option('--android-icu-data', store_path,
help='Path to libicudata.so')
option('--android-deploy-device-path', store_path,
default=android.adb.commands.DEVICE_TEMP_DIR,
help='Path on an Android device to which built Swift stdlib '
'products will be deployed. If running host tests, specify '
'the "{}" directory.'.format(
android.adb.commands.DEVICE_TEMP_DIR))

option('--android-arch', store,
choices=['armv7', 'aarch64'],
default='armv7',
help='The Android target architecture when building for Android. '
'Currently only armv7 and aarch64 are supported. '
'%(default)s is the default.')

# -------------------------------------------------------------------------
in_group('Unsupported options')

Expand Down
5 changes: 5 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
'android_icu_i18n_include': None,
'android_icu_uc': None,
'android_icu_uc_include': None,
'android_icu_data': None,
'android_ndk': None,
'android_ndk_gcc_version': '4.9',
'android_arch': 'armv7',
'assertions': True,
'benchmark': False,
'benchmark_num_o_iterations': 3,
Expand Down Expand Up @@ -484,6 +486,8 @@ class IgnoreOption(_BaseOption):
choices=['none', 'apple']),
ChoicesOption('--swift-analyze-code-coverage',
choices=['false', 'not-merged', 'merged']),
ChoicesOption('--android-arch',
choices=['armv7', 'aarch64']),

StrOption('--android-api-level'),
StrOption('--build-args'),
Expand All @@ -502,6 +506,7 @@ class IgnoreOption(_BaseOption):
PathOption('--android-icu-i18n-include'),
PathOption('--android-icu-uc'),
PathOption('--android-icu-uc-include'),
PathOption('--android-icu-data'),
PathOption('--android-ndk'),
PathOption('--build-subdir'),
PathOption('--clang-profile-instr-use'),
Expand Down
2 changes: 1 addition & 1 deletion utils/swift_build_support/swift_build_support/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class StdlibDeploymentTarget(object):

Cygwin = Platform("cygwin", archs=["x86_64"])

Android = Platform("android", archs=["armv7"])
Android = Platform("android", archs=["armv7", "aarch64"])

Windows = Platform("windows", archs=["x86_64"])

Expand Down