From 81c9dbfc105771a0be35c3c83872e3416c6435a8 Mon Sep 17 00:00:00 2001 From: Florian Friedrich Date: Wed, 13 Mar 2024 15:29:10 +0100 Subject: [PATCH] Fix triple generation --- .../generate-cross-compilation-sdk/action.yml | 26 +++++++---- actions/triple/action.yml | 46 +++++++++++++++++++ 2 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 actions/triple/action.yml diff --git a/actions/generate-cross-compilation-sdk/action.yml b/actions/generate-cross-compilation-sdk/action.yml index c066bc6..047a044 100644 --- a/actions/generate-cross-compilation-sdk/action.yml +++ b/actions/generate-cross-compilation-sdk/action.yml @@ -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' @@ -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}" diff --git a/actions/triple/action.yml b/actions/triple/action.yml new file mode 100644 index 0000000..6556577 --- /dev/null +++ b/actions/triple/action.yml @@ -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