Skip to content

Commit 7ed0fc3

Browse files
committed
Update doc and config files to 5.10
1 parent 3558cdc commit 7ed0fc3

File tree

4 files changed

+41
-42
lines changed

4 files changed

+41
-42
lines changed

README.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,25 @@ emulator](https://github.com/finagolfin/swift-android-sdk/blob/main/.github/work
1010
The CI now builds with both the latest LTS NDK 26 and the last LTS NDK 25c. Now
1111
that Swift 5.9 supports [the new experimental SDK bundle
1212
format](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md),
13-
I plan to distribute an Android SDK bundle for NDK 26 at some point.
13+
I plan to distribute an Android SDK bundle for NDK 26 in the coming month.
1414

15-
If you cannot build against NDK 26 and the Swift 5.9.2 SDK because of the newly
16-
added nullability annotations, use the previous NDK 25c and Swift 5.9 SDK instead,
17-
until you can get your package updated (you can still use the Swift 5.9.2
18-
compiler with the older Swift 5.9 SDK).
15+
If you cannot build against NDK 26 because of the newly added nullability
16+
annotations, you can download a 5.10 SDK built against 25c from a recent run of
17+
the CI, eg `sdk-tests-release-aarch64-ndk25c` under `Artifacts`.
1918

2019
## Cross-compiling and testing Swift packages with the Android SDK
2120

22-
To build with the Swift 5.9.2 SDK, first download [the latest Android LTS NDK
23-
26c](https://developer.android.com/ndk/downloads) and [Swift 5.9.2
21+
To build with the Swift 5.10 SDK, first download [the latest Android LTS NDK
22+
26c](https://developer.android.com/ndk/downloads) and [Swift 5.10
2423
compiler](https://swift.org/download/#releases) (make sure to install the Swift
2524
compiler's dependencies linked there). Unpack these archives and the SDK.
2625

27-
Change the symbolic link at `swift-5.9.2-android-24-sdk/usr/lib/swift/clang`
26+
Change the symbolic link at `swift-5.10-android-24-sdk/usr/lib/swift/clang`
2827
to point to the clang headers that come with your swift compiler, eg
2928

3029
```
31-
ln -sf /home/yourname/swift-5.9.2-RELEASE-ubuntu22.04/usr/lib/clang/13.0.0
32-
swift-5.9.2-android-24-sdk/usr/lib/swift/clang
30+
ln -sf /home/yourname/swift-5.10-RELEASE-ubuntu22.04/usr/lib/clang/15.0.0
31+
swift-5.10-android-24-sdk/usr/lib/swift/clang
3332
```
3433

3534
Next, modify the cross-compilation JSON file `android-aarch64.json` in this repo
@@ -38,11 +37,11 @@ similarly:
3837
1. All paths to the NDK should change from `/home/finagolfin/android-ndk-r26c`
3938
to the path to your NDK, `/home/yourname/android-ndk-r26c`.
4039

41-
2. The path to the compiler should change from `/home/finagolfin/swift-5.9.2-RELEASE-ubuntu22.04`
42-
to the path to your Swift compiler, `/home/yourname/swift-5.9.2-RELEASE-ubi9`.
40+
2. The path to the compiler should change from `/home/finagolfin/swift-5.10-RELEASE-ubuntu22.04`
41+
to the path to your Swift compiler, `/home/yourname/swift-5.10-RELEASE-ubi9`.
4342

44-
3. The paths to the Android SDK should change from `/home/finagolfin/swift-5.9.2-android-24-sdk`
45-
to the path where you unpacked the Android SDK, `/home/yourname/swift-5.9.2-android-24-sdk`.
43+
3. The paths to the Android SDK should change from `/home/finagolfin/swift-5.10-android-24-sdk`
44+
to the path where you unpacked the Android SDK, `/home/yourname/swift-5.10-android-24-sdk`.
4645

4746
Now you're ready to cross-compile a Swift package with the cross-compilation
4847
configuration JSON file, `android-aarch64.json`, and run its tests on Android.
@@ -52,9 +51,9 @@ git clone --depth 1 https://github.com/apple/swift-argument-parser.git
5251
5352
cd swift-argument-parser/
5453
55-
/home/yourname/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin/swift build --build-tests
54+
/home/yourname/swift-5.10-RELEASE-ubuntu22.04/usr/bin/swift build --build-tests
5655
--destination ~/swift-android-sdk/android-aarch64.json
57-
-Xlinker -rpath -Xlinker \$ORIGIN/swift-5.9.2-android-24-sdk/usr/lib/aarch64-linux-android
56+
-Xlinker -rpath -Xlinker \$ORIGIN/swift-5.10-android-24-sdk/usr/lib/aarch64-linux-android
5857
```
5958
This will cross-compile the package for Android aarch64 and produce a test
6059
runner executable with the `.xctest` extension, in this case at
@@ -68,13 +67,13 @@ one depends on the example executables `generate-manual`, `math`, `repeat`, and
6867
data in the repo: I've had success moving this data with the test runner, after
6968
modifying the test source so it has the path to this test data in the Android
7069
test environment. See the example of [swift-crypto on the
71-
CI](https://github.com/finagolfin/swift-android-sdk/blob/5.9/.github/workflows/sdks.yml#L293).
70+
CI](https://github.com/finagolfin/swift-android-sdk/blob/5.10/.github/workflows/sdks.yml#L317).
7271

7372
You can copy these executables and the SDK to [an emulator or a USB
74-
debugging-enabled device with adb](https://github.com/apple/swift/blob/release/5.9/docs/Android.md#3-deploying-the-build-products-to-the-device),
73+
debugging-enabled device with adb](https://github.com/apple/swift/blob/release/5.10/docs/Android.md#3-deploying-the-build-products-to-the-device),
7574
or put them on an Android device with [a terminal emulator app like Termux](https://termux.dev/en/).
7675
I test aarch64 with Termux so I'll show how to run the test runner there, but
77-
the process is similar with adb, [as can be seen on the CI](https://github.com/finagolfin/swift-android-sdk/blob/5.9/.github/workflows/sdks.yml#L328).
76+
the process is similar with adb, [as can be seen on the CI](https://github.com/finagolfin/swift-android-sdk/blob/5.10/.github/workflows/sdks.yml#L355).
7877

7978
Copy the test executables to the same directory as the SDK:
8079
```
@@ -87,10 +86,10 @@ uname -m # check if you're running on the right architecture, should say `aarch6
8786
cd # move to the Termux app's home directory
8887
pkg install openssh
8988
90-
scp [email protected]:{swift-5.9.2-android-24-sdk.tar.xz,
89+
scp [email protected]:{swift-5.10-android-24-sdk.tar.xz,
9190
swift-argument-parserPackageTests.xctest,generate-manual,math,repeat,roll} .
9291
93-
tar xf swift-5.9.2-android-24-sdk.tar.xz
92+
tar xf swift-5.10-android-24-sdk.tar.xz
9493
9594
./swift-argument-parserPackageTests.xctest
9695
```
@@ -146,11 +145,11 @@ dependencies and include them yourself.
146145

147146
## Building the Android SDKs from source
148147

149-
Download the Swift 5.9.2 compiler and Android NDK 26c as above. Check out this
148+
Download the Swift 5.10 compiler and Android NDK 26c as above. Check out this
150149
repo and run
151-
`SWIFT_TAG=swift-5.9.2-RELEASE ANDROID_ARCH=aarch64 swift get-packages-and-swift-source.swift`
150+
`SWIFT_TAG=swift-5.10-RELEASE ANDROID_ARCH=aarch64 swift get-packages-and-swift-source.swift`
152151
to get some prebuilt Android libraries and the Swift source to build the SDK. If
153-
you pass in a different tag like `swift-DEVELOPMENT-SNAPSHOT-2024-03-20-a`
152+
you pass in a different tag like `swift-DEVELOPMENT-SNAPSHOT-2024-03-30-a`
154153
for the latest Swift trunk snapshot and pass in the path to the corresponding
155154
prebuilt Swift toolchain to `build-script` below, you can build a Swift trunk
156155
SDK too, as seen on the CI.
@@ -163,14 +162,14 @@ added in NDK 26:
163162
git apply swift-android.patch swift-android-both-ndks.patch swift-android-foundation-ndk26.patch swift-android-stdlib-ndk26.patch swift-android-stdlib-except-trunk.patch
164163
```
165164

166-
After making sure [needed build tools like python 3, CMake, and ninja](https://github.com/apple/swift/blob/release/5.9/docs/HowToGuides/GettingStarted.md#linux)
165+
After making sure [needed build tools like python 3, CMake, and ninja](https://github.com/apple/swift/blob/release/5.10/docs/HowToGuides/GettingStarted.md#linux)
167166
are installed, run the following `build-script` command with your local paths
168167
substituted instead:
169168
```
170169
./swift/utils/build-script -RA --skip-build-cmark --build-llvm=0 --android
171170
--android-ndk /home/finagolfin/android-ndk-r26c/ --android-arch aarch64 --android-api-level 24
172-
--build-swift-tools=0 --native-swift-tools-path=/home/finagolfin/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin/
173-
--native-clang-tools-path=/home/finagolfin/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin/
171+
--build-swift-tools=0 --native-swift-tools-path=/home/finagolfin/swift-5.10-RELEASE-ubuntu22.04/usr/bin/
172+
--native-clang-tools-path=/home/finagolfin/swift-5.10-RELEASE-ubuntu22.04/usr/bin/
174173
--host-cc=/usr/bin/clang-13 --host-cxx=/usr/bin/clang++-13
175174
--cross-compile-hosts=android-aarch64 --cross-compile-deps-path=/home/finagolfin/swift-release-android-aarch64-24-sdk
176175
--skip-local-build --xctest --swift-install-components='clang-resource-dir-symlink;license;stdlib;sdk-overlay'
@@ -201,7 +200,7 @@ API 24. Specifically, it downloads the libicu, libicu-static, libandroid-spawn,
201200
libcurl, and libxml2 packages from the [Termux package
202201
repository](https://packages.termux.dev/apt/termux-main/pool/main/).
203202

204-
Each one is unpacked with `ar x libicu_74.1_aarch64.deb; tar xf data.tar.xz` and
203+
Each one is unpacked with `ar x libicu_74.2_aarch64.deb; tar xf data.tar.xz` and
205204
the resulting files moved to a newly-created Swift release SDK directory:
206205
```
207206
mkdir swift-release-android-aarch64-24-sdk
@@ -216,17 +215,17 @@ rm swift-release-android-aarch64-24-sdk/usr/bin/*-config
216215
cd swift-release-android-aarch64-24-sdk/usr/lib
217216
218217
rm libicu{io,test,tu}*
219-
patchelf --set-rpath \$ORIGIN libandroid-spawn.so libcurl.so libicu*so.74.1 libxml2.so
218+
patchelf --set-rpath \$ORIGIN libandroid-spawn.so libcurl.so libicu*so.74.2 libxml2.so
220219
221220
# repeat the following for libicui18n.so and libicudata.so, as needed
222221
rm libicuuc.so libicuuc.so.74
223-
readelf -d libicuuc.so.74.1
224-
mv libicuuc.so.74.1 libicuuc.so
222+
readelf -d libicuuc.so.74.2
223+
mv libicuuc.so.74.2 libicuuc.so
225224
patchelf --set-soname libicuuc.so libicuuc.so
226225
patchelf --replace-needed libicudata.so.74 libicudata.so libicuuc.so
227226
```
228227
The libcurl and libxml2 packages are [only needed for the FoundationNetworking
229-
and FoundationXML libraries respectively](https://github.com/apple/swift-corelibs-foundation/blob/release/5.9/Docs/ReleaseNotes_Swift5.md),
228+
and FoundationXML libraries respectively](https://github.com/apple/swift-corelibs-foundation/blob/release/5.10/Docs/ReleaseNotes_Swift5.md),
230229
so you don't have to deploy them on the Android device if you don't use those
231230
extra Foundation libraries. I simply include all four libraries since there's
232231
currently no way to disable building them in the CMake configuration.
@@ -237,7 +236,7 @@ instead, so this Swift SDK for Android could be built without using
237236
any prebuilt Termux packages, if you're willing to put in the effort to
238237
cross-compile them yourself, for example, against a different Android API.
239238

240-
Finally, it gets [the 5.9.2 source](https://github.com/apple/swift/releases/tag/swift-5.9.2-RELEASE)
239+
Finally, it gets [the 5.10 source](https://github.com/apple/swift/releases/tag/swift-5.10-RELEASE)
241240
tarballs for seven Swift repos and renames them to `llvm-project/`, `swift/`,
242241
`swift-syntax`, `swift-experimental-string-processing`, `swift-corelibs-libdispatch`,
243242
`swift-corelibs-foundation`, and `swift-corelibs-xctest`, as required by the Swift

android-aarch64.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": 1,
33
"target": "aarch64-unknown-linux-android24",
4-
"toolchain-bin-dir": "/home/finagolfin/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin",
4+
"toolchain-bin-dir": "/home/finagolfin/swift-5.10-RELEASE-ubuntu22.04/usr/bin",
55
"sdk": "/home/finagolfin/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot",
66
"extra-cc-flags": [
77
"-fPIC"
88
],
99
"extra-swiftc-flags": [
10-
"-resource-dir", "/home/finagolfin/swift-5.9.2-android-24-sdk/usr/lib/swift",
10+
"-resource-dir", "/home/finagolfin/swift-5.10-android-24-sdk/usr/lib/swift",
1111
"-tools-directory", "/home/finagolfin/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin",
12-
"-L", "/home/finagolfin/swift-5.9.2-android-24-sdk/usr/lib/aarch64-linux-android",
12+
"-L", "/home/finagolfin/swift-5.10-android-24-sdk/usr/lib/aarch64-linux-android",
1313
],
1414
"extra-cpp-flags": [
1515
"-lstdc++"

android-armv7.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": 1,
33
"target": "armv7-unknown-linux-androideabi24",
4-
"toolchain-bin-dir": "/home/finagolfin/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin",
4+
"toolchain-bin-dir": "/home/finagolfin/swift-5.10-RELEASE-ubuntu22.04/usr/bin",
55
"sdk": "/home/finagolfin/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot",
66
"extra-cc-flags": [
77
"-fPIC"
88
],
99
"extra-swiftc-flags": [
10-
"-resource-dir", "/home/finagolfin/swift-5.9.2-android-24-sdk/usr/lib/swift",
10+
"-resource-dir", "/home/finagolfin/swift-5.10-android-24-sdk/usr/lib/swift",
1111
"-tools-directory", "/home/finagolfin/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin",
12-
"-L", "/home/finagolfin/swift-5.9.2-android-24-sdk/usr/lib/arm-linux-androideabi",
12+
"-L", "/home/finagolfin/swift-5.10-android-24-sdk/usr/lib/arm-linux-androideabi",
1313
],
1414
"extra-cpp-flags": [
1515
"-lstdc++"

android-x86_64.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": 1,
33
"target": "x86_64-unknown-linux-android24",
4-
"toolchain-bin-dir": "/home/finagolfin/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin",
4+
"toolchain-bin-dir": "/home/finagolfin/swift-5.10-RELEASE-ubuntu22.04/usr/bin",
55
"sdk": "/home/finagolfin/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot",
66
"extra-cc-flags": [
77
"-fPIC"
88
],
99
"extra-swiftc-flags": [
10-
"-resource-dir", "/home/finagolfin/swift-5.9.2-android-24-sdk/usr/lib/swift",
10+
"-resource-dir", "/home/finagolfin/swift-5.10-android-24-sdk/usr/lib/swift",
1111
"-tools-directory", "/home/finagolfin/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin",
12-
"-L", "/home/finagolfin/swift-5.9.2-android-24-sdk/usr/lib/x86_64-linux-android",
12+
"-L", "/home/finagolfin/swift-5.10-android-24-sdk/usr/lib/x86_64-linux-android",
1313
],
1414
"extra-cpp-flags": [
1515
"-lstdc++"

0 commit comments

Comments
 (0)