Skip to content

Commit 555e085

Browse files
committed
[build-script] Support for Android aarch64
Support for Android aarch64 in many parts of the build-script. Most of the changes are reuse variables/parameters that already existed for Android ARMv7. There is also a new parameter to specify the ICU data library, which is used by #19503. With this one can build either armv7 or aarch64, since building both at the same time requires more changes like #19432 (and probably more work to support two set of paths).
1 parent c3a9498 commit 555e085

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
@@ -683,14 +689,15 @@ class BuildScriptInvocation(object):
683689

684690
if args.android:
685691
impl_args += [
692+
"--android-arch", args.android_arch,
686693
"--android-ndk", args.android_ndk,
687694
"--android-api-level", args.android_api_level,
688-
"--android-ndk-gcc-version",
689-
args.android_ndk_gcc_version,
695+
"--android-ndk-gcc-version", args.android_ndk_gcc_version,
690696
"--android-icu-uc", args.android_icu_uc,
691697
"--android-icu-uc-include", args.android_icu_uc_include,
692698
"--android-icu-i18n", args.android_icu_i18n,
693699
"--android-icu-i18n-include", args.android_icu_i18n_include,
700+
"--android-icu-data", args.android_icu_data,
694701
]
695702
if args.android_deploy_device_path:
696703
impl_args += [

utils/build-script-impl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,13 @@ KNOWN_SETTINGS=(
229229
android-ndk "" "An absolute path to the NDK that will be used as a libc implementation for Android builds"
230230
android-api-level "" "The Android API level to target when building for Android. Currently only 21 or above is supported"
231231
android-ndk-gcc-version "" "The GCC version to use when building for Android. Currently only 4.9 is supported"
232-
android-icu-uc "" "Path to a directory containing libicuuc.so"
232+
android-icu-uc "" "Path to libicuuc.so"
233233
android-icu-uc-include "" "Path to a directory containing headers for libicuuc"
234-
android-icu-i18n "" "Path to a directory containing libicui18n.so"
234+
android-icu-i18n "" "Path to libicui18n.so"
235235
android-icu-i18n-include "" "Path to a directory containing headers libicui18n"
236+
android-icu-data "" "Path to libicudata.so"
236237
android-deploy-device-path "" "Path on an Android device to which built Swift stdlib products will be deployed"
238+
android-arch "armv7" "The Android target architecture when building for Android"
237239
check-args-only "" "set to check all arguments are known. Exit with status 0 if success, non zero otherwise"
238240
common-cmake-options "" "CMake options used for all targets, including LLVM/Clang"
239241
cmark-cmake-options "" "CMake options used for all cmark targets"
@@ -1622,6 +1624,9 @@ function common_cross_c_flags() {
16221624
android-armv7)
16231625
echo -n " -arch armv7"
16241626
;;
1627+
android-arm64)
1628+
echo -n " -arch aarch64"
1629+
;;
16251630
esac
16261631
}
16271632

@@ -2093,12 +2098,13 @@ for host in "${ALL_HOSTS[@]}"; do
20932098
-DSWIFT_ANDROID_NDK_PATH:STRING="${ANDROID_NDK}"
20942099
-DSWIFT_ANDROID_NDK_GCC_VERSION:STRING="${ANDROID_NDK_GCC_VERSION}"
20952100
-DSWIFT_ANDROID_API_LEVEL:STRING="${ANDROID_API_LEVEL}"
2096-
-DSWIFT_ANDROID_armv7_ICU_UC:STRING="${ANDROID_ICU_UC}"
2097-
-DSWIFT_ANDROID_armv7_ICU_UC_INCLUDE:STRING="${ANDROID_ICU_UC_INCLUDE}"
2098-
-DSWIFT_ANDROID_armv7_ICU_I18N:STRING="${ANDROID_ICU_I18N}"
2099-
-DSWIFT_ANDROID_armv7_ICU_I18N_INCLUDE:STRING="${ANDROID_ICU_I18N_INCLUDE}"
2100-
-DSWIFT_SDK_ANDROID_ARCHITECTURES:STRING="armv7"
2101+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC:STRING="${ANDROID_ICU_UC}"
2102+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC_INCLUDE:STRING="${ANDROID_ICU_UC_INCLUDE}"
2103+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_I18N:STRING="${ANDROID_ICU_I18N}"
2104+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_I18N_INCLUDE:STRING="${ANDROID_ICU_I18N_INCLUDE}"
2105+
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_DATA:STRING="${ANDROID_ICU_DATA}"
21012106
-DSWIFT_ANDROID_DEPLOY_DEVICE_PATH:STRING="${ANDROID_DEPLOY_DEVICE_PATH}"
2107+
-DSWIFT_SDK_ANDROID_ARCHITECTURES:STRING="${ANDROID_ARCH}"
21022108
)
21032109
fi
21042110

utils/build_swift/driver_arguments.py

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

900900
option('--android-icu-uc', store_path,
901-
help='Path to a directory containing libicuuc.so')
901+
help='Path to libicuuc.so')
902902
option('--android-icu-uc-include', store_path,
903903
help='Path to a directory containing headers for libicuuc')
904904
option('--android-icu-i18n', store_path,
905-
help='Path to a directory containing libicui18n.so')
905+
help='Path to libicui18n.so')
906906
option('--android-icu-i18n-include', store_path,
907907
help='Path to a directory containing headers libicui18n')
908+
option('--android-icu-data', store_path,
909+
help='Path to libicudata.so')
908910
option('--android-deploy-device-path', store_path,
909911
default=android.adb.commands.DEVICE_TEMP_DIR,
910912
help='Path on an Android device to which built Swift stdlib '
911913
'products will be deployed. If running host tests, specify '
912914
'the "{}" directory.'.format(
913915
android.adb.commands.DEVICE_TEMP_DIR))
914916

917+
option('--android-arch', store,
918+
choices=['armv7', 'aarch64'],
919+
default='armv7',
920+
help='The Android target architecture when building for Android. '
921+
'Currently only armv7 and aarch64 are supported. '
922+
'%(default)s is the default.')
923+
915924
# -------------------------------------------------------------------------
916925
in_group('Unsupported options')
917926

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,
@@ -484,6 +486,8 @@ class IgnoreOption(_BaseOption):
484486
choices=['none', 'apple']),
485487
ChoicesOption('--swift-analyze-code-coverage',
486488
choices=['false', 'not-merged', 'merged']),
489+
ChoicesOption('--android-arch',
490+
choices=['armv7', 'aarch64']),
487491

488492
StrOption('--android-api-level'),
489493
StrOption('--build-args'),
@@ -502,6 +506,7 @@ class IgnoreOption(_BaseOption):
502506
PathOption('--android-icu-i18n-include'),
503507
PathOption('--android-icu-uc'),
504508
PathOption('--android-icu-uc-include'),
509+
PathOption('--android-icu-data'),
505510
PathOption('--android-ndk'),
506511
PathOption('--build-subdir'),
507512
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)