Skip to content

Commit

Permalink
Fix triple generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Mar 13, 2024
1 parent 9b53842 commit 81c9dbf
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 10 deletions.
26 changes: 16 additions & 10 deletions actions/generate-cross-compilation-sdk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ runs:
target-arch: ${{ inputs.target-arch }}
target-os: ${{ inputs.target-os }}
target-os-version: ${{ inputs.target-os-version }}
- uses: ffried/swift-cross-compilation-sdk-bundles/actions/triple@main
id: host-triple
with:
os: ${{ inputs.host-os }}
os-version: ${{ inputs.host-os-version }}
arch: ${{ inputs.host-arch }}
- uses: ffried/swift-cross-compilation-sdk-bundles/actions/triple@main
id: target-triple
with:
os: ${{ inputs.target-os }}
os-version: ${{ inputs.target-os-version }}
arch: ${{ inputs.target-arch }}
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '^15.0'
Expand Down Expand Up @@ -96,27 +108,21 @@ runs:
shell: bash
env:
SWIFT_VERSION: ${{ inputs.swift-version }}
HOST_OS: ${{ inputs.host-os }}
HOST_OS_VERSION: ${{ inputs.host-os-version }}
HOST_ARCH: ${{ inputs.host-arch }}
HOST_TRIPLE: ${{ steps.host-triple.outputs.triple }}
TARGET_TRIPLE: ${{ steps.target-triple.outputs.triple }}
TARGET_OS: ${{ inputs.target-os }}
TARGET_OS_VERSION: ${{ inputs.target-os-version }}
TARGET_ARCH: ${{ inputs.target-arch }}
BUNDLE_NAME: ${{ steps.bundle-names.outputs.base-name }}
BUNDLE_FULL_NAME: ${{ steps.bundle-names.outputs.full-name }}
run: |
TARGET_SYSTEM='linux'
if [ "${TARGET_OS}" = 'macos' ]; then
TARGET_SYSTEM='macos'
fi
swift run -c release \
swift-sdk-generator \
make-linux-sdk \
--with-docker \
--sdk-name "${BUNDLE_NAME}" \
--swift-version "${SWIFT_VERSION}-RELEASE" \
--host "${HOST_OS}-${HOST_ARCH}" \
--target "${TARGET_SYSTEM}-${TARGET_ARCH}" \
--host "${HOST_TRIPLE}" \
--target "${TARGET_TRIPLE}" \
--linux-distribution-name "${TARGET_OS}" \
--linux-distribution-version "${TARGET_OS_VERSION}"
echo "bundle-path=$(pwd)/Bundles/${BUNDLE_FULL_NAME}" >> "${GITHUB_OUTPUT}"
Expand Down
46 changes: 46 additions & 0 deletions actions/triple/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Compose SDK triple
description: Composes the SDK triple from the given inputs.

inputs:
os:
description: 'The OS'
required: true
os-version:
description: 'The OS version'
required: true
arch:
description: 'The OS architecture'
required: true

outputs:
triple:
description: SDK Triple
value: ${{ steps.triple.outputs.triple }}

runs:
using: composite
steps:
- name: Compose SDK triple
id: triple
shell: bash
env:
TRIPLE_OS: ${{ inputs.os }}
TRIPLE_OS_VERSION: ${{ inputs.os-version }}
TRIPLE_ARCH: ${{ inputs.arch }}
run: |
CLEANED_ARCH="${TRIPLE_ARCH}"
if [ "${TRIPLE_ARCH}" = "arm64" ]; then
CLEANED_ARCH="aarch64"
fi
case "${TRIPLE_OS}" in
macos)
echo "host-triple=${CLEANED_ARCH}-apple-macosx${TRIPLE_OS_VERSION}.0" >> "${GITHUB_OUTPUT}"
;;
ubuntu|rhel)
echo "host-triple=${CLEANED_ARCH}-unknown-linux" >> "${GITHUB_OUTPUT}"
;;
*)
echo "::error::Unsupported OS '${TRIPLE_OS}'"
exit 1
;;
esac

0 comments on commit 81c9dbf

Please sign in to comment.