From 555e085d7828a4f88d6c04d6a8ae790479ae83b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodr=C3=ADguez=20Troiti=C3=B1o?= Date: Fri, 26 Oct 2018 12:19:00 -0700 Subject: [PATCH] [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). --- utils/build-script | 19 ++++++++++++------ utils/build-script-impl | 20 ++++++++++++------- utils/build_swift/driver_arguments.py | 13 ++++++++++-- utils/build_swift/tests/expected_options.py | 5 +++++ .../swift_build_support/targets.py | 2 +- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/utils/build-script b/utils/build-script index ec6c8fd59e61a..4871322f59892 100755 --- a/utils/build-script +++ b/utils/build-script @@ -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): @@ -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 @@ -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 += [ diff --git a/utils/build-script-impl b/utils/build-script-impl index 9e930d254419c..687800da623f5 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -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" @@ -1622,6 +1624,9 @@ function common_cross_c_flags() { android-armv7) echo -n " -arch armv7" ;; + android-arm64) + echo -n " -arch aarch64" + ;; esac } @@ -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 diff --git a/utils/build_swift/driver_arguments.py b/utils/build_swift/driver_arguments.py index c33c4553b119d..4f452ebdbec01 100644 --- a/utils/build_swift/driver_arguments.py +++ b/utils/build_swift/driver_arguments.py @@ -898,13 +898,15 @@ 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 ' @@ -912,6 +914,13 @@ def create_argument_parser(): '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') diff --git a/utils/build_swift/tests/expected_options.py b/utils/build_swift/tests/expected_options.py index d39ce4efbd1eb..648fd25103e87 100644 --- a/utils/build_swift/tests/expected_options.py +++ b/utils/build_swift/tests/expected_options.py @@ -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, @@ -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'), @@ -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'), diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py index 2859677facc37..35e425d34a07e 100644 --- a/utils/swift_build_support/swift_build_support/targets.py +++ b/utils/swift_build_support/swift_build_support/targets.py @@ -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"])