diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 13c57b39..d5610edb 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -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 diff --git a/.gitmodules b/.gitmodules index f3724176..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/swift-ci/sdks/android/Dockerfile b/swift-ci/sdks/android/Dockerfile index 2be3fc37..c1d8c6db 100644 --- a/swift-ci/sdks/android/Dockerfile +++ b/swift-ci/sdks/android/Dockerfile @@ -24,7 +24,6 @@ RUN apt-get -q update \ golang \ git \ gnupg2 \ - libsqlite3-dev \ libcurl4-openssl-dev \ libedit-dev \ libicu-dev \ @@ -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 diff --git a/swift-ci/sdks/android/resources/patches b/swift-ci/sdks/android/resources/patches deleted file mode 160000 index d0828093..00000000 --- a/swift-ci/sdks/android/resources/patches +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d08280938ff70b790bbd0f559c0b420b518877ca diff --git a/swift-ci/sdks/android/scripts/build.sh b/swift-ci/sdks/android/scripts/build.sh index 20877272..b82c36ad 100755 --- a/swift-ci/sdks/android/scripts/build.sh +++ b/swift-ci/sdks/android/scripts/build.sh @@ -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 \ @@ -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 @@ -337,6 +338,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" \ -DOPENSSL_ROOT_DIR=$sdk_root/usr \ -DOPENSSL_INCLUDE_DIR=$sdk_root/usr/include \ -DOPENSSL_SSL_LIBRARY=$sdk_root/usr/lib/libssl.a \ @@ -344,6 +346,7 @@ for arch in $archs; do -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 \ @@ -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: @@ -616,6 +620,7 @@ cat > swift-toolset.json </dev/null -[[ -d swift ]] || git clone ${github}apple/swift.git +[[ -d swift ]] || git clone ${github}swiftlang/swift.git cd swift # Get its dependencies @@ -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 diff --git a/swift-ci/sdks/android/scripts/patch-sources.sh b/swift-ci/sdks/android/scripts/patch-sources.sh index ee425c6a..1282c706 100755 --- a/swift-ci/sdks/android/scripts/patch-sources.sh +++ b/swift-ci/sdks/android/scripts/patch-sources.sh @@ -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 @@ -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