Skip to content

Commit

Permalink
Merge pull request #19 from xtremekforever/main
Browse files Browse the repository at this point in the history
Add Swift 6.1 support
  • Loading branch information
colemancda authored Dec 26, 2024
2 parents 6d34b01 + 3245700 commit e27e6c3
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 184 deletions.
2 changes: 0 additions & 2 deletions .github/actions/build-for-distribution/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
24 changes: 2 additions & 22 deletions .github/actions/build-with-sysroot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/build-swift-latest.yml
Original file line number Diff line number Diff line change
@@ -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 }}
47 changes: 47 additions & 0 deletions .github/workflows/build-swift-nightly.yml
Original file line number Diff line number Diff line change
@@ -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 }}
94 changes: 31 additions & 63 deletions .github/workflows/build-swift-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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."
74 changes: 0 additions & 74 deletions .github/workflows/build-swift-versions.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
1 change: 1 addition & 0 deletions build-foundation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
6 changes: 4 additions & 2 deletions build-in-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions build-swift-stdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Loading

0 comments on commit e27e6c3

Please sign in to comment.