Skip to content

Checkout patches repo instead of using a git submodule #5

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 11 commits into from
May 19, 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
2 changes: 0 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ jobs:
echo "WORKDIR=${{ runner.temp }}/swift-android-sdk" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Build Android SDK (Local)
if: ${{ matrix.build-type == 'local' }}
working-directory: swift-ci/sdks/android
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "swift-ci/sdks/android/resources/patches"]
path = swift-ci/sdks/android/resources/patches
url = https://github.com/swift-android-sdk/swift-android-sdk
3 changes: 0 additions & 3 deletions swift-ci/sdks/android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ RUN apt-get -q update \
golang \
git \
gnupg2 \
libsqlite3-dev \
libcurl4-openssl-dev \
libedit-dev \
libicu-dev \
Expand Down Expand Up @@ -78,8 +77,6 @@ ENV SWIFT_BUILD_DOCKER="1"
COPY scripts /scripts
RUN chmod ugo+x /scripts/*

COPY resources /resources

# Create a user
RUN groupadd -g 998 build-user && \
useradd -m -r -u 998 -g build-user build-user
Expand Down
1 change: 0 additions & 1 deletion swift-ci/sdks/android/resources/patches
Submodule patches deleted from d08280
9 changes: 7 additions & 2 deletions swift-ci/sdks/android/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ for arch in $archs; do
-DANDROID_PLATFORM=android-$android_api \
-DCMAKE_TOOLCHAIN_FILE=$ndk_home/build/cmake/android.toolchain.cmake \
-DCMAKE_BUILD_TYPE=$build_type \
-DCMAKE_EXTRA_LINK_FLAGS="-rtlib=compiler-rt -unwindlib=libunwind -stdlib=libc++ -fuse-ld=lld -lc++ -lc++abi" \
-DCMAKE_EXTRA_LINK_FLAGS="-rtlib=compiler-rt -unwindlib=libunwind -stdlib=libc++ -fuse-ld=lld -lc++ -lc++abi -Wl,-z,max-page-size=16384" \
-DCMAKE_BUILD_TYPE=$build_type \
-DCMAKE_INSTALL_PREFIX=$sdk_root/usr \
-DLIBXML2_WITH_PYTHON=NO \
Expand Down Expand Up @@ -311,6 +311,7 @@ for arch in $archs; do
-DCMAKE_TOOLCHAIN_FILE=$ndk_home/build/cmake/android.toolchain.cmake \
-DCMAKE_BUILD_TYPE=$build_type \
-DCMAKE_INSTALL_PREFIX=$sdk_root/usr \
-DCMAKE_EXTRA_LINK_FLAGS="-Wl,-z,max-page-size=16384" \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DBUILD_TESTING=OFF
Expand All @@ -337,13 +338,15 @@ for arch in $archs; do
-DCMAKE_TOOLCHAIN_FILE=$ndk_home/build/cmake/android.toolchain.cmake \
-DCMAKE_BUILD_TYPE=$build_type \
-DCMAKE_INSTALL_PREFIX=$sdk_root/usr \
-DCMAKE_EXTRA_LINK_FLAGS="-Wl,-z,max-page-size=16384" \
-DOPENSSL_ROOT_DIR=$sdk_root/usr \
-DOPENSSL_INCLUDE_DIR=$sdk_root/usr/include \
-DOPENSSL_SSL_LIBRARY=$sdk_root/usr/lib/libssl.a \
-DOPENSSL_CRYPTO_LIBRARY=$sdk_root/usr/lib/libcrypto.a \
-DCURLSSLOPT_NATIVE_CA=ON \
-DCURL_USE_OPENSSL=ON \
-DCURL_USE_LIBSSH2=OFF \
-DCURL_USE_LIBPSL=OFF \
-DTHREADS_PREFER_PTHREAD_FLAG=OFF \
-DCMAKE_THREAD_PREFER_PTHREAD=OFF \
-DCMAKE_THREADS_PREFER_PTHREAD_FLAG=OFF \
Expand Down Expand Up @@ -399,7 +402,8 @@ for arch in $archs; do
--install-foundation \
--xctest --install-xctest \
--swift-testing --install-swift-testing \
--cross-compile-append-host-target-to-destdir=False
--cross-compile-append-host-target-to-destdir=False \
--extra-cmake-options='-DCMAKE_EXTRA_LINK_FLAGS="-Wl,-z,max-page-size=16384"'

# need to remove symlink that gets created in the NDK to the previous arch's build
# or else we get errors like:
Expand Down Expand Up @@ -616,6 +620,7 @@ cat > swift-toolset.json <<EOF
{
"cCompiler": { "extraCLIOptions": ["-fPIC"] },
"swiftCompiler": { "extraCLIOptions": ["-Xclang-linker", "-fuse-ld=lld"] },
"linker": { "extraCLIOptions": ["-z,max-page-size=16384"] },
"schemaVersion": "1.0"
}
EOF
Expand Down
18 changes: 13 additions & 5 deletions swift-ci/sdks/android/scripts/fetch-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,17 @@ if [[ -z "${SWIFT_VERSION}" ]]; then
SWIFT_VERSION=scheme:release/6.1
fi
if [[ -z "${LIBXML2_VERSION}" ]]; then
LIBXML2_VERSION=2.12.7
#LIBXML2_VERSION=2.14.2
LIBXML2_VERSION=2.14.2
fi
if [[ -z "${CURL_VERSION}" ]]; then
CURL_VERSION=8.7.1
#CURL_VERSION=8.13.0
CURL_VERSION=8.13.0
fi
if [[ -z "${BORINGSSL_VERSION}" ]]; then
BORINGSSL_VERSION=fips-20220613
fi
if [[ -z "${SWIFT_ANDROID_PATCHES_VERSION}" ]]; then
SWIFT_ANDROID_PATCHES_VERSION=main
fi

clone_with_ssh=false
while [ "$#" -gt 0 ]; do
Expand Down Expand Up @@ -139,7 +140,7 @@ mkdir -p swift-project
groupstart "Fetching Swift"
pushd swift-project >/dev/null

[[ -d swift ]] || git clone ${github}apple/swift.git
[[ -d swift ]] || git clone ${github}swiftlang/swift.git
cd swift

# Get its dependencies
Expand Down Expand Up @@ -181,3 +182,10 @@ git checkout ${BORINGSSL_VERSION}
popd >/dev/null 2>&1
groupend

# Fetch BoringSSL
groupstart "Fetching Patches"
[[ -d swift-android-patches ]] || git clone https://github.com/swift-android-sdk/swift-android-sdk swift-android-patches
pushd swift-android-patches >/dev/null 2>&1
git checkout ${SWIFT_ANDROID_PATCHES_VERSION}
popd >/dev/null 2>&1
groupend
10 changes: 1 addition & 9 deletions swift-ci/sdks/android/scripts/patch-sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
set -e

source_dir=$1

if [[ ! -d "${source_dir}" ]]; then
echo "$0: source_dir ${source_dir} does not exist"
exit 1
fi

script_dir=$(dirname -- "${BASH_SOURCE[0]}")
resource_dir=$(realpath "${script_dir}/../resources")
patches_dir="${resource_dir}/patches"

patches_dir="${source_dir}/swift-android-patches"
if [[ ! -d "${patches_dir}" ]]; then
echo "$0: patches_dir ${patches_dir} does not exist"
exit 1
Expand All @@ -21,10 +17,6 @@ fi
cd ${source_dir}/swift-project
swift_android_patch="${patches_dir}/swift-android.patch"

ls -la swift/utils/build-script-impl
ls -la ${swift_android_patch}
ls -la swiftpm/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift

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