3
3
All patches used to build these SDKs are open source and listed below.
4
4
5
5
To build with a Swift 5.4.2 SDK, first download [ the latest Android LTS NDK
6
- 23] ( https://developer.android.com/ndk/downloads ) and [ Swift 5.4.2
6
+ 23] ( https://developer.android.com/ndk/downloads ) and [ Swift 5.4.3
7
7
compiler] ( https://swift.org/download/#releases ) (make sure to install the Swift
8
8
compiler's dependencies listed there). Unpack these archives and the SDK.
9
9
@@ -27,7 +27,7 @@ path where you unpacked this SDK, such as `/home/yourname/swift-5.4.2-android-aa
27
27
to point to the clang headers next to your swift compiler, eg
28
28
29
29
```
30
- ln -sf /home/yourname/swift-5.4.2 -RELEASE-ubuntu20.04/usr/lib/clang/10.0.0
30
+ ln -sf /home/yourname/swift-5.4.3 -RELEASE-ubuntu20.04/usr/lib/clang/10.0.0
31
31
swift-5.4.2-android-aarch64-24-sdk/usr/lib/swift/clang
32
32
```
33
33
The new NDK 23 needs to have a header modified: change the line from this file,
@@ -44,8 +44,8 @@ Finally, modify the cross-compilation JSON file in this repo similarly:
44
44
1 . All paths to the NDK should change from ` /home/butta/android-ndk-r23 `
45
45
to the path to your NDK, ` /home/yourname/android-ndk-r23 ` .
46
46
47
- 2 . The path to the compiler should change from ` /home/butta/swift-5.4.2 -RELEASE-ubuntu20.04 `
48
- to the path to your Swift compiler, ` /home/yourname/swift-5.4.2 -RELEASE-centos8 ` .
47
+ 2 . The path to the compiler should change from ` /home/butta/swift-5.4.3 -RELEASE-ubuntu20.04 `
48
+ to the path to your Swift compiler, ` /home/yourname/swift-5.4.3 -RELEASE-centos8 ` .
49
49
50
50
3 . The path to the Android SDK should change from ` /home/butta/swift-5.4.2-android-aarch64-24-sdk `
51
51
to the path where you unpacked the Android SDK, ` /home/yourname/swift-5.4.2-android-aarch64-24-sdk ` .
@@ -56,7 +56,7 @@ I'll demonstrate with the swift-argument-parser package:
56
56
```
57
57
git clone --depth 1 https://github.com/apple/swift-argument-parser.git
58
58
cd swift-argument-parser/
59
- /home/yourname/swift-5.4.2 -RELEASE-ubuntu20.04/usr/bin/swift build --build-tests
59
+ /home/yourname/swift-5.4.3 -RELEASE-ubuntu20.04/usr/bin/swift build --build-tests
60
60
--enable-test-discovery --destination ~/swift-android-sdk/android-aarch64.json
61
61
-Xlinker -rpath -Xlinker \$ORIGIN/swift-5.4.2-android-aarch64-24-sdk/usr/lib/swift/android
62
62
```
@@ -109,9 +109,9 @@ mode.
109
109
110
110
# Building the Android SDKs
111
111
112
- Download the Swift 5.4.2 compiler and Android NDK 23 as above. Check out this
112
+ Download the Swift 5.4.3 compiler and Android NDK 23 as above. Check out this
113
113
repo and run
114
- ` SWIFT_TAG=swift-5.4.2 -RELEASE ANDROID_ARCH=aarch64 swift get-packages-and-swift-source.swift `
114
+ ` SWIFT_TAG=swift-5.4.3 -RELEASE ANDROID_ARCH=aarch64 swift get-packages-and-swift-source.swift `
115
115
to get some prebuilt Android libraries and the Swift source to build the SDK. If
116
116
you pass in a different tag like ` swift-5.5-DEVELOPMENT-SNAPSHOT-2021-08-28-a `
117
117
for the latest Swift 5.5 snapshot and pass in the path to the corresponding
@@ -124,18 +124,18 @@ substituted instead:
124
124
```
125
125
./swift/utils/build-script -RA --skip-build-cmark --build-llvm=0 --android
126
126
--android-ndk /home/butta/android-ndk-r23/ --android-arch aarch64 --android-api-level 24
127
- --android-icu-uc /home/butta/swift-5.4.2 -android-aarch64-24-sdk/usr/lib/libicuuc.so
128
- --android-icu-uc-include /home/butta/swift-5.4.2 -android-aarch64-24-sdk/usr/include/
129
- --android-icu-i18n /home/butta/swift-5.4.2 -android-aarch64-24-sdk/usr/lib/libicui18n.so
130
- --android-icu-i18n-include /home/butta/swift-5.4.2 -android-aarch64-24-sdk/usr/include/
131
- --android-icu-data /home/butta/swift-5.4.2 -android-aarch64-24-sdk/usr/lib/libicudata.so
132
- --build-swift-tools=0 --native-swift-tools-path=/home/butta/swift-5.4.2 -RELEASE-ubuntu20.04/usr/bin/
127
+ --android-icu-uc /home/butta/swift-5.4.3 -android-aarch64-24-sdk/usr/lib/libicuuc.so
128
+ --android-icu-uc-include /home/butta/swift-5.4.3 -android-aarch64-24-sdk/usr/include/
129
+ --android-icu-i18n /home/butta/swift-5.4.3 -android-aarch64-24-sdk/usr/lib/libicui18n.so
130
+ --android-icu-i18n-include /home/butta/swift-5.4.3 -android-aarch64-24-sdk/usr/include/
131
+ --android-icu-data /home/butta/swift-5.4.3 -android-aarch64-24-sdk/usr/lib/libicudata.so
132
+ --build-swift-tools=0 --native-swift-tools-path=/home/butta/swift-5.4.3 -RELEASE-ubuntu20.04/usr/bin/
133
133
--native-clang-tools-path=/home/butta/android-ndk-r23/toolchains/llvm/prebuilt/linux-x86_64/bin
134
134
--host-cc=/usr/bin/clang-11 --host-cxx=/usr/bin/clang++-11
135
- --cross-compile-hosts=android-aarch64 --cross-compile-deps-path=/home/butta/swift-5.4.2 -android-aarch64-24-sdk
135
+ --cross-compile-hosts=android-aarch64 --cross-compile-deps-path=/home/butta/swift-5.4.3 -android-aarch64-24-sdk
136
136
--skip-local-build --xctest --swift-install-components='clang-resource-dir-symlink;license;stdlib;sdk-overlay'
137
137
--install-swift --install-libdispatch --install-foundation --install-xctest
138
- --install-destdir=/home/butta/swift-5.4.2 -android-aarch64-24-sdk
138
+ --install-destdir=/home/butta/swift-5.4.3 -android-aarch64-24-sdk
139
139
--common-swift-flags="-Xlinker -rpath -Xlinker \\\$\$ORIGIN/../.."
140
140
--swift-cmake-options=-DCMAKE_SHARED_LINKER_FLAGS='-Wl,-rpath,"\$ORIGIN/../.."' -j9
141
141
```
@@ -148,8 +148,8 @@ into these two commands to build for those architectures instead.
148
148
Finally, copy ` libc++_shared.so ` from the NDK and modify the cross-compiled
149
149
` libdispatch.so ` to include ` $ORIGIN ` in its rpath:
150
150
```
151
- cp /home/yourname/android-ndk-r23/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so swift-5.4.2 -android-aarch64-24-sdk/usr/lib
152
- patchelf --set-rpath \$ORIGIN swift-5.4.2 -android-aarch64-24-sdk/usr/lib/swift/android/libdispatch.so
151
+ cp /home/yourname/android-ndk-r23/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so swift-5.4.3 -android-aarch64-24-sdk/usr/lib
152
+ patchelf --set-rpath \$ORIGIN swift-5.4.3 -android-aarch64-24-sdk/usr/lib/swift/android/libdispatch.so
153
153
```
154
154
155
155
Here is a description of what the above Swift script is doing:
@@ -162,18 +162,18 @@ libcurl, and libxml2 packages from the [Termux package
162
162
repository] ( https://packages.termux.org/apt/termux-main/pool/main/ ) .
163
163
164
164
Each one is unpacked with ` ar x libicu_68.2-1_aarch64.deb; tar xf data.tar.xz ` and
165
- the resulting files moved to a newly-created Swift 5.4.2 SDK directory:
165
+ the resulting files moved to a newly-created Swift 5.4.3 SDK directory:
166
166
```
167
- mkdir swift-5.4.2 -android-aarch64-24-sdk
168
- mv data/data/com.termux/files/usr swift-5.4.2 -android-aarch64-24-sdk
167
+ mkdir swift-5.4.3 -android-aarch64-24-sdk
168
+ mv data/data/com.termux/files/usr swift-5.4.3 -android-aarch64-24-sdk
169
169
```
170
170
It removes two config scripts in ` usr/bin ` , runs ` patchelf ` to remove the
171
171
Termux rpath from all Termux shared libraries, and modifies the ICU libraries
172
172
to get rid of the versioning and symlinks (three libicu libraries are removed
173
173
since they're unused by Swift):
174
174
```
175
- rm swift-5.4.2 -android-aarch64-24-sdk/usr/bin/*-config
176
- cd swift-5.4.2 -android-aarch64-24-sdk/usr/lib
175
+ rm swift-5.4.3 -android-aarch64-24-sdk/usr/bin/*-config
176
+ cd swift-5.4.3 -android-aarch64-24-sdk/usr/lib
177
177
178
178
rm libicu{io,test,tu}*
179
179
patchelf --set-rpath \$ORIGIN libandroid-spawn.so libcurl.so libicu*so.68.2 libxml2.so
@@ -203,12 +203,12 @@ instead, so this Swift SDK for Android could be built without using
203
203
any prebuilt Termux packages, if you're willing to put in the effort to
204
204
cross-compile them yourself, for example, against a different Android API.
205
205
206
- Next, it gets [ the 5.4.2 source] ( https://github.com/apple/swift/releases/tag/swift-5.4.2 -RELEASE )
206
+ Next, it gets [ the 5.4.3 source] ( https://github.com/apple/swift/releases/tag/swift-5.4.3 -RELEASE )
207
207
tarballs for five Swift repos and renames them to ` llvm-project/ ` , ` swift/ ` ,
208
208
` swift-corelibs-libdispatch ` , ` swift-corelibs-foundation ` , and
209
209
` swift-corelibs-xctest ` , as required by the Swift ` build-script ` . After creating
210
210
an empty directory, ` mkdir cmark ` , it downloads six patches that have been
211
- backported to build the Termux package for Swift 5.4.2 (all Termux patches are
211
+ backported to build the Termux package for Swift 5.4.3 (all Termux patches are
212
212
available under the [ same license as the Termux package, the Apache license used
213
213
by Swift in this case] ( https://github.com/termux/termux-packages/blob/master/LICENSE.md#license-for-package-patches ) )
214
214
and applies each of them:
0 commit comments