Skip to content

Commit

Permalink
Support building for armv6 for Swift Latest workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
xtremekforever committed Dec 27, 2024
1 parent cc3148c commit 369d5a6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
8 changes: 6 additions & 2 deletions .github/actions/build-for-distribution/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Build Swift for a given armv7 distribution
name: Build Swift for a given distribution
description: This wraps all the functionality of other actions to build Swift for a given distribution
inputs:
swift-tag:
description: The Swift tag version that is being built
required: true
swift-target-arch:
description: The target architecture to build Swift for (e.g., armv6 or armv7)
required: true
swift-workspace-cache:
description: The name of the Swift workspace directory to restore
required: true
Expand All @@ -27,6 +30,7 @@ runs:
name: Build Swift + SDK using Sysroot
with:
swift-tag: ${{ inputs.swift-tag }}
sysroot-name: sysroot-${{ inputs.distribution }}-armv7
sysroot-name: sysroot-${{ inputs.distribution }}
swift-target-arch: ${{ inputs.swift-target-arch }}
distribution: ${{ inputs.distribution }}
builder-tag: ${{ inputs.builder-tag }}
19 changes: 12 additions & 7 deletions .github/actions/build-with-sysroot/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Swift with a provided armv7 sysroot for a given sysroot
name: Build Swift with a provided sysroot and for a target architecture
description: This contains the functionality to build/restore a sysroot, build Swift, and build an SDK
inputs:
swift-tag:
Expand All @@ -7,6 +7,9 @@ inputs:
sysroot-name:
description: The name of the sysroot to use to build Swift
required: true
swift-target-arch:
description: The target architecture to build Swift for (e.g., armv6 or armv7)
required: true
distribution:
description: The name of the distribution to build for
required: true
Expand All @@ -29,20 +32,22 @@ runs:
run: |
docker run --rm --user runner --workdir ${{ github.workspace }} -v $HOME:$HOME \
-e SWIFT_VERSION=${{ inputs.swift-tag }} \
-e INSTALL_TAR=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-armv7-install.tar.gz \
-e INSTALL_TAR=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }}-install.tar.gz \
-e STAGING_DIR=$(pwd)/${{ inputs.sysroot-name }} \
-e SWIFT_TARGET_ARCH=${{ inputs.swift-target-arch }}
-e SKIP_FETCH_SOURCES=1 \
xtremekforever/swift-builder:${{ inputs.builder-tag }} \
/bin/bash ./build.sh
- name: Build SDK for Linux
shell: bash
run: |
INSTALLABLE_SDK_PACKAGE=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-armv7-sdk.tar.gz SYSROOT=${{ inputs.sysroot-name }} \
INSTALLABLE_SDK_PACKAGE=$(pwd)/${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }}-sdk.tar.gz \
SYSROOT=${{ inputs.sysroot-name }} \
./build-linux-cross-sdk.sh ${{ inputs.swift-tag }} ${{ inputs.distribution }}
- name: Test SDK for Linux
shell: bash
env:
SDK_NAME: ${{ inputs.swift-tag }}-${{ inputs.distribution }}-armv7
SDK_NAME: ${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }}
run: |
docker run --rm --user runner --workdir ${{ github.workspace }} -v $HOME:$HOME -v ${{ github.workspace }}/artifacts:/opt \
xtremekforever/swift-builder:${{ inputs.builder-tag }} \
Expand All @@ -54,8 +59,8 @@ runs:
- uses: actions/upload-artifact@v4
name: Publish
with:
name: ${{ inputs.swift-tag }}-${{ inputs.distribution }}-armv7
name: ${{ inputs.swift-tag }}-${{ inputs.distribution }}-${{ inputs.swift-target-arch }}
path: |
${{ inputs.sysroot-name }}.tar.gz
${{ inputs.swift-tag }}*-armv7-install.tar.gz
${{ inputs.swift-tag }}*-armv7-sdk.tar.gz
${{ inputs.swift-tag }}*-${{ inputs.swift-target-arch }}-install.tar.gz
${{ inputs.swift-tag }}*-${{ inputs.swift-target-arch }}-sdk.tar.gz
6 changes: 4 additions & 2 deletions .github/workflows/build-swift-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ name: Build Swift Latest

on:
push:
branches: [ "main" ]
branches: [ "main", "feature/armv6" ]
pull_request:
branches: [ "main" ]

env:
DISTRIBUTION: debian-bookworm
DISTRIBUTION: raspios-bookworm

jobs:
build-latest:
strategy:
matrix:
version: ["6.0.3"]
swift-target-arch: ["armv6", "armv7"]
env:
SWIFT_VERSION: ${{ matrix.version }}
SWIFT_TAG: swift-${{ matrix.version }}-RELEASE
Expand All @@ -35,5 +36,6 @@ jobs:
name: Build & Publish Swift
with:
swift-tag: ${{ env.SWIFT_TAG }}
swift-target-arch: ${{ matrix.swift-target-arch }}
distribution: ${{ env.DISTRIBUTION }}
builder-tag: ${{ env.SWIFT_VERSION }}
9 changes: 4 additions & 5 deletions build-sysroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ DISTRIUBTION_VERSION=$2
SYSROOT=$3

if [ -z $SYSROOT ]; then
SYSROOT=sysroot-$DISTRIBUTION_NAME-$DISTRIUBTION_VERSION
SYSROOT=$(pwd)/sysroot-$DISTRIBUTION_NAME-$DISTRIUBTION_VERSION
fi
SYSROOT=$(pwd)/$SYSROOT

DISTRIBUTION="$DISTRIBUTION_NAME:$DISTRIUBTION_VERSION"

Expand Down Expand Up @@ -97,14 +96,14 @@ if [ ! -z $EXTRA_PACKAGES ]; then
INSTALL_DEPS_CMD="$INSTALL_DEPS_CMD && apt-get install -y $EXTRA_PACKAGES --no-optional"
fi

if [[ $DISTRIBUTION_NAME = "debian" ]]; then
# This is for supporting armv6
if [[ $DISTRIBUTION_NAME = "raspios" ]]; then
echo "Installing host dependencies..."
sudo apt update && sudo apt install qemu-user-static p7zip xz-utils

mkdir artifacts && true
cd artifacts

# Use Raspberry Pi OS to build for debian to support armv6
echo "Downloading raspios $RASPBIAN_VERSION for $DISTRIUBTION_VERSION..."
IMAGE_FILE=$RASPIOS_VERSION-raspios-$DISTRIUBTION_VERSION-armhf-lite.img
DOWNLOAD_URL=$RASPIOS_URL/$IMAGE_FILE.xz
Expand Down Expand Up @@ -175,4 +174,4 @@ else

echo "Cleaning up"
docker rm $CONTAINER_NAME
fi
fi

0 comments on commit 369d5a6

Please sign in to comment.