Skip to content

Remove unnecessary source checkouts #11

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

Merged
merged 6 commits into from
Jul 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ jobs:
fail-fast: false
matrix:
include:
#- swift-version: 'swift-6.2-branch'
# build-type: 'docker'
# build-compiler: '1'
# runner: 'self-hosted'
#- swift-version: 'development'
# build-type: 'docker'
# build-compiler: '1'
# runner: 'self-hosted'
- swift-version: 'swift-6.2-branch'
build-type: 'docker'
build-compiler: '1'
runner: 'self-hosted'
build-compiler: '0'
runner: 'ubuntu-24.04'
- swift-version: 'development'
build-type: 'docker'
build-compiler: '1'
runner: 'self-hosted'
build-compiler: '0'
runner: 'ubuntu-24.04'
- swift-version: 'swift-6.2-branch'
build-type: 'docker'
build-compiler: '0'
Expand Down
1 change: 1 addition & 0 deletions swift-ci/sdks/android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ RUN groupadd -g 998 build-user && \
USER build-user

WORKDIR /home/build-user

28 changes: 9 additions & 19 deletions swift-ci/sdks/android/build-docker
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ TARGET_ARCHS=${TARGET_ARCHS:-aarch64,x86_64,armv7}
ANDROID_NDK_VERSION=android-ndk-r27c
ANDROID_API=28

BASEPATH=$(dirname $(realpath $0))
cd ${BASEPATH}

export BUILD_SCHEME=${1}
# note that WORKDIR must not be under the current checkout or the patches will fail to apply
WORKDIR=${2}
Expand All @@ -27,13 +30,13 @@ source ./scripts/toolchain-vars.sh

# Check-out and patch the sources
if [[ "${BUILD_COMPILER}" != "1" ]]; then
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-tag ${SWIFT_TAG}
else
if [[ "${BUILD_SCHEME}" == "development" ]]; then
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-scheme main
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-tag ${SWIFT_TAG}
else
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-scheme release/6.2
fi
if [[ "${BUILD_SCHEME}" == "development" ]]; then
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-scheme main
else
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-scheme release/6.2
fi
fi
./patches/apply-patches.sh ${WORKDIR}/source/swift-project

Expand All @@ -44,19 +47,6 @@ if [[ "$DOCKER" == "" ]]; then
DOCKER=docker
fi

case $(arch) in
arm64|aarch64)
OS_ARCH_SUFFIX=-aarch64
;;
amd64|x86_64)
OS_ARCH_SUFFIX=
;;
*)
echo "Unknown architecture $(arch)"
exit 1
;;
esac

CONTAINER_NAME="swift-android"

# Build the Docker image
Expand Down
3 changes: 3 additions & 0 deletions swift-ci/sdks/android/build-local
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ TARGET_ARCHS=${TARGET_ARCHS:-aarch64,x86_64,armv7}
ANDROID_NDK_VERSION=android-ndk-r27c
ANDROID_API=28

BASEPATH=$(dirname $(realpath $0))
cd ${BASEPATH}

export BUILD_SCHEME=${1}
# note that WORKDIR must not be under the current checkout or the patches will fail to apply
WORKDIR=${2}
Expand Down
23 changes: 13 additions & 10 deletions swift-ci/sdks/android/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ function versionFromTag {
fi
}

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

swift_version=$(describe ${swift_source_dir}/swift)
swift_tag_date=$(git -C ${swift_source_dir}/swift log -1 --format=%ct 2>/dev/null)

if [[ $swift_version == swift-* ]]; then
swift_version=${swift_version#swift-}
Expand All @@ -199,9 +201,9 @@ if [[ -z "$sdk_name" ]]; then
sdk_name=swift-${swift_version}-android-${android_sdk_version}
fi

libxml2_version=$(versionFromTag ${source_dir}/libxml2)
libxml2_version=$(versionFromTag ${swift_source_dir}/libxml2)

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

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

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

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

groupstart "Building libxml2 for $arch"
quiet_pushd ${source_dir}/libxml2
quiet_pushd ${swift_source_dir}/libxml2
run cmake \
-G Ninja \
-S ${source_dir}/libxml2 \
-S ${swift_source_dir}/libxml2 \
-B ${build_dir}/$arch/libxml2 \
-DANDROID_ABI=$android_abi \
-DANDROID_PLATFORM=android-$android_api \
Expand Down Expand Up @@ -355,10 +358,10 @@ for arch in $archs; do
groupend

groupstart "Building libcurl for ${compiler_target_host}"
quiet_pushd ${source_dir}/curl
quiet_pushd ${swift_source_dir}/curl
run cmake \
-G Ninja \
-S ${source_dir}/curl \
-S ${swift_source_dir}/curl \
-B ${build_dir}/$arch/curl \
-DANDROID_ABI=$android_abi \
-DANDROID_PLATFORM=android-$android_api \
Expand Down Expand Up @@ -395,7 +398,7 @@ for arch in $archs; do
groupend

groupstart "Building Android SDK for ${compiler_target_host}"
quiet_pushd ${source_dir}/swift-project
quiet_pushd ${swift_source_dir}
build_type_flag="--debug"
case $build_type in
Debug) build_type_flag="--debug" ;;
Expand Down Expand Up @@ -522,7 +525,7 @@ for arch in $archs; do
quiet_pushd ${sdk_staging}/${arch}/usr
rm -r bin
rm -r include/*
cp -r ${source_dir}/swift-project/swift/lib/ClangImporter/SwiftBridging/{module.modulemap,swift} include/
cp -r ${swift_source_dir}/swift/lib/ClangImporter/SwiftBridging/{module.modulemap,swift} include/

arch_triple="$arch-linux-android"
if [[ $arch == 'armv7' ]]; then
Expand Down
42 changes: 0 additions & 42 deletions swift-ci/sdks/android/scripts/fetch-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function usage {
cat <<EOF
usage: fetch-source.sh [--swift-scheme <scheme>|--swift-tag <tag>
|--swift-version <version>]
[--curl-version <version>]
[--boringssl-version <version>]
[--clone-with-ssh]
[--source-dir <path>]
Expand All @@ -70,8 +69,6 @@ SDK for Swift. Options are:
If <version> starts with "scheme:" or "tag:", it will
select a scheme or tag; otherwise it will be treated as
a version number.
--libxml2-version <version>
--curl-version <version>
--boringssl-version <version>
EOF
}
Expand All @@ -80,18 +77,9 @@ EOF
if [[ -z "${SWIFT_VERSION}" ]]; then
SWIFT_VERSION=scheme:release/6.1
fi
if [[ -z "${LIBXML2_VERSION}" ]]; then
LIBXML2_VERSION=2.14.2
fi
if [[ -z "${CURL_VERSION}" ]]; then
CURL_VERSION=8.13.0
fi
if [[ -z "${BORINGSSL_VERSION}" ]]; then
BORINGSSL_VERSION=fips-20220613
fi
if [[ -z "${YAMS_VERSION}" ]]; then
YAMS_VERSION=5.0.6
fi

clone_with_ssh=false
while [ "$#" -gt 0 ]; do
Expand All @@ -102,10 +90,6 @@ while [ "$#" -gt 0 ]; do
SWIFT_VERSION="tag:$2"; shift ;;
--swift-version)
SWIFT_VERSION="$2"; shift ;;
--libxml2-version)
LIBXML2_VERSION="$2"; shift ;;
--curl-version)
CURL_VERSION="$2"; shift ;;
--boringssl-version)
BORINGSSL_VERSION="$2"; shift ;;
--clone-with-ssh)
Expand Down Expand Up @@ -158,32 +142,6 @@ fi
popd >/dev/null
groupend

# Fetch yams (needed for Swift 6.1.x)
groupstart "Fetching yams"
pushd swift-project >/dev/null
[[ -d yams ]] || git clone ${github}jpsim/Yams.git yams
pushd yams >/dev/null 2>&1
git checkout ${YAMS_VERSION}
popd >/dev/null 2>&1
popd >/dev/null
groupend

# Fetch libxml2
groupstart "Fetching libxml2"
[[ -d libxml2 ]] || git clone ${github}GNOME/libxml2.git
pushd libxml2 >/dev/null 2>&1
git checkout v${LIBXML2_VERSION}
popd >/dev/null 2>&1
groupend

# Fetch curl
groupstart "Fetching curl"
[[ -d curl ]] || git clone ${github}curl/curl.git
pushd curl >/dev/null 2>&1
git checkout curl-$(echo ${CURL_VERSION} | tr '.' '_')
popd >/dev/null 2>&1
groupend

# Fetch BoringSSL
groupstart "Fetching BoringSSL"
[[ -d boringssl ]] || git clone https://boringssl.googlesource.com/boringssl
Expand Down
19 changes: 17 additions & 2 deletions swift-ci/sdks/android/scripts/toolchain-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,26 @@ case "${BUILD_SCHEME}" in
esac

SWIFT_BASE=$SWIFT_TAG-$HOST_OS

case $(arch) in
arm64|aarch64)
export OS_ARCH_SUFFIX=-aarch64
;;
amd64|x86_64)
export OS_ARCH_SUFFIX=
;;
*)
echo "Unknown architecture $(arch)"
exit 1
;;
esac


case $BUILD_COMPILER in
1|true|yes|YES)
export SWIFT_TOOLCHAIN_URL="https://download.swift.org/$RELEASE_BRANCH/$OS/$RELEASE_TAG/$RELEASE_TAG-$HOST_OS.tar.gz"
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"
;;
*)
export SWIFT_TOOLCHAIN_URL="https://download.swift.org/$SWIFT_BRANCH/$OS/$SWIFT_TAG/$SWIFT_BASE.tar.gz"
export SWIFT_TOOLCHAIN_URL="https://download.swift.org/$SWIFT_BRANCH/$OS$OS_ARCH_SUFFIX/$SWIFT_TAG/$SWIFT_BASE$OS_ARCH_SUFFIX.tar.gz"
;;
esac
Loading