Skip to content

Commit 78c5f7a

Browse files
committed
1 parent ca2b1a1 commit 78c5f7a

File tree

4 files changed

+59
-48
lines changed

4 files changed

+59
-48
lines changed

swift-ci/sdks/android/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ RUN chmod ugo+x /scripts/install-swift.sh
6767
RUN /scripts/install-swift.sh
6868
ENV PATH="/usr/local/swift/bin:${PATH}"
6969

70-
ARG NDK_VERSION=android-ndk-r27c
70+
ARG ANDROID_NDK_VERSION=android-ndk-r27c
7171

72-
ENV NDK_VERSION=$NDK_VERSION
72+
ENV ANDROID_NDK_VERSION=$ANDROID_NDK_VERSION
7373

7474
COPY scripts/install-ndk.sh /scripts/install-ndk.sh
7575
RUN chmod ugo+x /scripts/install-ndk.sh
7676
RUN /scripts/install-ndk.sh
77-
ENV ANDROID_NDK_HOME="/usr/local/ndk/${NDK_VERSION}"
77+
ENV ANDROID_NDK_HOME="/usr/local/ndk/${ANDROID_NDK_VERSION}"
7878

7979
ENV SWIFT_VERSION=$SWIFT_VERSION \
8080
LIBXML2_VERSION=$LIBXML2_VERSION \

swift-ci/sdks/android/build

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,34 @@ esac
2525

2626
case "${BUILD_VERSION}" in
2727
release)
28-
SWIFT_BRANCH="swift-6.1-branch"
28+
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/releases | grep -m1 swift-6.1 | cut -d- -f2)
29+
SWIFT_TAG="swift-${LATEST_TOOLCHAIN_VERSION}-RELEASE"
30+
SWIFT_BRANCH="swift-$(echo $SWIFT_TAG | cut -d- -f2)-release"
2931
;;
3032
devel)
31-
SWIFT_BRANCH="swift-6.2-branch"
33+
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/tags | grep -m1 swift-6.2-DEV | cut -d- -f8-10)
34+
SWIFT_TAG="swift-6.2-DEVELOPMENT-SNAPSHOT-${LATEST_TOOLCHAIN_VERSION}-a"
35+
SWIFT_BRANCH="swift-$(echo $SWIFT_TAG | cut -d- -f2)-branch"
3236
;;
3337
trunk)
38+
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/tags | grep -m1 swift-DEV | cut -d- -f7-9)
39+
SWIFT_TAG="swift-DEVELOPMENT-SNAPSHOT-${LATEST_TOOLCHAIN_VERSION}-a"
3440
SWIFT_BRANCH="development"
3541
;;
3642
*)
37-
echo "Unknown build version: ${BUILD_VERSION}"
43+
echo "$0: invalid BUILD_VERSION=${BUILD_VERSION}"
3844
exit 1
3945
;;
4046
esac
4147

48+
ANDROID_API=28
49+
ANDROID_NDK_VERSION=android-ndk-r27c
50+
4251
# Build the Docker image
43-
$DOCKER build --build-arg OS_ARCH_SUFFIX=$OS_ARCH_SUFFIX --build-arg SWIFT_BRANCH=$SWIFT_BRANCH -t swift-android .
52+
$DOCKER build --build-arg OS_ARCH_SUFFIX=$OS_ARCH_SUFFIX --build-arg SWIFT_BRANCH=$SWIFT_BRANCH --build-arg ANDROID_NDK_VERSION=$ANDROID_NDK_VERSION -t swift-android .
4453

4554
# Check-out the sources
46-
scripts/fetch-source.sh --source-dir source
55+
scripts/fetch-source.sh --source-dir source --swift-tag ${SWIFT_TAG}
4756

4857
mkdir -p products
4958

@@ -52,4 +61,4 @@ $DOCKER run -it --rm \
5261
-v ./source:/source \
5362
-v ./products:/products \
5463
swift-android \
55-
/scripts/build.sh --source-dir /source --products-dir /products
64+
/scripts/build.sh --source-dir /source --products-dir /products --android-api ${ANDROID_API} --host-toolchain /usr/local/swift --archs ${TARGET_ARCHS}

swift-ci/sdks/android/build-local

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,29 @@ HOST_OS=ubuntu$(lsb_release -sr)
1616

1717
#BUILD_VERSION='release'
1818
#BUILD_VERSION='trunk'
19-
BUILD_VERSION=${BUILD_VERSION:-'devel'}
20-
21-
if [ "${BUILD_VERSION}" = 'release' ]; then
22-
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/releases | grep -m1 swift-6.1 | cut -d- -f2)
23-
SWIFT_TAG="swift-${LATEST_TOOLCHAIN_VERSION}-RELEASE"
24-
SWIFT_BRANCH="swift-$(echo $SWIFT_TAG | cut -d- -f2)-release"
25-
elif [ "${BUILD_VERSION}" = 'devel' ]; then
26-
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/tags | grep -m1 swift-6.2-DEV | cut -d- -f8-10)
27-
SWIFT_TAG="swift-6.2-DEVELOPMENT-SNAPSHOT-${LATEST_TOOLCHAIN_VERSION}-a"
28-
SWIFT_BRANCH="swift-$(echo $SWIFT_TAG | cut -d- -f2)-branch"
29-
elif [ "${BUILD_VERSION}" = 'trunk' ]; then
30-
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/tags | grep -m1 swift-DEV | cut -d- -f7-9)
31-
SWIFT_TAG="swift-DEVELOPMENT-SNAPSHOT-${LATEST_TOOLCHAIN_VERSION}-a"
32-
SWIFT_BRANCH="development"
33-
else
34-
echo "$0: invalid BUILD_VERSION=${BUILD_VERSION}"
35-
exit 1
36-
fi
19+
#BUILD_VERSION=${BUILD_VERSION:-'devel'}
20+
21+
case "${BUILD_VERSION}" in
22+
release)
23+
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/releases | grep -m1 swift-6.1 | cut -d- -f2)
24+
SWIFT_TAG="swift-${LATEST_TOOLCHAIN_VERSION}-RELEASE"
25+
SWIFT_BRANCH="swift-$(echo $SWIFT_TAG | cut -d- -f2)-release"
26+
;;
27+
devel)
28+
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/tags | grep -m1 swift-6.2-DEV | cut -d- -f8-10)
29+
SWIFT_TAG="swift-6.2-DEVELOPMENT-SNAPSHOT-${LATEST_TOOLCHAIN_VERSION}-a"
30+
SWIFT_BRANCH="swift-$(echo $SWIFT_TAG | cut -d- -f2)-branch"
31+
;;
32+
trunk)
33+
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/tags | grep -m1 swift-DEV | cut -d- -f7-9)
34+
SWIFT_TAG="swift-DEVELOPMENT-SNAPSHOT-${LATEST_TOOLCHAIN_VERSION}-a"
35+
SWIFT_BRANCH="development"
36+
;;
37+
*)
38+
echo "$0: invalid BUILD_VERSION=${BUILD_VERSION}"
39+
exit 1
40+
;;
41+
esac
3742

3843
SWIFT_BASE=$SWIFT_TAG-$HOST_OS
3944

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

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -238,38 +238,36 @@ function run() {
238238
header "Patching Sources"
239239

240240
quiet_pushd ${source_dir}/swift-project
241-
patch="${patches_dir}/swift-android.patch"
241+
swift_android_patch="${patches_dir}/swift-android.patch"
242242

243243
# patch the patch, which seems to only be needed for an API less than 28
244244
# https://github.com/finagolfin/swift-android-sdk/blob/main/swift-android.patch#L110
245-
perl -pi -e 's/#if os\(Windows\)/#if os\(Android\)/g' $patch
245+
perl -pi -e 's/#if os\(Windows\)/#if os\(Android\)/g' $swift_android_patch
246246

247247
# remove the need to link in android-execinfo
248-
perl -pi -e 's/dispatch android-execinfo/dispatch/g' $patch
249-
250-
if git apply --reverse --check "$patch" ; then
251-
echo "already patched"
252-
elif git apply "$patch" ; then
253-
echo "done"
254-
else
255-
echo "failed"
256-
exit 1
257-
fi
248+
perl -pi -e 's/dispatch android-execinfo/dispatch/g' $swift_android_patch
258249

259250
if [ "${BUILD_VERSION}" = 'release' ]; then
260251
testing_patch="${patches_dir}/swift-android-testing-release.patch"
261252
else
262253
testing_patch="${patches_dir}/swift-android-testing-except-release.patch"
263254
fi
264255

265-
if git apply --reverse --check "$testing_patch" ; then
266-
echo "already patched"
267-
elif git apply "$testing_patch" ; then
268-
echo "done"
269-
else
270-
echo "failed"
271-
exit 1
272-
fi
256+
for patch in "$swift_android_patch" "$testing_patch"; do
257+
echo "applying patch $patch in $PWD"
258+
259+
if git apply --reverse --check "$patch" >/dev/null 2>&1 ; then
260+
echo "already patched"
261+
elif git apply "$patch" ; then
262+
echo "done"
263+
else
264+
echo "failed to apply patch $patch in $PWD"
265+
# tolerate failed patches in trunk for now
266+
if [[ "${BUILD_VERSION}" != 'trunk' ]]; then
267+
exit 1
268+
fi
269+
fi
270+
done
273271

274272
perl -pi -e 's%String\(cString: getpass%\"fake\" //%' swiftpm/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift
275273
# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport)
@@ -689,4 +687,3 @@ if [[ -z "$SWIFT_ANDROID_ARCHIVEONLY" ]]; then
689687
fi
690688

691689
groupend
692-

0 commit comments

Comments
 (0)