Skip to content

Commit 8d2a2c4

Browse files
committed
Swift Android build
1 parent 0633a32 commit 8d2a2c4

File tree

3 files changed

+58
-41
lines changed

3 files changed

+58
-41
lines changed

.github/workflows/pull_request.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ jobs:
123123
# recent releases require that ANDROID_NDK_ROOT *not* be set
124124
# see https://github.com/finagolfin/swift-android-sdk/issues/207
125125
echo "ANDROID_NDK_ROOT=" >> $GITHUB_ENV
126-
- name: Build Demo Project
126+
127+
- name: Create Demo Project
127128
run: |
128129
cd ${{ runner.temp }}
129130
mkdir DemoProject
@@ -136,28 +137,25 @@ jobs:
136137
echo 'import FoundationNetworking' >> Sources/DemoProject/DemoProject.swift
137138
echo 'import Dispatch' >> Sources/DemoProject/DemoProject.swift
138139
echo 'import Android' >> Sources/DemoProject/DemoProject.swift
139-
${{ steps.info.outputs.swift-path }} build --build-tests --swift-sdk ${{ steps.info.outputs.sdk-id }}
140140
- name: Test Demo Project on Android
141-
# only test for the complete arch SDK build to speed up CI
142-
if: ${{ matrix.arch == '' }}
143-
uses: skiptools/swift-android-action@main
141+
uses: skiptools/swift-android-action@v2
144142
with:
143+
# only test for the complete arch SDK build to speed up CI
144+
run-tests: ${{ matrix.arch == '' }}
145145
package-path: ${{ runner.temp }}/DemoProject
146146
installed-sdk: ${{ steps.info.outputs.sdk-id }}
147147
installed-swift: ${{ steps.info.outputs.swift-root }}
148-
- name: Build swift-algorithms
149-
run: |
150-
cd ${{ runner.temp }}
151-
git clone https://github.com/apple/swift-algorithms.git
152-
cd swift-algorithms
153-
${{ steps.info.outputs.swift-path }} build --build-tests --swift-sdk ${{ steps.info.outputs.sdk-id }}
154-
- name: Test swift-algorithms on Android
155-
# only test for the complete arch SDK build to speed up CI
156-
if: ${{ matrix.arch == '' }}
157-
uses: skiptools/swift-android-action@main
148+
149+
- name: Checkout swift-algorithms
150+
uses: actions/checkout@v4
151+
with:
152+
repository: apple/swift-algorithms
153+
path: swift-algorithms
154+
- name: Test swift-algorithms
155+
uses: skiptools/swift-android-action@v2
158156
with:
159-
#package-path: ${{ runner.temp }}/DemoProject
160-
package-path: ${{ runner.temp }}/swift-algorithms
157+
run-tests: ${{ matrix.arch == '' }}
158+
package-path: swift-algorithms
161159
installed-sdk: ${{ steps.info.outputs.sdk-id }}
162160
installed-swift: ${{ steps.info.outputs.swift-root }}
163161

swift-ci/sdks/android/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Build scripts for Swift Android SDK
2+
3+
This folder contains scripts to build a Swift Android SDK
4+
in the form of an artifactbundle.
5+
6+
## Running
7+
8+
The top-level `./build` script installs a host toolchain and the
9+
Android NDK, and then invokes `scripts/fetch-source.sh` which will
10+
fetch tagged sources for libxml2, curl, boringssl, and swift.
11+
12+
It then applies some patches and invokes `scripts/build.sh`,
13+
which will build the sources for each of the specified
14+
architectures. Finally, it combines the NDK and the newly built
15+
SDKs into a single artifactbundle.
16+
17+
## Specifying Architectures
18+
19+
By default all the supported Android architectures
20+
(`aarch64`, `x86_64`, `aarmv7`)
21+
will be built, but this can be reduced in order to speed
22+
up the build. This can be useful, e.g., as part of a CI that
23+
validates a pull request, as building a single architecture
24+
takes around 30 minutes on a standard ubuntu-24.04 GitHub runner,
25+
whereas building for all the architectures takes over an hour.
26+
27+
To build an artifactbundle for just the `x86_64` architecture, run:
28+
29+
```
30+
TARGET_ARCHS=x86_64 ./build
31+
```
32+
33+
## Installing and validating the SDK
34+
35+
The `.github/workflows/pull_request.yml` workflow
36+
will create and upload an installable SDK named something like:
37+
`swift-6.1-RELEASE_android-0.1.artifactbundle.tar.gz`
38+
39+
The workflow will also install the SDK locally and use
40+
[swift-android-action](https://github.com/marketplace/actions/swift-android-action)
41+
to build and test various Swift packages in an Android emulator.
42+
43+

swift-ci/sdks/android/scripts/build.sh

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -477,30 +477,6 @@ rm -r ${sysroot_path}/usr/{include,lib}/{i686,riscv64}-linux-android
477477
rm -r ${sysroot_path}/usr/lib/swift/clang/lib/linux/*{i[36]86,riscv64}*
478478
rm -r ${sdk_staging}
479479

480-
# validate that some expected paths exist
481-
quiet_pushd ${sysroot_path}/usr
482-
ls lib/swift/android
483-
ls lib/swift/android/*
484-
ls lib/swift/android/*/swiftrt.o
485-
486-
ls lib/swift_static-*
487-
ls lib/swift_static-*/android
488-
ls lib/swift_static-*/android/libFoundationEssentials.a
489-
490-
ls lib/*-linux-android/libFoundationEssentials.so
491-
ls lib/*-linux-android/libFoundationNetworking.so
492-
ls lib/*-linux-android/libFoundationInternationalization.so
493-
ls lib/*-linux-android/lib_FoundationICU.so
494-
ls lib/*-linux-android/libFoundationXML.so
495-
ls lib/*-linux-android/libTesting.so
496-
497-
ls lib/swift/clang/lib
498-
ls lib/swift/clang/lib/linux
499-
ls lib/swift/clang/lib/linux/*
500-
ls lib/swift/clang/lib/linux/*/libunwind.a
501-
ls lib/*-linux-android/*/crtbegin_dynamic.o
502-
quiet_popd
503-
504480
cat > swift-sdk.json <<EOF
505481
{
506482
"schemaVersion": "4.0",

0 commit comments

Comments
 (0)