Skip to content

Commit bc3f105

Browse files
authored
Merge pull request #11 from swift-android-sdk/update-patches2
Remove unnecessary source checkouts
2 parents ed09034 + 22a4320 commit bc3f105

File tree

7 files changed

+55
-77
lines changed

7 files changed

+55
-77
lines changed

.github/workflows/pull_request.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
include:
31+
#- swift-version: 'swift-6.2-branch'
32+
# build-type: 'docker'
33+
# build-compiler: '1'
34+
# runner: 'self-hosted'
35+
#- swift-version: 'development'
36+
# build-type: 'docker'
37+
# build-compiler: '1'
38+
# runner: 'self-hosted'
3139
- swift-version: 'swift-6.2-branch'
3240
build-type: 'docker'
33-
build-compiler: '1'
34-
runner: 'self-hosted'
41+
build-compiler: '0'
42+
runner: 'ubuntu-24.04'
3543
- swift-version: 'development'
3644
build-type: 'docker'
37-
build-compiler: '1'
38-
runner: 'self-hosted'
45+
build-compiler: '0'
46+
runner: 'ubuntu-24.04'
3947
- swift-version: 'swift-6.2-branch'
4048
build-type: 'docker'
4149
build-compiler: '0'

swift-ci/sdks/android/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ RUN groupadd -g 998 build-user && \
8585
USER build-user
8686

8787
WORKDIR /home/build-user
88+

swift-ci/sdks/android/build-docker

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ TARGET_ARCHS=${TARGET_ARCHS:-aarch64,x86_64,armv7}
1212
ANDROID_NDK_VERSION=android-ndk-r27c
1313
ANDROID_API=28
1414

15+
BASEPATH=$(dirname $(realpath $0))
16+
cd ${BASEPATH}
17+
1518
export BUILD_SCHEME=${1}
1619
# note that WORKDIR must not be under the current checkout or the patches will fail to apply
1720
WORKDIR=${2}
@@ -27,13 +30,13 @@ source ./scripts/toolchain-vars.sh
2730

2831
# Check-out and patch the sources
2932
if [[ "${BUILD_COMPILER}" != "1" ]]; then
30-
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-tag ${SWIFT_TAG}
31-
else
32-
if [[ "${BUILD_SCHEME}" == "development" ]]; then
33-
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-scheme main
33+
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-tag ${SWIFT_TAG}
3434
else
35-
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-scheme release/6.2
36-
fi
35+
if [[ "${BUILD_SCHEME}" == "development" ]]; then
36+
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-scheme main
37+
else
38+
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-scheme release/6.2
39+
fi
3740
fi
3841
./patches/apply-patches.sh ${WORKDIR}/source/swift-project
3942

@@ -44,19 +47,6 @@ if [[ "$DOCKER" == "" ]]; then
4447
DOCKER=docker
4548
fi
4649

47-
case $(arch) in
48-
arm64|aarch64)
49-
OS_ARCH_SUFFIX=-aarch64
50-
;;
51-
amd64|x86_64)
52-
OS_ARCH_SUFFIX=
53-
;;
54-
*)
55-
echo "Unknown architecture $(arch)"
56-
exit 1
57-
;;
58-
esac
59-
6050
CONTAINER_NAME="swift-android"
6151

6252
# Build the Docker image

swift-ci/sdks/android/build-local

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ TARGET_ARCHS=${TARGET_ARCHS:-aarch64,x86_64,armv7}
1212
ANDROID_NDK_VERSION=android-ndk-r27c
1313
ANDROID_API=28
1414

15+
BASEPATH=$(dirname $(realpath $0))
16+
cd ${BASEPATH}
17+
1518
export BUILD_SCHEME=${1}
1619
# note that WORKDIR must not be under the current checkout or the patches will fail to apply
1720
WORKDIR=${2}

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ function versionFromTag {
188188
fi
189189
}
190190

191-
swift_version=$(describe ${source_dir}/swift-project/swift)
192-
swift_tag_date=$(git -C ${source_dir}/swift-project/swift log -1 --format=%ct 2>/dev/null)
191+
swift_source_dir=${source_dir}/swift-project
192+
193+
swift_version=$(describe ${swift_source_dir}/swift)
194+
swift_tag_date=$(git -C ${swift_source_dir}/swift log -1 --format=%ct 2>/dev/null)
193195

194196
if [[ $swift_version == swift-* ]]; then
195197
swift_version=${swift_version#swift-}
@@ -199,9 +201,9 @@ if [[ -z "$sdk_name" ]]; then
199201
sdk_name=swift-${swift_version}-android-${android_sdk_version}
200202
fi
201203

202-
libxml2_version=$(versionFromTag ${source_dir}/libxml2)
204+
libxml2_version=$(versionFromTag ${swift_source_dir}/libxml2)
203205

204-
curl_desc=$(describe ${source_dir}/curl | tr '_' '.')
206+
curl_desc=$(describe ${swift_source_dir}/curl | tr '_' '.')
205207
curl_version=${curl_desc#curl-}
206208

207209
boringssl_version=$(describe ${source_dir}/boringssl)
@@ -217,6 +219,7 @@ header "Swift Android SDK build script"
217219

218220
swift_dir=$(realpath $(dirname "$swiftc")/..)
219221
HOST=linux-x86_64
222+
# The Linux NDK only supports x86
220223
#HOST=$(uname -s -m | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
221224

222225
# in a Docker container, the pre-installed NDK is read-only,
@@ -298,10 +301,10 @@ for arch in $archs; do
298301
mkdir -p "$sdk_root"
299302

300303
groupstart "Building libxml2 for $arch"
301-
quiet_pushd ${source_dir}/libxml2
304+
quiet_pushd ${swift_source_dir}/libxml2
302305
run cmake \
303306
-G Ninja \
304-
-S ${source_dir}/libxml2 \
307+
-S ${swift_source_dir}/libxml2 \
305308
-B ${build_dir}/$arch/libxml2 \
306309
-DANDROID_ABI=$android_abi \
307310
-DANDROID_PLATFORM=android-$android_api \
@@ -355,10 +358,10 @@ for arch in $archs; do
355358
groupend
356359

357360
groupstart "Building libcurl for ${compiler_target_host}"
358-
quiet_pushd ${source_dir}/curl
361+
quiet_pushd ${swift_source_dir}/curl
359362
run cmake \
360363
-G Ninja \
361-
-S ${source_dir}/curl \
364+
-S ${swift_source_dir}/curl \
362365
-B ${build_dir}/$arch/curl \
363366
-DANDROID_ABI=$android_abi \
364367
-DANDROID_PLATFORM=android-$android_api \
@@ -395,7 +398,7 @@ for arch in $archs; do
395398
groupend
396399

397400
groupstart "Building Android SDK for ${compiler_target_host}"
398-
quiet_pushd ${source_dir}/swift-project
401+
quiet_pushd ${swift_source_dir}
399402
build_type_flag="--debug"
400403
case $build_type in
401404
Debug) build_type_flag="--debug" ;;
@@ -522,7 +525,7 @@ for arch in $archs; do
522525
quiet_pushd ${sdk_staging}/${arch}/usr
523526
rm -r bin
524527
rm -r include/*
525-
cp -r ${source_dir}/swift-project/swift/lib/ClangImporter/SwiftBridging/{module.modulemap,swift} include/
528+
cp -r ${swift_source_dir}/swift/lib/ClangImporter/SwiftBridging/{module.modulemap,swift} include/
526529

527530
arch_triple="$arch-linux-android"
528531
if [[ $arch == 'armv7' ]]; then

swift-ci/sdks/android/scripts/fetch-source.sh

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ function usage {
5252
cat <<EOF
5353
usage: fetch-source.sh [--swift-scheme <scheme>|--swift-tag <tag>
5454
|--swift-version <version>]
55-
[--curl-version <version>]
5655
[--boringssl-version <version>]
5756
[--clone-with-ssh]
5857
[--source-dir <path>]
@@ -70,8 +69,6 @@ SDK for Swift. Options are:
7069
If <version> starts with "scheme:" or "tag:", it will
7170
select a scheme or tag; otherwise it will be treated as
7271
a version number.
73-
--libxml2-version <version>
74-
--curl-version <version>
7572
--boringssl-version <version>
7673
EOF
7774
}
@@ -80,18 +77,9 @@ EOF
8077
if [[ -z "${SWIFT_VERSION}" ]]; then
8178
SWIFT_VERSION=scheme:release/6.1
8279
fi
83-
if [[ -z "${LIBXML2_VERSION}" ]]; then
84-
LIBXML2_VERSION=2.14.2
85-
fi
86-
if [[ -z "${CURL_VERSION}" ]]; then
87-
CURL_VERSION=8.13.0
88-
fi
8980
if [[ -z "${BORINGSSL_VERSION}" ]]; then
9081
BORINGSSL_VERSION=fips-20220613
9182
fi
92-
if [[ -z "${YAMS_VERSION}" ]]; then
93-
YAMS_VERSION=5.0.6
94-
fi
9583

9684
clone_with_ssh=false
9785
while [ "$#" -gt 0 ]; do
@@ -102,10 +90,6 @@ while [ "$#" -gt 0 ]; do
10290
SWIFT_VERSION="tag:$2"; shift ;;
10391
--swift-version)
10492
SWIFT_VERSION="$2"; shift ;;
105-
--libxml2-version)
106-
LIBXML2_VERSION="$2"; shift ;;
107-
--curl-version)
108-
CURL_VERSION="$2"; shift ;;
10993
--boringssl-version)
11094
BORINGSSL_VERSION="$2"; shift ;;
11195
--clone-with-ssh)
@@ -158,32 +142,6 @@ fi
158142
popd >/dev/null
159143
groupend
160144

161-
# Fetch yams (needed for Swift 6.1.x)
162-
groupstart "Fetching yams"
163-
pushd swift-project >/dev/null
164-
[[ -d yams ]] || git clone ${github}jpsim/Yams.git yams
165-
pushd yams >/dev/null 2>&1
166-
git checkout ${YAMS_VERSION}
167-
popd >/dev/null 2>&1
168-
popd >/dev/null
169-
groupend
170-
171-
# Fetch libxml2
172-
groupstart "Fetching libxml2"
173-
[[ -d libxml2 ]] || git clone ${github}GNOME/libxml2.git
174-
pushd libxml2 >/dev/null 2>&1
175-
git checkout v${LIBXML2_VERSION}
176-
popd >/dev/null 2>&1
177-
groupend
178-
179-
# Fetch curl
180-
groupstart "Fetching curl"
181-
[[ -d curl ]] || git clone ${github}curl/curl.git
182-
pushd curl >/dev/null 2>&1
183-
git checkout curl-$(echo ${CURL_VERSION} | tr '.' '_')
184-
popd >/dev/null 2>&1
185-
groupend
186-
187145
# Fetch BoringSSL
188146
groupstart "Fetching BoringSSL"
189147
[[ -d boringssl ]] || git clone https://boringssl.googlesource.com/boringssl

swift-ci/sdks/android/scripts/toolchain-vars.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,26 @@ case "${BUILD_SCHEME}" in
3737
esac
3838

3939
SWIFT_BASE=$SWIFT_TAG-$HOST_OS
40+
41+
case $(arch) in
42+
arm64|aarch64)
43+
export OS_ARCH_SUFFIX=-aarch64
44+
;;
45+
amd64|x86_64)
46+
export OS_ARCH_SUFFIX=
47+
;;
48+
*)
49+
echo "Unknown architecture $(arch)"
50+
exit 1
51+
;;
52+
esac
53+
54+
4055
case $BUILD_COMPILER in
4156
1|true|yes|YES)
42-
export SWIFT_TOOLCHAIN_URL="https://download.swift.org/$RELEASE_BRANCH/$OS/$RELEASE_TAG/$RELEASE_TAG-$HOST_OS.tar.gz"
57+
export SWIFT_TOOLCHAIN_URL="https://download.swift.org/$RELEASE_BRANCH/$OS$OS_ARCH_SUFFIX/$RELEASE_TAG/$RELEASE_TAG-$HOST_OS$OS_ARCH_SUFFIX.tar.gz"
4358
;;
4459
*)
45-
export SWIFT_TOOLCHAIN_URL="https://download.swift.org/$SWIFT_BRANCH/$OS/$SWIFT_TAG/$SWIFT_BASE.tar.gz"
60+
export SWIFT_TOOLCHAIN_URL="https://download.swift.org/$SWIFT_BRANCH/$OS$OS_ARCH_SUFFIX/$SWIFT_TAG/$SWIFT_BASE$OS_ARCH_SUFFIX.tar.gz"
4661
;;
4762
esac

0 commit comments

Comments
 (0)