diff --git a/.github/actions/build-for-distribution/action.yml b/.github/actions/build-for-distribution/action.yml index e95026e..13d1c0e 100644 --- a/.github/actions/build-for-distribution/action.yml +++ b/.github/actions/build-for-distribution/action.yml @@ -27,8 +27,6 @@ runs: name: Build Swift + SDK using Sysroot with: swift-tag: ${{ inputs.swift-tag }} - swift-workspace-cache: ${{ inputs.swift-workspace-cache }} - sysroot-id: sysroot-${{ inputs.distribution }} sysroot-name: sysroot-${{ inputs.distribution }}-armv7 distribution: ${{ inputs.distribution }} builder-tag: ${{ inputs.builder-tag }} diff --git a/.github/actions/build-with-sysroot/action.yml b/.github/actions/build-with-sysroot/action.yml index 5b910e2..7bc23a3 100644 --- a/.github/actions/build-with-sysroot/action.yml +++ b/.github/actions/build-with-sysroot/action.yml @@ -4,12 +4,6 @@ inputs: swift-tag: description: The Swift tag version that is being built required: true - swift-workspace-cache: - description: The name of the Swift workspace directory to restore - required: true - sysroot-id: - description: The sysroot ID to use when caching and publishing - required: true sysroot-name: description: The name of the sysroot to use to build Swift required: true @@ -22,28 +16,14 @@ inputs: runs: using: "composite" steps: - - name: Restore Sysroot - id: restore-sysroot - uses: actions/cache/restore@v4 - with: - key: ${{ inputs.sysroot-id }} - path: ${{ inputs.sysroot-name }} - - if: ${{ steps.restore-sysroot.outputs.cache-hit != 'true' }} - name: Build + - name: Build shell: bash env: DISTRIBUTION: ${{ inputs.distribution }} - run: ./build-sysroot.sh `echo ${DISTRIBUTION/-/:}` ${{ inputs.sysroot-name }} + run: ./build-sysroot.sh $(echo ${DISTRIBUTION/-/:}) ${{ inputs.sysroot-name }} - name: Compress shell: bash run: tar -czf ${{ inputs.sysroot-name }}.tar.gz ${{ inputs.sysroot-name }} - - name: Cache Sysroot - id: cache-sysroot - if: steps.restore-sysroot.outputs.cache-hit != 'true' - uses: actions/cache/save@v4 - with: - key: ${{ inputs.sysroot-id }} - path: ${{ inputs.sysroot-name }} - name: Build Swift shell: bash run: | diff --git a/.github/workflows/build-swift-latest.yml b/.github/workflows/build-swift-latest.yml new file mode 100644 index 0000000..e9ba708 --- /dev/null +++ b/.github/workflows/build-swift-latest.yml @@ -0,0 +1,39 @@ +name: Build Swift Latest + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + DISTRIBUTION: debian-bookworm + +jobs: + build-latest: + strategy: + matrix: + version: ["6.0.3"] + env: + SWIFT_VERSION: ${{ matrix.version }} + SWIFT_TAG: swift-${{ matrix.version }}-RELEASE + name: Build Swift + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/checkout-swift + name: Fetch Swift Sources + with: + swift-tag: ${{ env.SWIFT_TAG }} + swift-workspace-cache: swift-workspace + - name: Generate Builder Container + shell: bash + run: | + source ./swift-builder/swift-builder-common + ./swift-builder/build-container.sh + - uses: ./.github/actions/build-for-distribution + name: Build & Publish Swift + with: + swift-tag: ${{ env.SWIFT_TAG }} + distribution: ${{ env.DISTRIBUTION }} + builder-tag: ${{ env.SWIFT_VERSION }} diff --git a/.github/workflows/build-swift-nightly.yml b/.github/workflows/build-swift-nightly.yml new file mode 100644 index 0000000..00ebb5a --- /dev/null +++ b/.github/workflows/build-swift-nightly.yml @@ -0,0 +1,47 @@ +name: Build Swift Nightly + +on: + pull_request: + schedule: + - cron: '0 9 * * *' + +env: + DISTRIBUTION: debian-bookworm + +jobs: + nightly: + strategy: + matrix: + branch: ["swift-6.1-branch", "development"] + env: + SWIFT_TAG: + SWIFT_BRANCH: ${{ matrix.branch }} + SWIFT_PLATFORM: ubuntu2204 + SWIFT_VERSION: ${{ matrix.branch }} + SWIFT_WORKSPACE_CACHE: swift-workspace + name: Build Swift Nigtly + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Get Latest Nightly Version + shell: bash + run: | + export $(curl https://download.swift.org/${{ env.SWIFT_BRANCH }}/${{ env.SWIFT_PLATFORM }}/latest-build.yml | grep 'dir:' | sed 's/:[^:\/\/]/=/g') + echo "Latest Tag on ${{ env.SWIFT_BRANCH }} Branch: $dir" + echo "SWIFT_TAG=$(echo $dir)" >> $GITHUB_ENV + - uses: ./.github/actions/checkout-swift + name: Fetch Swift Sources + with: + swift-tag: ${{ env.SWIFT_TAG }} + swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} + - name: Build Swift Nightly Container + shell: bash + run: | + source ./swift-builder/swift-builder-common + ./swift-builder/build-container.sh + - uses: ./.github/actions/build-for-distribution + name: Build & Publish Swift + with: + swift-tag: ${{ env.SWIFT_TAG }} + distribution: ${{ env.DISTRIBUTION }} + builder-tag: ${{ env.SWIFT_VERSION }} diff --git a/.github/workflows/build-swift-release.yml b/.github/workflows/build-swift-release.yml index 97355a8..bc791ce 100644 --- a/.github/workflows/build-swift-release.yml +++ b/.github/workflows/build-swift-release.yml @@ -5,9 +5,9 @@ on: types: [published] env: + SWIFT_VERSION: ${{ github.event.release.tag_name }} SWIFT_TAG: swift-${{ github.event.release.tag_name }}-RELEASE - SWIFT_WORKSPACE_CACHE: swift-${{ github.event.release.tag_name }}-workspace - SWIFT_BUILDER_TAG: ${{ github.event.release.tag_name }}-gh-runner + SWIFT_WORKSPACE_CACHE: swift-workspace jobs: fetch-sources: @@ -16,77 +16,45 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/checkout-swift - name: "Restore or Checkout: ${{ env.SWIFT_TAG }}" + name: "Restore or Checkout ${{ env.SWIFT_VERSION }}" with: swift-tag: ${{ env.SWIFT_TAG }} swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - debian-bullseye: - name: Build for Debian Bullseye + build-for-distribution: + strategy: + matrix: + distribution: [ + "debian-bullseye", + "debian-bookworm", + "ubuntu-focal", + "ubuntu-jammy", + "ubuntu-noble" + ] + name: Build Swift runs-on: ubuntu-latest needs: [fetch-sources] steps: - uses: actions/checkout@v4 + - name: Generate Builder Container + shell: bash + run: | + source ./swift-builder/swift-builder-common + ./swift-builder/build-container.sh - uses: ./.github/actions/build-for-distribution - name: "Build & Publish Swift: ${{ env.SWIFT_TAG }}" + name: "Build & Publish Swift ${{ env.SWIFT_VERSION }}" with: swift-tag: ${{ env.SWIFT_TAG }} swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - distribution: ${{ github.job }} - builder-tag: ${{ env.SWIFT_BUILDER_TAG }} - - debian-bookworm: - name: Build for Debian Bookworm - runs-on: ubuntu-latest - needs: [fetch-sources] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build-for-distribution - name: "Build & Publish Swift: ${{ env.SWIFT_TAG }}" - with: - swift-tag: ${{ env.SWIFT_TAG }} - swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - distribution: ${{ github.job }} - builder-tag: ${{ env.SWIFT_BUILDER_TAG }} - - ubuntu-focal: - name: Build for Ubuntu Focal - runs-on: ubuntu-latest - needs: [fetch-sources] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build-for-distribution - name: "Build & Publish Swift: ${{ env.SWIFT_TAG }}" + distribution: ${{ matrix.distribution }} + builder-tag: ${{ env.SWIFT_VERSION }} + - name: Update Release ${{ env.SWIFT_VERSION }} + uses: ncipollo/release-action@v1 with: - swift-tag: ${{ env.SWIFT_TAG }} - swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - distribution: ${{ github.job }} - builder-tag: ${{ env.SWIFT_BUILDER_TAG }} - - ubuntu-jammy: - name: Build for Ubuntu Jammy - runs-on: ubuntu-latest - needs: [fetch-sources] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build-for-distribution - name: "Build & Publish Swift: ${{ env.SWIFT_TAG }}" - with: - swift-tag: ${{ env.SWIFT_TAG }} - swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - distribution: ${{ github.job }} - builder-tag: ${{ env.SWIFT_BUILDER_TAG }} - - ubuntu-noble: - name: Build for Ubuntu Noble - runs-on: ubuntu-latest - needs: [fetch-sources] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build-for-distribution - name: "Build & Publish Swift: ${{ env.SWIFT_TAG }}" - with: - swift-tag: ${{ env.SWIFT_TAG }} - swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - distribution: ${{ github.job }} - builder-tag: ${{ env.SWIFT_BUILDER_TAG }} + allowUpdates: true + name: Swift ${{ env.SWIFT_VERSION }} for armv7 + tag: ${{ env.SWIFT_VERSION }} + commit: ${{ github.sha }} + artifactErrorsFailBuild: true + artifacts: "*.tar.gz" + body: "See the [README](https://github.com/xtremekforever/swift-armv7#continuous-integration) for more information on build artifacts." diff --git a/.github/workflows/build-swift-versions.yml b/.github/workflows/build-swift-versions.yml deleted file mode 100644 index a1c6e4d..0000000 --- a/.github/workflows/build-swift-versions.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Build Swift Versions - -on: - push: - branches: [ "main", "feature/**" ] - pull_request: - branches: [ "main" ] - -env: - DISTRIBUTION: debian-bookworm - -jobs: - swift-5-9-2: - env: - SWIFT_TAG: swift-5.9.2-RELEASE - SWIFT_WORKSPACE_CACHE: swift-5.9.2-workspace - SWIFT_BUILDER_TAG: 5.9.2-gh-runner - name: Build Swift 5.9.2 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/checkout-swift - name: Fetch Swift Sources - with: - swift-tag: ${{ env.SWIFT_TAG }} - swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - - uses: ./.github/actions/build-for-distribution - name: Build & Publish Swift - with: - swift-tag: ${{ env.SWIFT_TAG }} - distribution: ${{ env.DISTRIBUTION }} - builder-tag: ${{ env.SWIFT_BUILDER_TAG }} - - swift-5-10-1: - env: - SWIFT_TAG: swift-5.10.1-RELEASE - SWIFT_WORKSPACE_CACHE: swift-5.10.1-workspace - SWIFT_BUILDER_TAG: 5.10.1-gh-runner - name: Build Swift 5.10.1 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/checkout-swift - name: Fetch Swift Sources - with: - swift-tag: ${{ env.SWIFT_TAG }} - swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - - uses: ./.github/actions/build-for-distribution - name: Build & Publish Swift - with: - swift-tag: ${{ env.SWIFT_TAG }} - distribution: ${{ env.DISTRIBUTION }} - builder-tag: ${{ env.SWIFT_BUILDER_TAG }} - - swift-6-0-3: - env: - SWIFT_TAG: swift-6.0.3-RELEASE - SWIFT_WORKSPACE_CACHE: swift-6.0.3-workspace - SWIFT_BUILDER_TAG: 6.0.2-gh-runner - name: Build Swift 6.0.3 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/checkout-swift - name: Fetch Swift Sources - with: - swift-tag: ${{ env.SWIFT_TAG }} - swift-workspace-cache: ${{ env.SWIFT_WORKSPACE_CACHE }} - - uses: ./.github/actions/build-for-distribution - name: Build & Publish Swift - with: - swift-tag: ${{ env.SWIFT_TAG }} - distribution: ${{ env.DISTRIBUTION }} - builder-tag: ${{ env.SWIFT_BUILDER_TAG }} diff --git a/README.md b/README.md index 82e6f66..ee66d96 100644 --- a/README.md +++ b/README.md @@ -73,14 +73,14 @@ After building the armv7 runtime using the `build.sh` script, you can generate a using the `build-linux-cross-sdk.sh` script. You must provide the swift tag and distribution name: ```bash -./build-linux-cross-sdk.sh swift-5.10.1-RELEASE ubuntu-noble +./build-linux-cross-sdk.sh swift-6.0.3-RELEASE ubuntu-noble ``` By default, the SDK will be generated to be installed at a path of /opt/$SWIFT_TAG-$DISTRIBUTION-armv7, but this can be customized by providing a different install prefix to the script: ```bash export SDK_INSTALL_PREFIX=/home/myuser/swift-sdks -./build-linux-cross-sdk.sh swift-5.10.1-RELEASE ubuntu-noble +./build-linux-cross-sdk.sh swift-6.0.3-RELEASE ubuntu-noble ``` ## Continuous Integration & Releases @@ -97,11 +97,11 @@ To use the SDK that is generated by the CI or published to the [Releases](https: extract it to /opt: ```bash -sudo tar -xf swift-5.10.1-RELEASE-debian-bookworm-armv7-sdk.tar.gz -C /opt +sudo tar -xf swift-6.0.3-RELEASE-debian-bookworm-armv7-sdk.tar.gz -C /opt ``` Then, from a Swift package, use the `--destination` paramter to cross-compile it for the target: ```bash -swift build --destination /opt/swift-5.10.1-RELEASE-debian-bookworm-armv7/debian-bookworm.json +swift build --destination /opt/swift-6.0.3-RELEASE-debian-bookworm-armv7/debian-bookworm.json ``` diff --git a/build-foundation.sh b/build-foundation.sh index 4d16059..114c892 100755 --- a/build-foundation.sh +++ b/build-foundation.sh @@ -37,6 +37,7 @@ LIBS="-latomic" cmake -S $FOUNDATION_SRCDIR -B $FOUNDATION_BUILDDIR -G Ninja \ -DCMAKE_Swift_FLAGS_DEBUG="" \ -DCMAKE_Swift_FLAGS_RELEASE="" \ -DCMAKE_Swift_FLAGS_RELWITHDEBINFO="" \ + -DSwiftFoundation_MACRO="${SWIFT_NATIVE_PATH}../lib/host/plugins/libFoundationMacros.so" \ -D_SwiftFoundation_SourceDIR="$SRC_ROOT/downloads/swift-foundation" \ -D_SwiftFoundationICU_SourceDIR="$SRC_ROOT/downloads/swift-foundation-icu" \ -D_SwiftCollections_SourceDIR="$SRC_ROOT/downloads/swift-collections" \ diff --git a/build-in-container.sh b/build-in-container.sh index 0e7cf58..29238ff 100755 --- a/build-in-container.sh +++ b/build-in-container.sh @@ -10,9 +10,11 @@ source ./swift-builder/swift-builder-common echo "Building Swift ${SWIFT_TAG} using ${DOCKER_TAG}..." docker run \ --rm -ti \ - --user ${BUILD_USER}:${BUILD_USER} \ + --user ${USER}:${USER} \ --volume $(pwd):/src \ --workdir /src \ -e SWIFT_VERSION=${SWIFT_TAG} \ - ${DOCKER_REPO}swift-builder:${SWIFT_VERSION} \ + -e STAGING_DIR=${STAGING_DIR} \ + -e INSTALL_TAR=${INSTALL_TAG} \ + ${DOCKER_TAG} \ ./build.sh diff --git a/build-swift-stdlib.sh b/build-swift-stdlib.sh index 407ca72..8477719 100755 --- a/build-swift-stdlib.sh +++ b/build-swift-stdlib.sh @@ -54,6 +54,7 @@ LIBS="-latomic" cmake -S $SWIFT_SRCDIR -B $SWIFT_BUILDDIR -G Ninja \ -DSWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES=ON \ -DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION=ON \ -DSWIFT_ENABLE_SYNCHRONIZATION=ON \ + -DSWIFT_SHOULD_BUILD_EMBEDDED_STDLIB=OFF \ -DSWIFT_INCLUDE_TESTS=OFF \ -DSWIFT_INCLUDE_TEST_BINARIES=OFF \ -DSWIFT_BUILD_TEST_SUPPORT_MODULES=OFF \ diff --git a/build.sh b/build.sh index 742a99d..f9cd834 100755 --- a/build.sh +++ b/build.sh @@ -31,7 +31,9 @@ rm -rf $STAGING_DIR/usr/lib/swift* ./build-dispatch.sh ./build-foundation.sh ./build-xctest.sh -if [[ $SWIFT_VERSION == *"6."* ]]; then + +# NOTE: Swift-testing is disabled in 6.1 since it fails to compile +if [[ $SWIFT_VERSION == *"6.0"* ]]; then ./build-swift-testing.sh fi diff --git a/swift-builder/Dockerfile b/swift-builder/Dockerfile index 5170f52..d5a356e 100644 --- a/swift-builder/Dockerfile +++ b/swift-builder/Dockerfile @@ -44,8 +44,7 @@ ARG SWIFT_BRANCH=development ARG SWIFT_VERSION=swift-DEVELOPMENT-SNAPSHOT-2024-12-13-a ARG SWIFT_WEBROOT=https://download.swift.org -ENV SWIFT_SIGNING_KEY=$SWIFT_SIGNING_KEY \ - SWIFT_PLATFORM=$SWIFT_PLATFORM \ +ENV SWIFT_PLATFORM=$SWIFT_PLATFORM \ SWIFT_BRANCH=$SWIFT_BRANCH \ SWIFT_VERSION=$SWIFT_VERSION \ SWIFT_WEBROOT=$SWIFT_WEBROOT diff --git a/swift-builder/build-container.sh b/swift-builder/build-container.sh index 9e31602..b045d8d 100755 --- a/swift-builder/build-container.sh +++ b/swift-builder/build-container.sh @@ -9,7 +9,7 @@ echo "Building container for Swift $SWIFT_VERSION, branch $SWIFT_BRANCH, tag $SW docker build \ --build-arg SWIFT_VERSION=${SWIFT_TAG} \ --build-arg SWIFT_BRANCH=${SWIFT_BRANCH} \ - --build-arg USER=${BUILD_USER} \ - --build-arg UID=${BUILD_USER_ID} \ + --build-arg USER=${USER} \ + --build-arg UID=${UID} \ -t ${DOCKER_TAG} \ ${SCRIPT_DIR} diff --git a/swift-builder/build-gh-runner.sh b/swift-builder/build-gh-runner.sh index f033fe9..2051f0b 100755 --- a/swift-builder/build-gh-runner.sh +++ b/swift-builder/build-gh-runner.sh @@ -6,13 +6,11 @@ if [ -z $SWIFT_VERSION ]; then fi export DOCKER_TAG=${DOCKER_TAG:=xtremekforever/swift-builder:${SWIFT_VERSION}-gh-runner} -export BUILD_USER=runner -export BUILD_USER_ID=1001 SCRIPT_DIR=$(dirname "$0") source ${SCRIPT_DIR}/swift-builder-common -./build-container.sh +USER=runner UID=1001 ./build-container.sh if [ ! -z $PUSH ]; then echo "Pushing ${DOCKER_TAG} now..." diff --git a/swift-builder/swift-builder-common b/swift-builder/swift-builder-common index d6af23f..cf7624f 100644 --- a/swift-builder/swift-builder-common +++ b/swift-builder/swift-builder-common @@ -1,7 +1,5 @@ SWIFT_VERSION=${SWIFT_VERSION:=6.0.3} SWIFT_BRANCH=${SWIFT_BRANCH:=swift-${SWIFT_VERSION}-release} SWIFT_TAG=${SWIFT_TAG:=swift-${SWIFT_VERSION}-RELEASE} -BUILD_USER=${BUILD_USER:=build-user} -BUILD_USER_ID=${BUILD_USER_ID:=$UID} -DOCKER_TAG=${DOCKER_TAG:=swift-builder:${SWIFT_VERSION}} +DOCKER_TAG=${DOCKER_TAG:=xtremekforever/swift-builder:${SWIFT_VERSION}} diff --git a/swift-hello/Tests/swift-helloTests/swift_helloTests.swift b/swift-hello/Tests/swift-helloTests/swift_helloTests.swift index 8f8c155..ef09795 100644 --- a/swift-hello/Tests/swift-helloTests/swift_helloTests.swift +++ b/swift-hello/Tests/swift-helloTests/swift_helloTests.swift @@ -2,9 +2,9 @@ import XCTest import class Foundation.Bundle -#if canImport(Testing) +/*#if canImport(Testing) import Testing -#endif +#endif*/ final class swift_helloTests: XCTestCase { func testExample() throws { @@ -51,9 +51,10 @@ final class swift_helloTests: XCTestCase { } } -#if canImport(Testing) - @Test +// Disabled due to compiler crash in 6.1 +/*#if canImport(Testing) + /*@Test func swiftTesting() { #expect(true) - } -#endif + }*/ +#endif*/