diff --git a/docs/Android.md b/docs/Android.md index bd3324369b407..a7dda5fd4cecb 100644 --- a/docs/Android.md +++ b/docs/Android.md @@ -43,51 +43,22 @@ To follow along with this guide, you'll need: ## "Hello, world" on Android -### 1. Downloading (or building) the Swift Android stdlib dependencies +### 1. Building the Swift stdlib for Android -You may have noticed that, in order to build the Swift stdlib for Linux, you -needed to `apt-get install libicu-dev icu-devtools`. Similarly, building -the Swift stdlib for Android requires the libiconv and libicu libraries. -However, you'll need versions of these libraries that work on Android devices. - -The steps are as follows: - -1. Ensure you have `curl`, `autoconf`, `automake`, `libtool`, and - `git` installed. -2. Clone the [SwiftAndroid/libiconv-libicu-android](https://github.com/SwiftAndroid/libiconv-libicu-android) - project. From the command-line, run the following command: - `git clone https://github.com/SwiftAndroid/libiconv-libicu-android.git`. -3. From the command-line, run `which ndk-build`. Confirm that the path to - the `ndk-build` executable in the Android NDK you downloaded is displayed. - If not, you may need to add the Android NDK directory to your `PATH`. -4. Change directories into `libiconv-libicu-android`: `cd libiconv-libicu-android` -5. Run the Swift build script: `./build-swift.sh` -6. Confirm that the various `libicuXYZswift.so` libraries are located in the - `armeabi-v7a` directory. - -### 2. Building the Swift stdlib for Android - -Enter your Swift directory, then run the build script, passing paths to the -Android NDK, as well as the directories that contain the `libicuucswift.so` and -`libicui18nswift.so` you downloaded or built in step one: +Enter your Swift directory, then run the build script, passing the path to the +Android NDK: ``` -$ ARM_DIR=path/to/libiconv-libicu-android/armeabi-v7a $ NDK_PATH=path/to/android-ndk-r23b $ utils/build-script \ -R \ # Build in ReleaseAssert mode. --android \ # Build for Android. --android-ndk $NDK_PATH \ # Path to an Android NDK. --android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64 or x86_64 - --android-api-level 21 \ # The Android API level to target. Swift only supports 21 or greater. - --android-icu-uc ${ARM_DIR}/libicuucswift.so \ - --android-icu-uc-include ${ARM_DIR}/icu/source/common \ - --android-icu-i18n ${ARM_DIR}/libicui18nswift.so \ - --android-icu-i18n-include ${ARM_DIR}/icu/source/i18n \ - --android-icu-data ${ARM_DIR}/libicudataswift.so + --android-api-level 21 # The Android API level to target. Swift only supports 21 or greater. ``` -### 3. Compiling `hello.swift` to run on an Android device +### 2. Compiling `hello.swift` to run on an Android device Create a simple Swift file named `hello.swift`: @@ -121,7 +92,7 @@ This is exactly the error we want: the executable is built to run on an Android device--it does not run on Linux. Next, let's deploy it to an Android device in order to execute it. -### 4. Deploying the build products to the device +### 3. Deploying the build products to the device You can use the `adb push` command to copy build products from your Linux environment to your Android device. If you haven't already installed `adb`, @@ -142,14 +113,6 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswi $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftRemoteMirror.so /data/local/tmp ``` -You will also need to push the icu libraries: - -``` -adb push /path/to/libicu-android/armeabi-v7a/libicudataswift.so /data/local/tmp -adb push /path/to/libicu-android/armeabi-v7a/libicui18nswift.so /data/local/tmp -adb push /path/to/libicu-android/armeabi-v7a/libicuucswift.so /data/local/tmp -``` - In addition, you'll also need to copy the Android NDK's libc++: ``` @@ -162,7 +125,7 @@ previous step: $ adb push hello /data/local/tmp ``` -### 5. Running "Hello, world" on your Android device +### 4. Running "Hello, world" on your Android device You can use the `adb shell` command to execute the `hello` executable on the Android device: @@ -182,7 +145,7 @@ Congratulations! You've just run your first Swift program on Android. ## Running the Swift test suite hosted on an Android device When running the test suite, build products are automatically pushed to your -device. As in part four, you'll need to connect your Android device via USB: +device. As in part three, you'll need to connect your Android device via USB: 1. Connect your Android device to your computer via USB. Ensure that remote debugging is enabled for that device by following the official instructions: @@ -198,10 +161,5 @@ $ utils/build-script \ --android \ # Build for Android. --android-ndk ~/android-ndk-r23b \ # Path to an Android NDK. --android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64 - --android-ndk-version 21 \ - --android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \ - --android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \ - --android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \ - --android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/ \ - --android-icu-data ~/libicu-android/armeabi-v7a/libicudata.so + --android-ndk-version 21 ``` diff --git a/docs/AndroidBuild.md b/docs/AndroidBuild.md index c45f77bec0644..44278a585f443 100644 --- a/docs/AndroidBuild.md +++ b/docs/AndroidBuild.md @@ -74,10 +74,6 @@ cmake -C S:\swift-build\cmake\caches\android-armv7.cmake -DANDROID_ALTERNATE_TOOLCHAIN=S:/b/a/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr ^ -DLLVM_DIR=S:/b/a/llvm/lib/cmake/llvm ^ -DSWIFT_NATIVE_SWIFT_TOOLS_PATH=S:/b/a/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin ^ - -DSWIFT_ANDROID_armv7_ICU_UC_INCLUDE=S:/b/a/Library/icu-64/usr/include/unicode ^ - -DSWIFT_ANDROID_armv7_ICU_UC=S:/b/a/Library/icu-64/usr/lib/libicuuc64.so ^ - -DSWIFT_ANDROID_armv7_ICU_I18N_INCLUDE=S:/b/a/Library/icu-64/usr/include ^ - -DSWIFT_ANDROID_armv7_ICU_I18N=S:/b/a/Library/icu-64/usr/lib/libicuin64.so ^ S:/swift ninja ninja install diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2fe371e5dcd44..b71ca19293f07 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -340,13 +340,7 @@ foreach(SDK ${SWIFT_SDKS}) --destination "${SWIFT_ANDROID_DEPLOY_DEVICE_PATH}" --destination-arch "${ARCH}" # Build products like libswiftCore.so. - "${SWIFTLIB_DIR}/android" - # These two directories may contain the same libraries, - # but upload both to device just in case. Duplicates will be - # overwritten, and uploading doesn't take very long anyway. - "${SWIFT_ANDROID_${ARCH}_ICU_UC}" - "${SWIFT_ANDROID_${ARCH}_ICU_I18N}" - "${SWIFT_ANDROID_${ARCH}_ICU_DATA}") + "${SWIFTLIB_DIR}/android") endif() add_custom_target("upload-stdlib${VARIANT_SUFFIX}" ${command_upload_stdlib} diff --git a/utils/android/build-toolchain b/utils/android/build-toolchain deleted file mode 100755 index dc51a3cad6680..0000000000000 --- a/utils/android/build-toolchain +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -# -# android/build-toolchain -# -# This source file is part of the Swift.org open source project -# -# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See https://swift.org/LICENSE.txt for license information -# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors - -set -e - -SWIFT_PATH="$( cd "$(dirname $0)/../../.." && pwd )" - -ANDROID_NDK_PATH="${ANDROID_NDK_PATH:?Please set the Android NDK path in the ANDROID_NDK_PATH environment variable}" -ANDROID_ICU_PATH=${SWIFT_PATH}/libiconv-libicu-android - -[ -e ${ANDROID_ICU_PATH} ] || exit 1 - -SWIFT_ANDROID_TOOLCHAIN_PATH="${SWIFT_PATH}/swift-android-toolchain" - -rm -rf ${SWIFT_ANDROID_TOOLCHAIN_PATH} - -${SWIFT_PATH}/swift/utils/build-script \ - -R \ - --android \ - --android-ndk ${ANDROID_NDK_PATH} \ - --android-api-level 21 \ - --android-icu-uc "${ANDROID_ICU_PATH}/armeabi-v7a" \ - --android-icu-uc-include "${ANDROID_ICU_PATH}/armeabi-v7a/icu/source/common" \ - --android-icu-i18n "${ANDROID_ICU_PATH}/armeabi-v7a" \ - --android-icu-i18n-include "${ANDROID_ICU_PATH}/armeabi-v7a/icu/source/i18n" \ - --libdispatch --install-libdispatch \ - --foundation --install-foundation \ - --llbuild --install-llbuild \ - --lldb --install-lldb \ - --swiftpm --install-swiftpm \ - --xctest --install-xctest \ - --install-swift \ - '--swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;dev' \ - --install-prefix=/usr \ - --install-destdir=${SWIFT_ANDROID_TOOLCHAIN_PATH} - -${SWIFT_PATH}/swift-corelibs-libdispatch/build-android -${SWIFT_PATH}/swift-corelibs-foundation/build-android - diff --git a/utils/build-presets.ini b/utils/build-presets.ini index de8ae46c57d22..3ebed671fe128 100644 --- a/utils/build-presets.ini +++ b/utils/build-presets.ini @@ -927,12 +927,6 @@ libcxx android android-ndk=%(ndk_path)s android-api-level=21 -android-icu-uc=%(arm_dir)s/libicuucswift.so -android-icu-uc-include=%(arm_dir)s/icu/source/common -android-icu-i18n=%(arm_dir)s/libicui18nswift.so -android-icu-i18n-include=%(arm_dir)s/icu/source/i18n -android-icu-data=%(arm_dir)s/libicudataswift.so - build-swift-static-stdlib build-swift-static-sdk-overlay build-swift-stdlib-unittest-extra @@ -945,8 +939,6 @@ installable-package=%(installable_package)s host-test -extra-cmake-options=-DSWIFT_ENABLE_LLD_LINKER:BOOL=OFF - install-prefix=/usr install-llvm install-swift diff --git a/utils/build-script b/utils/build-script index 18cb730318a5b..4440554af7e5e 100755 --- a/utils/build-script +++ b/utils/build-script @@ -225,18 +225,10 @@ def validate_arguments(toolchain, args): if args.android: if args.android_ndk is None or \ - args.android_api_level is None or \ - 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 or \ - args.android_icu_data is None: + args.android_api_level is None: fatal_error( - "when building for Android, --android-ndk, " - "--android-api-level, --android-icu-uc, " - "--android-icu-uc-include, --android-icu-i18n, " - "--android-icu-i18n-include, and --android-icu-data " - "must be specified") + "when building for Android, --android-ndk " + "and --android-api-level must be specified") targets_needing_toolchain = [ 'build_indexstoredb', diff --git a/utils/build-script-impl b/utils/build-script-impl index 08716408f5c7d..8b418d33d700e 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -89,11 +89,6 @@ KNOWN_SETTINGS=( android-api-level "" "The Android API level to target when building for Android. Currently only 21 or above is supported" android-arch "armv7" "The Android target architecture when building for Android" android-deploy-device-path "" "Path on an Android device to which built Swift stdlib products will be deployed" - android-icu-data "" "Path to libicudata.so" - android-icu-i18n "" "Path to libicui18n.so" - android-icu-i18n-include "" "Path to a directory containing headers libicui18n" - android-icu-uc "" "Path to libicuuc.so" - android-icu-uc-include "" "Path to a directory containing headers for libicuuc" android-ndk "" "An absolute path to the NDK that will be used as a libc implementation for Android builds" ## Darwin Options @@ -1907,11 +1902,6 @@ for host in "${ALL_HOSTS[@]}"; do cmake_options=( "${cmake_options[@]}" -DSWIFT_ANDROID_NDK_PATH:STRING="${ANDROID_NDK}" - -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}" ) diff --git a/utils/build_swift/build_swift/driver_arguments.py b/utils/build_swift/build_swift/driver_arguments.py index a210047048b42..940a4dde3d5ee 100644 --- a/utils/build_swift/build_swift/driver_arguments.py +++ b/utils/build_swift/build_swift/driver_arguments.py @@ -1176,16 +1176,6 @@ def create_argument_parser(): help='The Android API level to target when building for Android. ' 'Currently only 21 or above is supported') - option('--android-icu-uc', store_path, - 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 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 ' diff --git a/utils/build_swift/tests/expected_options.py b/utils/build_swift/tests/expected_options.py index 77b453cda84fe..24337dcf6a892 100644 --- a/utils/build_swift/tests/expected_options.py +++ b/utils/build_swift/tests/expected_options.py @@ -42,11 +42,6 @@ 'android': False, 'android_api_level': '21', 'android_deploy_device_path': '/data/local/tmp', - 'android_icu_i18n': None, - 'android_icu_i18n_include': None, - 'android_icu_uc': None, - 'android_icu_uc_include': None, - 'android_icu_data': None, 'android_ndk': None, 'android_arch': 'armv7', 'assertions': True, @@ -688,11 +683,6 @@ class BuildScriptImplOption(_BaseOption): SetTrueOption('--swift-freestanding-is-darwin'), PathOption('--android-deploy-device-path'), - PathOption('--android-icu-i18n'), - PathOption('--android-icu-i18n-include'), - PathOption('--android-icu-uc'), - PathOption('--android-icu-uc-include'), - PathOption('--android-icu-data'), PathOption('--android-ndk'), PathOption('--build-subdir'), SetTrueOption('--relocate-xdg-cache-home-under-build-subdir'), diff --git a/utils/swift_build_support/swift_build_support/build_script_invocation.py b/utils/swift_build_support/swift_build_support/build_script_invocation.py index 0e9908b72989b..588ca26ce6a84 100644 --- a/utils/swift_build_support/swift_build_support/build_script_invocation.py +++ b/utils/swift_build_support/swift_build_support/build_script_invocation.py @@ -311,11 +311,6 @@ def convert_to_impl_arguments(self): "--android-arch", args.android_arch, "--android-ndk", args.android_ndk, "--android-api-level", args.android_api_level, - "--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 building natively on an Android host, only pass the API level. if StdlibDeploymentTarget.Android.contains(StdlibDeploymentTarget diff --git a/validation-test/BuildSystem/android_cross_compile.test b/validation-test/BuildSystem/android_cross_compile.test index 8a35f88ae549e..8396568dce764 100644 --- a/validation-test/BuildSystem/android_cross_compile.test +++ b/validation-test/BuildSystem/android_cross_compile.test @@ -5,7 +5,7 @@ # UNSUPPORTED: OS=watchos # RUN: %empty-directory(%t) -# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --libdispatch --cross-compile-hosts=android-aarch64 --skip-local-build --android --android-ndk %t/ndk/ --android-arch aarch64 --android-icu-uc %t/lib/libicuuc.so --android-icu-uc-include %t/include/ --android-icu-i18n %t/lib/libicui18n.so --android-icu-i18n-include %t/include/ --android-icu-data %t/lib/libicudata.so 2>&1 | %FileCheck %s +# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --libdispatch --cross-compile-hosts=android-aarch64 --skip-local-build --android --android-ndk %t/ndk/ --android-arch aarch64 2>&1 | %FileCheck %s # CHECK: -DCMAKE_Swift_FLAGS{{.*}}-target {{.*}}unknown-linux-android{{.*}} -sdk # CHECK: -DCMAKE_SYSTEM_NAME=Android {{.*}} -DCMAKE_ANDROID_NDK