Skip to content

Commit ac8b89a

Browse files
authored
Merge pull request #20082 from drodriguez/android-aarch64-build-script
2 parents 6f9bb8e + 555e085 commit ac8b89a

File tree

5 files changed

+43
-16
lines changed

5 files changed

+43
-16
lines changed

utils/build-script

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,14 @@ class BuildScriptInvocation(object):
250250
args.android_icu_uc is None or \
251251
args.android_icu_uc_include is None or \
252252
args.android_icu_i18n is None or \
253-
args.android_icu_i18n_include is None:
253+
args.android_icu_i18n_include is None or \
254+
args.android_icu_data is None:
254255
diagnostics.fatal(
255256
"when building for Android, --android-ndk, "
256257
"--android-ndk-version, --android-icu-uc, "
257258
"--android-icu-uc-include, --android-icu-i18n, "
258-
"and --android-icu-i18n-include must be specified")
259+
"--android-icu-i18n-include, and --android-icu-data "
260+
"must be specified")
259261

260262
@staticmethod
261263
def apply_default_arguments(toolchain, args):
@@ -292,8 +294,12 @@ class BuildScriptInvocation(object):
292294

293295
# Add optional stdlib-deployment-targets
294296
if args.android:
295-
args.stdlib_deployment_targets.append(
296-
StdlibDeploymentTarget.Android.armv7.name)
297+
if args.android_arch == "armv7":
298+
args.stdlib_deployment_targets.append(
299+
StdlibDeploymentTarget.Android.armv7.name)
300+
elif args.android_arch == "aarch64":
301+
args.stdlib_deployment_targets.append(
302+
StdlibDeploymentTarget.Android.aarch64.name)
297303

298304
# Infer platform flags from manually-specified configure targets.
299305
# This doesn't apply to Darwin platforms, as they are
@@ -687,14 +693,15 @@ class BuildScriptInvocation(object):
687693

688694
if args.android:
689695
impl_args += [
696+
"--android-arch", args.android_arch,
690697
"--android-ndk", args.android_ndk,
691698
"--android-api-level", args.android_api_level,
692-
"--android-ndk-gcc-version",
693-
args.android_ndk_gcc_version,
699+
"--android-ndk-gcc-version", args.android_ndk_gcc_version,
694700
"--android-icu-uc", args.android_icu_uc,
695701
"--android-icu-uc-include", args.android_icu_uc_include,
696702
"--android-icu-i18n", args.android_icu_i18n,
697703
"--android-icu-i18n-include", args.android_icu_i18n_include,
704+
"--android-icu-data", args.android_icu_data,
698705
]
699706
if args.android_deploy_device_path:
700707
impl_args += [

utils/build-script-impl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,13 @@ KNOWN_SETTINGS=(
235235
android-ndk "" "An absolute path to the NDK that will be used as a libc implementation for Android builds"
236236
android-api-level "" "The Android API level to target when building for Android. Currently only 21 or above is supported"
237237
android-ndk-gcc-version "" "The GCC version to use when building for Android. Currently only 4.9 is supported"
238-
android-icu-uc "" "Path to a directory containing libicuuc.so"
238+
android-icu-uc "" "Path to libicuuc.so"
239239
android-icu-uc-include "" "Path to a directory containing headers for libicuuc"
240-
android-icu-i18n "" "Path to a directory containing libicui18n.so"
240+
android-icu-i18n "" "Path to libicui18n.so"
241241
android-icu-i18n-include "" "Path to a directory containing headers libicui18n"
242+
android-icu-data "" "Path to libicudata.so"
242243
android-deploy-device-path "" "Path on an Android device to which built Swift stdlib products will be deployed"
244+
android-arch "armv7" "The Android target architecture when building for Android"
243245
check-args-only "" "set to check all arguments are known. Exit with status 0 if success, non zero otherwise"
244246
common-cmake-options "" "CMake options used for all targets, including LLVM/Clang"
245247
cmark-cmake-options "" "CMake options used for all cmark targets"
@@ -1638,6 +1640,9 @@ function common_cross_c_flags() {
16381640
android-armv7)
16391641
echo -n " -arch armv7"
16401642
;;
1643+
android-arm64)
1644+
echo -n " -arch aarch64"
1645+
;;
16411646
esac
16421647
}
16431648

@@ -2144,12 +2149,13 @@ for host in "${ALL_HOSTS[@]}"; do
21442149
-DSWIFT_ANDROID_NDK_PATH:STRING="${ANDROID_NDK}"
21452150
-DSWIFT_ANDROID_NDK_GCC_VERSION:STRING="${ANDROID_NDK_GCC_VERSION}"
21462151
-DSWIFT_ANDROID_API_LEVEL:STRING="${ANDROID_API_LEVEL}"
2147-
-DSWIFT_ANDROID_armv7_ICU_UC:STRING="${ANDROID_ICU_UC}"
2148-
-DSWIFT_ANDROID_armv7_ICU_UC_INCLUDE:STRING="${ANDROID_ICU_UC_INCLUDE}"
2149-
-DSWIFT_ANDROID_armv7_ICU_I18N:STRING="${ANDROID_ICU_I18N}"
2150-
-DSWIFT_ANDROID_armv7_ICU_I18N_INCLUDE:STRING="${ANDROID_ICU_I18N_INCLUDE}"
2151-
-DSWIFT_SDK_ANDROID_ARCHITECTURES:STRING="armv7"
2152+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC:STRING="${ANDROID_ICU_UC}"
2153+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC_INCLUDE:STRING="${ANDROID_ICU_UC_INCLUDE}"
2154+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_I18N:STRING="${ANDROID_ICU_I18N}"
2155+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_I18N_INCLUDE:STRING="${ANDROID_ICU_I18N_INCLUDE}"
2156+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_DATA:STRING="${ANDROID_ICU_DATA}"
21522157
-DSWIFT_ANDROID_DEPLOY_DEVICE_PATH:STRING="${ANDROID_DEPLOY_DEVICE_PATH}"
2158+
-DSWIFT_SDK_ANDROID_ARCHITECTURES:STRING="${ANDROID_ARCH}"
21532159
)
21542160
fi
21552161

utils/build_swift/driver_arguments.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,20 +901,29 @@ def create_argument_parser():
901901
'Swift')
902902

903903
option('--android-icu-uc', store_path,
904-
help='Path to a directory containing libicuuc.so')
904+
help='Path to libicuuc.so')
905905
option('--android-icu-uc-include', store_path,
906906
help='Path to a directory containing headers for libicuuc')
907907
option('--android-icu-i18n', store_path,
908-
help='Path to a directory containing libicui18n.so')
908+
help='Path to libicui18n.so')
909909
option('--android-icu-i18n-include', store_path,
910910
help='Path to a directory containing headers libicui18n')
911+
option('--android-icu-data', store_path,
912+
help='Path to libicudata.so')
911913
option('--android-deploy-device-path', store_path,
912914
default=android.adb.commands.DEVICE_TEMP_DIR,
913915
help='Path on an Android device to which built Swift stdlib '
914916
'products will be deployed. If running host tests, specify '
915917
'the "{}" directory.'.format(
916918
android.adb.commands.DEVICE_TEMP_DIR))
917919

920+
option('--android-arch', store,
921+
choices=['armv7', 'aarch64'],
922+
default='armv7',
923+
help='The Android target architecture when building for Android. '
924+
'Currently only armv7 and aarch64 are supported. '
925+
'%(default)s is the default.')
926+
918927
# -------------------------------------------------------------------------
919928
in_group('Unsupported options')
920929

utils/build_swift/tests/expected_options.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
'android_icu_i18n_include': None,
4646
'android_icu_uc': None,
4747
'android_icu_uc_include': None,
48+
'android_icu_data': None,
4849
'android_ndk': None,
4950
'android_ndk_gcc_version': '4.9',
51+
'android_arch': 'armv7',
5052
'assertions': True,
5153
'benchmark': False,
5254
'benchmark_num_o_iterations': 3,
@@ -486,6 +488,8 @@ class IgnoreOption(_BaseOption):
486488
choices=['none', 'apple']),
487489
ChoicesOption('--swift-analyze-code-coverage',
488490
choices=['false', 'not-merged', 'merged']),
491+
ChoicesOption('--android-arch',
492+
choices=['armv7', 'aarch64']),
489493

490494
StrOption('--android-api-level'),
491495
StrOption('--build-args'),
@@ -504,6 +508,7 @@ class IgnoreOption(_BaseOption):
504508
PathOption('--android-icu-i18n-include'),
505509
PathOption('--android-icu-uc'),
506510
PathOption('--android-icu-uc-include'),
511+
PathOption('--android-icu-data'),
507512
PathOption('--android-ndk'),
508513
PathOption('--build-subdir'),
509514
PathOption('--clang-profile-instr-use'),

utils/swift_build_support/swift_build_support/targets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class StdlibDeploymentTarget(object):
125125

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

128-
Android = Platform("android", archs=["armv7"])
128+
Android = Platform("android", archs=["armv7", "aarch64"])
129129

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

0 commit comments

Comments
 (0)