-
Notifications
You must be signed in to change notification settings - Fork 201
Android SDK build scripts #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcprux
wants to merge
49
commits into
swiftlang:main
Choose a base branch
from
swift-android-sdk:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
5f1dbac
Add Android workflow
marcprux 1b7e52f
Merge branch 'swiftlang:main' into main
marcprux c263e80
Merge branch 'swiftlang:main' into main
marcprux dd6d09f
Merge branch 'swiftlang:main' into main
marcprux 6565052
Build Android image (#1)
marcprux 5f9dab4
Merge branch 'swiftlang:main' into main
marcprux 412e6b0
Merge branch 'swiftlang:main' into main
marcprux 40733f7
Swift Android build 6.2 (#2)
marcprux 53e361a
Swift Android build 6.2 (#3)
marcprux 72964f5
Build SDK in Docker container (#4)
marcprux 9160168
Merge branch 'swiftlang:main' into main
marcprux 4987bcc
Checkout patches repo instead of using a git submodule
marcprux ff3f274
Update libcurl to 8.13.0
marcprux 595efc3
Remove resources that we no longer use
marcprux 27b1bf4
Update libcurl to 8.13.0
marcprux b898129
Update libxml2 to 2.14.2
marcprux f566b23
Build libxml2, libcurl, and boringssl with support for Android 16kb p…
marcprux 529e3f1
Add build-script --extra-cmake-options=-DCMAKE_EXTRA_LINK_FLAGS=-Wl,-…
marcprux c82587d
Add 16KB page size linker flags to linker flags in swift-toolset.json
marcprux 217f1d7
Add 16KB page size linker flags to linker flags in swift-toolset.json
marcprux 95046b3
Build with ndk-r28b
marcprux 8b18b5f
Revert to building with ndk-r27c
marcprux f67f9bf
Use official endpoints for discovering latest Swift release/devel/tru…
marcprux 7011a45
Typo fix in version script
marcprux 4c65a93
Cleanup for PR
marcprux d80c80b
Change BUILD_VERSION to BUILD_SCHEME and have it match release, swift…
marcprux 2c07eef
Update Android README
marcprux 51d93f8
Update how patches are applied
marcprux 46a06df
Fix source directory for patch target
marcprux afb2918
Harmonize timestamps in artifactbundle with the swift source tag date…
marcprux a469e85
Simplify toolchain-vars.sh
marcprux dea39d7
Merge branch 'swiftlang:main' into main
marcprux b3cddbd
Merge branch 'swiftlang:main' into main
marcprux abd3fd1
Merge branch 'swiftlang:main' into main
marcprux ad24ea5
Merge branch 'swiftlang:main' into main
marcprux 50ba1cd
Run the compiler validation suite for Android (#8)
marcprux 71b7131
Build compiler-validated bundles from latest branch commits, not olde…
finagolfin e2f696a
Merge pull request #9 from swift-android-sdk/Testing
finagolfin 3f4cd4a
gcpd 'Update patches'
marcprux bd0df11
Update patches and build matrix
marcprux 80291aa
Disable compiler validated builds on self-hosted
marcprux 18c563f
Centralize cmake variable for 6.2 in patches, as done for trunk upstream
finagolfin ed09034
Update disabled tests
finagolfin e4a96b2
Merge branch 'main' into update-patches2
marcprux f472e9e
Try running Docker build on macOS host
marcprux 22a4320
Remove separate checks of libxml2, curl, and yams
marcprux bc3f105
Merge pull request #11 from swift-android-sdk/update-patches2
marcprux a7b303a
Remove upstreamed 6.2 branch patches
finagolfin 4ed1375
Merge branch 'swiftlang:main' into main
marcprux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.*.swp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# ===----------------------------------------------------------------------=== | ||
# | ||
# Swift Android SDK: Docker-based build | ||
# | ||
# ===----------------------------------------------------------------------=== | ||
|
||
FROM ubuntu:24.04 | ||
|
||
# Architecture to build on (empty means x86-64) | ||
ARG OS_ARCH_SUFFIX= | ||
|
||
# the Swift toolchain URL to download | ||
ARG SWIFT_TOOLCHAIN_URL= | ||
|
||
# ............................................................................ | ||
|
||
# Install development tools | ||
RUN apt-get -q update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get -q install -y \ | ||
build-essential \ | ||
clang-19 \ | ||
cmake \ | ||
ninja-build \ | ||
python3 \ | ||
golang \ | ||
git \ | ||
gnupg2 \ | ||
libcurl4-openssl-dev \ | ||
libedit-dev \ | ||
libicu-dev \ | ||
libncurses5-dev \ | ||
libpython3-dev \ | ||
libsqlite3-dev \ | ||
libxml2-dev \ | ||
rsync \ | ||
uuid-dev \ | ||
uuid-runtime \ | ||
tzdata \ | ||
curl \ | ||
unzip \ | ||
&& rm -rf /var/lib/apt-lists/* | ||
|
||
# Install Swift | ||
ARG SWIFT_SIGNING_KEY=E813C892820A6FA13755B268F167DF1ACF9CE069 | ||
ARG SWIFT_PLATFORM=ubuntu | ||
ARG OS_MAJOR_VER=24 | ||
ARG OS_MINOR_VER=04 | ||
|
||
ENV SWIFT_SIGNING_KEY=$SWIFT_SIGNING_KEY \ | ||
SWIFT_PLATFORM=$SWIFT_PLATFORM \ | ||
OS_MAJOR_VER=$OS_MAJOR_VER \ | ||
OS_MINOR_VER=$OS_MINOR_VER \ | ||
OS_VER=$SWIFT_PLATFORM$OS_MAJOR_VER.$OS_MINOR_VER | ||
|
||
COPY scripts/install-swift.sh /scripts/install-swift.sh | ||
RUN chmod ugo+x /scripts/install-swift.sh | ||
RUN /scripts/install-swift.sh /usr/local/swift | ||
ENV PATH="/usr/lib/llvm-19/bin:/usr/local/swift/bin:${PATH}" | ||
|
||
ARG ANDROID_NDK_VERSION= | ||
|
||
ENV ANDROID_NDK_VERSION=$ANDROID_NDK_VERSION | ||
|
||
COPY scripts/install-ndk.sh /scripts/install-ndk.sh | ||
RUN chmod ugo+x /scripts/install-ndk.sh | ||
RUN /scripts/install-ndk.sh | ||
ENV ANDROID_NDK_HOME="/usr/local/ndk/${ANDROID_NDK_VERSION}" | ||
|
||
ENV SWIFT_VERSION=$SWIFT_VERSION \ | ||
LIBXML2_VERSION=$LIBXML2_VERSION \ | ||
CURL_VERSION=$CURL_VERSION \ | ||
BORINGSSL_VERSION=$BORINGSSL_VERSION \ | ||
ICU_VERSION=$ICU_VERSION \ | ||
ZLIB_VERSION=$ZLIB_VERSION | ||
|
||
ENV SWIFT_BUILD_DOCKER="1" | ||
|
||
COPY scripts /scripts | ||
RUN chmod ugo+x /scripts/* | ||
|
||
# Create a user | ||
RUN groupadd -g 998 build-user && \ | ||
useradd -m -r -u 998 -g build-user build-user | ||
|
||
USER build-user | ||
|
||
WORKDIR /home/build-user | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Dockerfile-based build for Swift Android SDK | ||
|
||
This is a Dockerfile-based build set-up for the Swift Android SDK. | ||
|
||
The top-level `./build-docker` script will create a | ||
Docker container and install a host toolchain and the | ||
Android NDK, and then invoke `scripts/fetch-source.sh` which will | ||
fetch tagged sources for libxml2, curl, boringssl, and swift. | ||
|
||
It can be run with: | ||
|
||
``` | ||
$ ./build-docker <version> <workdir> | ||
``` | ||
|
||
for example: | ||
|
||
``` | ||
$ ./build-docker release /tmp/android-sdk | ||
``` | ||
|
||
This will create an Ubuntu 24.04 container with the necessary dependencies | ||
to build the Android SDK, including a Swift host toolchain and the | ||
Android NDK that will be used for cross-compilation. | ||
|
||
The `version` argument can be one of the following values: | ||
|
||
| version | Swift version example | | ||
| --- | --- | | ||
| `release` | swift-6.1-RELEASE | | ||
| `swift-6.2-branch` | swift-6.2-DEVELOPMENT-SNAPSHOT-yyyy-mm-dd | | ||
| `development` | swift-DEVELOPMENT-SNAPSHOT-yyyy-mm-dd | | ||
|
||
> [!WARNING] | ||
> The workdir argument must not be located in a git repository (e.g., it cannot be the | ||
> current directory) | ||
|
||
## Running | ||
|
||
The top-level `./build-docker` script installs a host toolchain and the | ||
Android NDK, and then invokes `scripts/fetch-source.sh` which will | ||
fetch tagged sources for libxml2, curl, boringssl, and swift. | ||
|
||
It then applies some patches and invokes `scripts/build.sh`, | ||
which will build the sources for each of the specified | ||
architectures and then combines the SDKs into a single | ||
artifactbundle with targetTriples for each of the supported | ||
architectures (`aarch64`, `x86_64`, `aarmv7`) | ||
and Android API levels (28-35). | ||
|
||
## Specifying Architectures | ||
|
||
By default all the supported Android architectures | ||
will be built, but this can be reduced in order to speed | ||
up the build. This can be useful, e.g., as part of a CI that | ||
validates a pull request, as building a single architecture | ||
takes around 30 minutes on a standard ubuntu-24.04 GitHub runner, | ||
whereas building for all the architectures takes over an hour. | ||
|
||
To build an artifactbundle for just the `x86_64` architecture, run: | ||
|
||
``` | ||
TARGET_ARCHS=x86_64 ./build-docker release /tmp/android-sdk | ||
``` | ||
|
||
## Installing and validating the SDK | ||
|
||
The `.github/workflows/pull_request.yml` workflow | ||
will create and upload an installable SDK named something like: | ||
`swift-6.1-RELEASE_android-0.1.artifactbundle.tar.gz` | ||
|
||
The GitHub workflow will also install the SDK locally and use | ||
[swift-android-action](https://github.com/marketplace/actions/swift-android-action) | ||
to build and test various Swift packages in an Android emulator using the | ||
freshly-created SDK bundle. | ||
|
||
## Building locally | ||
|
||
Instead of building within a Docker container, the script can also | ||
perform the build locally on an Ubuntu 24.04 machine with all the | ||
build prerequisites already installed. This will generate | ||
the same artifacts in approximately half the time, and | ||
may be suitable to an already containerized envrionment (such as | ||
a GitHub runner). | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned about running this on every PR against the swift-docker repository.
At the moment, testing on this repo takes a few minutes maximum, while I suspect that this will increase that it pretty substantially. It might be good to either limit running it to changes to the android subdirectory, or we should make this a dedicated job on Swift CI like the static Linux Musl SDK instead.
CC @shahmishal, @justice-adams-apple
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, actually, that
android-build
CI part was intended to be expunged before this PR would be merged. 😊It is just there so we can exercise updates to the pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that sounds good to me. Either Justice or I can probably use it as a template for setting up the Jenkins job if we have questions later, so useful to have in history.