Skip to content

Commit adf36cb

Browse files
authored
Merge pull request #5432 from modocache/android-ndk-r13
[CMake] Updates for Android NDK r13
2 parents 3210c94 + 61868b5 commit adf36cb

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,11 @@ function(_add_variant_c_compile_flags)
230230
endif()
231231

232232
if("${CFLAGS_SDK}" STREQUAL "ANDROID")
233+
# FIXME: Instead of hardcoding paths in the Android NDK, these paths should
234+
# be passed in via ENV, as with the Windows build.
233235
list(APPEND result
234-
"-I${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libcxx/include"
235-
"-I${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++abi/libcxxabi/include"
236+
"-I${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/include"
237+
"-I${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++abi/include"
236238
"-I${SWIFT_ANDROID_NDK_PATH}/sources/android/support/include")
237239
endif()
238240

@@ -1368,7 +1370,13 @@ function(add_swift_library name)
13681370
set(swiftlib_private_link_libraries_targets
13691371
${swiftlib_module_dependency_targets})
13701372
foreach(lib ${SWIFTLIB_PRIVATE_LINK_LIBRARIES})
1371-
if(TARGET "${lib}${VARIANT_SUFFIX}")
1373+
if("${lib}" STREQUAL "ICU_UC")
1374+
list(APPEND swiftlib_private_link_libraries_targets
1375+
"${SWIFT_${sdk}_ICU_UC}")
1376+
elseif("${lib}" STREQUAL "ICU_I18N")
1377+
list(APPEND swiftlib_private_link_libraries_targets
1378+
"${SWIFT_${sdk}_ICU_I18N}")
1379+
elseif(TARGET "${lib}${VARIANT_SUFFIX}")
13721380
list(APPEND swiftlib_private_link_libraries_targets
13731381
"${lib}${VARIANT_SUFFIX}")
13741382
else()

cmake/modules/FindICU.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ endforeach()
2727

2828
foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS)
2929
foreach(MODULE ${ICU_FIND_COMPONENTS})
30+
string(TOUPPER "${MODULE}" MODULE)
3031
if("${SWIFT_${sdk}_ICU_${MODULE}_INCLUDE}" STREQUAL "")
3132
set(SWIFT_${sdk}_ICU_${MODULE}_INCLUDE ${ICU_${MODULE}_INCLUDE_DIRS})
3233
endif()

docs/Android.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To follow along with this guide, you'll need:
3434
The stdlib is currently only buildable for Android from a Linux environment.
3535
Before attempting to build for Android, please make sure you are able to build
3636
for Linux by following the instructions in the Swift project README.
37-
2. The latest version of the Android NDK (r12 at the time of this writing),
37+
2. The latest version of the Android NDK (r13 at the time of this writing),
3838
available to download here:
3939
http://developer.android.com/ndk/downloads/index.html.
4040
3. An Android device with remote debugging enabled. We require remote
@@ -52,7 +52,7 @@ the Swift stdlib for Android requires the libiconv and libicu libraries.
5252
However, you'll need versions of these libraries that work on Android devices.
5353

5454
You may download prebuilt copies of these dependencies, built for Ubuntu 15.10
55-
and Android NDK r12. Click [here](https://github.com/SwiftAndroid/libiconv-libicu-android/releases/download/android-ndk-r12/libiconv-libicu-armeabi-v7a-ubuntu-15.10-ndk-r12.tar.gz)
55+
and Android NDK r13. Click [here](https://github.com/SwiftAndroid/libiconv-libicu-android/releases/download/android-ndk-r13/libiconv-libicu-armeabi-v7a-ubuntu-15.10-ndk-r13.tar.gz)
5656
to download, then unzip the archive file.
5757

5858
Alternatively, you may choose to build libiconv and libicu for Android yourself:
@@ -81,7 +81,7 @@ Android NDK, as well as the directories that contain the `libicuuc.so` and
8181
$ utils/build-script \
8282
-R \ # Build in ReleaseAssert mode.
8383
--android \ # Build for Android.
84-
--android-ndk /path/to/android-ndk-r12 \ # Path to an Android NDK.
84+
--android-ndk /path/to/android-ndk-r13 \ # Path to an Android NDK.
8585
--android-api-level 21 \ # The Android API level to target. Swift only supports 21 or greater.
8686
--android-icu-uc /path/to/libicu-android/armeabi-v7a \
8787
--android-icu-uc-include /path/to/libicu-android/armeabi-v7a/icu/source/common \
@@ -102,7 +102,7 @@ gold linker in the Android NDK into your `PATH`:
102102

103103
```
104104
$ sudo ln -s \
105-
/path/to/android-ndk-r12/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.gold \
105+
/path/to/android-ndk-r13/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.gold \
106106
/usr/bin/armv7-none-linux-androideabi-ld.gold
107107
```
108108

@@ -112,9 +112,9 @@ source file, targeting Android:
112112
```
113113
$ build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc \ # The Swift compiler built in the previous step.
114114
-target armv7-none-linux-androideabi \ # Targeting android-armv7.
115-
-sdk /path/to/android-ndk-r12/platforms/android-21/arch-arm \ # Use the same NDK path and API version as you used to build the stdlib in the previous step.
116-
-L /path/to/android-ndk-r12/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a \ # Link the Android NDK's libc++ and libgcc.
117-
-L /path/to/android-ndk-r12/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9 \
115+
-sdk /path/to/android-ndk-r13/platforms/android-21/arch-arm \ # Use the same NDK path and API version as you used to build the stdlib in the previous step.
116+
-L /path/to/android-ndk-r13/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a \ # Link the Android NDK's libc++ and libgcc.
117+
-L /path/to/android-ndk-r13/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9 \
118118
hello.swift
119119
```
120120

@@ -155,7 +155,7 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswi
155155
In addition, you'll also need to copy the Android NDK's libc++:
156156

157157
```
158-
$ adb push /path/to/android-ndk-r12/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so /data/local/tmp
158+
$ adb push /path/to/android-ndk-r13/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so /data/local/tmp
159159
```
160160

161161
Finally, you'll need to copy the `hello` executable you built in the
@@ -198,7 +198,7 @@ $ utils/build-script \
198198
-R \ # Build in ReleaseAssert mode.
199199
-T \ # Run all tests.
200200
--android \ # Build for Android.
201-
--android-ndk ~/android-ndk-r12 \ # Path to an Android NDK.
201+
--android-ndk ~/android-ndk-r13 \ # Path to an Android NDK.
202202
--android-ndk-version 21 \
203203
--android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
204204
--android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ else()
179179
# -Wl,--whole-archive swiftRuntime -Wl,--no-whole-archive)
180180
find_package(ICU REQUIRED COMPONENTS uc i18n)
181181
list(APPEND swift_core_private_link_libraries
182-
${ICU_UC_LIBRARY} ${ICU_I18N_LIBRARY})
182+
ICU_UC ICU_I18N)
183183
endif()
184184

185185
if("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")

0 commit comments

Comments
 (0)