diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1a4b5833..88a19bdb 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -27,14 +27,14 @@ jobs: strategy: fail-fast: false matrix: - build-type: ['docker'] - #build-type: ['docker', 'local'] + #build-type: ['docker'] + build-type: ['docker', 'local'] # blank arch builds all (aarch64,x86_64,armv7) - arch: [''] + #arch: [''] # builds only x86_64 to speed up the validation #arch: ['x86_64'] # build both the quick (x86_64) and complete (aarch64,x86_64,armv7) SDKs - #arch: ['x86_64', ''] + arch: ['x86_64', ''] swift-version: ['release', 'swift-6.2-branch', 'development'] runs-on: ubuntu-24.04 steps: diff --git a/swift-ci/sdks/android/build-docker b/swift-ci/sdks/android/build-docker index ef283152..17a18820 100755 --- a/swift-ci/sdks/android/build-docker +++ b/swift-ci/sdks/android/build-docker @@ -27,7 +27,7 @@ source ./scripts/toolchain-vars.sh # Check-out and patch the sources ./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-tag ${SWIFT_TAG} -./scripts/patch-sources.sh ${WORKDIR}/source +${WORKDIR}/source/swift-android-patches/apply-patches.sh ${WORKDIR}/source/swift-project mkdir -p ${WORKDIR}/products chmod ugo+rwx ${WORKDIR}/products diff --git a/swift-ci/sdks/android/build-local b/swift-ci/sdks/android/build-local index 3a5e448d..8311ecb1 100755 --- a/swift-ci/sdks/android/build-local +++ b/swift-ci/sdks/android/build-local @@ -50,7 +50,7 @@ fi # Check-out and patch the sources ./scripts/fetch-source.sh --source-dir ${WORKDIR}/source --swift-tag ${SWIFT_TAG} -./scripts/patch-sources.sh ${WORKDIR}/source +${WORKDIR}/source/swift-android-patches/apply-patches.sh ${WORKDIR}/source/swift-project mkdir -p ${WORKDIR}/products diff --git a/swift-ci/sdks/android/scripts/build.sh b/swift-ci/sdks/android/scripts/build.sh index b82c36ad..6e7f1714 100755 --- a/swift-ci/sdks/android/scripts/build.sh +++ b/swift-ci/sdks/android/scripts/build.sh @@ -186,6 +186,8 @@ function versionFromTag { } 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) + if [[ $swift_version == swift-* ]]; then swift_version=${swift_version#swift-} fi @@ -631,8 +633,13 @@ header "Outputting compressed bundle" quiet_pushd "${build_dir}" mkdir -p "${products_dir}" - tar czf "${bundle}.tar.gz" "${bundle}" - mv "${bundle}.tar.gz" "${products_dir}" + # set the timestamps of every file in the artifact to the tag date for the swift repo for build reproducibility + touch_date=$(date -d "@$swift_tag_date" "+%Y%m%d%H%M.%S") + find "${bundle}" -exec touch -t "$touch_date" {} + + + bundle_archive="${products_dir}/${bundle}.tar.gz" + tar czf "${bundle_archive}" "${bundle}" + shasum -a 256 "${bundle_archive}" quiet_popd groupend diff --git a/swift-ci/sdks/android/scripts/patch-sources.sh b/swift-ci/sdks/android/scripts/patch-sources.sh deleted file mode 100755 index efced711..00000000 --- a/swift-ci/sdks/android/scripts/patch-sources.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# Swift Android SDK: Patch Sources -set -e - -source_dir=$1 -if [[ ! -d "${source_dir}" ]]; then - echo "$0: source_dir ${source_dir} does not exist" - exit 1 -fi - -patches_dir="${source_dir}/swift-android-patches" -if [[ ! -d "${patches_dir}" ]]; then - echo "$0: patches_dir ${patches_dir} does not exist" - exit 1 -fi - -cd ${source_dir}/swift-project -swift_android_patch="${patches_dir}/swift-android.patch" - -# 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 - -# remove the need to link in android-execinfo -perl -pi -e 's;dispatch android-execinfo;dispatch;g' $swift_android_patch - -# debug symbolic link setup -perl -pi -e 's;call ln -sf;call ln -svf;g' $swift_android_patch -perl -pi -e 's%linux-x86_64/sysroot/usr/lib"%linux-x86_64/sysroot/usr/lib"; echo "VALIDATING SYMBOLIC LINK"; ls -la "\${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib"; ls -la "\${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/swift"; %g' $swift_android_patch - -case "${BUILD_SCHEME}" in - release) - testing_patch="${patches_dir}/swift-android-testing-release.patch" - ;; - swift-*-branch) - testing_patch="${patches_dir}/swift-android-testing-except-release.patch" - ;; - development) - testing_patch="${patches_dir}/swift-android-testing-except-release.patch" - dispatch_patch="${patches_dir}/swift-android-trunk-libdispatch.patch" - ;; - *) - echo "$0: invalid BUILD_SCHEME=${BUILD_SCHEME}" - exit 1 - ;; -esac - -for patch in "$swift_android_patch" "$testing_patch" "$dispatch_patch"; do - if [[ "${patch}" == "" ]]; then - continue - fi - - echo "applying patch $patch in $PWD…" - # first check to make sure the patches can apply and fail if not - git apply -v --check -C1 "$patch" - git apply --no-index -v -C1 "$patch" - - #if git apply -C1 --reverse --check "$patch" >/dev/null 2>&1 ; then - # echo "already patched" - #elif git apply -C1 "$patch" ; then - # echo "done" - #else - # echo "failed to apply patch $patch in $PWD" - # exit 1 - #fi -done - -perl -pi -e 's%String\(cString: getpass%\"fake\" //%' swiftpm/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift -# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport) -perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift - -# need to un-apply libandroid-spawn since we don't need it for API28+ -perl -pi -e 's;MATCHES "Android";MATCHES "AndroidDISABLED";g' llbuild/lib/llvm/Support/CMakeLists.txt -perl -pi -e 's; STREQUAL Android\); STREQUAL AndroidDISABLED\);g' swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt - -# validate the patches -ls -la swift/utils/build-script-impl -grep 'VALIDATING SYMBOLIC LINK' swift/utils/build-script-impl - diff --git a/swift-ci/sdks/android/scripts/toolchain-vars.sh b/swift-ci/sdks/android/scripts/toolchain-vars.sh index 010f7dd2..39868951 100644 --- a/swift-ci/sdks/android/scripts/toolchain-vars.sh +++ b/swift-ci/sdks/android/scripts/toolchain-vars.sh @@ -17,19 +17,16 @@ OS=$(echo $HOST_OS | tr -d '.') case "${BUILD_SCHEME}" in release) # e.g., "swift-6.1-RELEASE" - SWIFT_TAG=$(curl -fsSL https://www.swift.org/api/v1/install/releases.json | jq -r '.[-1].tag') + # there is no latest-build.yml for releases, so we need to get it from the API + export SWIFT_TAG=$(curl -fsSL https://www.swift.org/api/v1/install/releases.json | jq -r '.[-1].tag') # e.g., "swift-6.1-release" - SWIFT_BRANCH=$(echo "${SWIFT_TAG}" | tr '[A-Z]' '[a-z]') + export SWIFT_BRANCH=$(echo "${SWIFT_TAG}" | tr '[A-Z]' '[a-z]') ;; - swift-*-branch) + development|swift-*-branch) # e.g., swift-6.2-DEVELOPMENT-SNAPSHOT-2025-05-15-a - SWIFT_TAG=$(curl -fsSL https://download.swift.org/$BUILD_SCHEME/$OS/latest-build.yml | grep '^dir: ' | cut -f 2 -d ' ') - SWIFT_BRANCH=$BUILD_SCHEME - ;; - development) # e.g., swift-DEVELOPMENT-SNAPSHOT-2025-05-14-a - SWIFT_TAG=$(curl -fsSL https://download.swift.org/development/$OS/latest-build.yml | grep '^dir: ' | cut -f 2 -d ' ') - SWIFT_BRANCH="development" + export SWIFT_TAG=$(curl -fsSL https://download.swift.org/$BUILD_SCHEME/$OS/latest-build.yml | grep '^dir: ' | cut -f 2 -d ' ') + export SWIFT_BRANCH=$BUILD_SCHEME ;; *) echo "$0: invalid BUILD_SCHEME=${BUILD_SCHEME}"