From a64f8b6eecf443248efe53d0c32eb38ca2ddb0a3 Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Fri, 18 Oct 2024 17:13:27 -0700 Subject: [PATCH] Add the native ARM64 toolchain build to the main CI --- .github/workflows/build-toolchain.yml | 175 +++++++++-- .../pull-request-swift-toolchain-cirun.yml | 6 +- .../pull-request-swift-toolchain-github.yml | 6 +- ...schedule-swift-toolchain-windows-arm64.yml | 28 ++ .../workflows/schedule-swift-toolchain.yml | 27 +- .github/workflows/swift-toolchain.yml | 271 +++++++++++------- 6 files changed, 376 insertions(+), 137 deletions(-) create mode 100644 .github/workflows/schedule-swift-toolchain-windows-arm64.yml diff --git a/.github/workflows/build-toolchain.yml b/.github/workflows/build-toolchain.yml index 0655b59e..69904945 100644 --- a/.github/workflows/build-toolchain.yml +++ b/.github/workflows/build-toolchain.yml @@ -36,6 +36,12 @@ on: default: true required: false + create_snapshot: + description: 'Create Snapshot' + type: boolean + default: true + required: false + workflow_call: inputs: swift_version: @@ -71,15 +77,36 @@ on: default: true required: false - windows_default_runner: - description: 'Build runner' + create_snapshot: + description: 'Create Snapshot' + type: boolean + default: true + required: false + + windows_x64_default_runner: + description: 'X64 Build runner' + required: false + type: string + + windows_arm64_default_runner: + description: 'ARM64 Build runner' + required: false + type: string + + windows_x64_compilers_runner: + description: 'X64 Build runner for `compilers` job' required: false type: string - windows_compilers_runner: - description: 'Build runner for `compilers` job' + windows_arm64_compilers_runner: + description: 'ARM64 Build runner for `compilers` job' + required: false type: string + + windows_build_arch: + description: 'Windows build architecture' required: false + type: string secrets: SYMBOL_SERVER_PAT: @@ -153,12 +180,19 @@ jobs: signed: ${{ steps.context.outputs.signed }} swift_version: ${{ steps.context.outputs.swift_version }} swift_tag: ${{ steps.context.outputs.swift_tag }} - windows_build_runner: ${{ steps.context.outputs.windows_build_runner }} - windows_compilers_runner: ${{ steps.context.outputs.windows_compilers_runner }} + windows_arm64_build_runner: ${{ steps.context.outputs.windows_arm64_build_runner }} + windows_arm64_compilers_runner: ${{ steps.context.outputs.windows_arm64_compilers_runner }} + windows_build_arch: ${{ steps.context.outputs.windows_build_arch }} + windows_build_cpu: ${{ steps.context.outputs.windows_build_cpu }} + windows_x64_build_runner: ${{ steps.context.outputs.windows_x64_build_runner }} + windows_x64_compilers_runner: ${{ steps.context.outputs.windows_x64_compilers_runner }} mac_build_runner: ${{ steps.context.outputs.mac_build_runner }} - windows_host_matrix: ${{ steps.setup-matrix.outputs.windows_host_matrix }} - windows_build_matrix: ${{ steps.setup-matrix.outputs.windows_build_matrix }} - windows_target_matrix: ${{ steps.setup-matrix.outputs.windows_target_matrix }} + windows_arm64_build_matrix: ${{ steps.setup-matrix.outputs.windows_arm64_build_matrix }} + windows_arm64_host_matrix: ${{ steps.setup-matrix.outputs.windows_arm64_host_matrix }} + windows_arm64_target_matrix: ${{ steps.setup-matrix.outputs.windows_arm64_target_matrix }} + windows_x64_build_matrix: ${{ steps.setup-matrix.outputs.windows_x64_build_matrix }} + windows_x64_host_matrix: ${{ steps.setup-matrix.outputs.windows_x64_host_matrix }} + windows_x64_target_matrix: ${{ steps.setup-matrix.outputs.windows_x64_target_matrix }} darwin_host_matrix: ${{ steps.setup-matrix.outputs.darwin_host_matrix }} darwin_build_matrix: ${{ steps.setup-matrix.outputs.darwin_build_matrix }} darwin_target_matrix: ${{ steps.setup-matrix.outputs.darwin_target_matrix }} @@ -284,8 +318,18 @@ jobs: fi fi - echo windows_build_runner=${{ inputs.windows_default_runner || vars.WINDOWS_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT} - echo windows_compilers_runner=${{ inputs.windows_compilers_runner || inputs.windows_default_runner || vars.COMPILERS_BUILD_RUNNER || vars.WINDOWS_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT} + echo windows_x64_build_runner=${{ inputs.windows_x64_default_runner || vars.WINDOWS_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT} + echo windows_x64_compilers_runner=${{ inputs.windows_x64_compilers_runner || inputs.windows_x64_default_runner || vars.WINDOWS_X64_COMPILERS_BUILD_RUNNER || vars.WINDOWS_X64_DEFAULT_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT} + echo windows_arm64_build_runner=${{ inputs.windows_arm64_default_runner || vars.WINDOWS_ARM64_DEFAULT_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT} + echo windows_arm64_compilers_runner=${{ inputs.windows_arm64_compilers_runner || inputs.windows_arm64_default_runner || vars.WINDOWS_ARM64_COMPILERS_BUILD_RUNNER || vars.WINDOWS_ARM64_DEFAULT_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT} + if [[ "${{ inputs.windows_build_arch }}" == "arm64" ]] ; then + echo windows_build_arch=arm64 >> ${GITHUB_OUTPUT} + echo windows_build_cpu=arm64 >> ${GITHUB_OUTPUT} + else + echo windows_build_arch=amd64 >> ${GITHUB_OUTPUT} + echo windows_build_cpu=x64 >> ${GITHUB_OUTPUT} + fi + # TODO: Make the mac runner configurable. echo mac_build_runner=macos-latest >> ${GITHUB_OUTPUT} @@ -293,6 +337,7 @@ jobs: echo ANDROID_NDK_VERSION=r26b >> ${GITHUB_OUTPUT} - uses: actions/upload-artifact@v4 + if: inputs.create_snapshot == true with: name: stable.xml path: stable.xml @@ -301,11 +346,13 @@ jobs: - name: Setup matrix id: setup-matrix env: - WINDOWS_HOST_MATRIX: >- + WINDOWS_X64_HOST_MATRIX: >- { "include": [ { "arch": "amd64", + "cpu": "x86_64", + "triple": "x86_64-unknown-windows-msvc", "compiler_target": "x86_64-unknown-windows-msvc", "os": "Windows", "cc": "cl", @@ -317,6 +364,8 @@ jobs: }, { "arch": "arm64", + "cpu": "aarch64", + "triple": "aarch64-unknown-windows-msvc", "compiler_target": "aarch64-unknown-windows-msvc", "os": "Windows", "cc": "cl", @@ -328,11 +377,30 @@ jobs: } ] } - WINDOWS_BUILD_MATRIX: >- + WINDOWS_ARM64_HOST_MATRIX: >- + { + "include": [ + { + "arch": "arm64", + "cpu": "aarch64", + "triple": "aarch64-unknown-windows-msvc", + "compiler_target": "aarch64-unknown-windows-msvc", + "os": "Windows", + "cc": "cl", + "cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}", + "cxx": "cl", + "cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}", + "swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}", + "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=ARM64 -D CMAKE_MT=mt" + } + ] + } + WINDOWS_X64_BUILD_MATRIX: >- { "include": [ { "arch": "amd64", + "compiler_target": "x86_64-unknown-windows-msvc", "os": "Windows", "cc": "cl", "cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}", @@ -343,7 +411,23 @@ jobs: } ] } - WINDOWS_TARGET_MATRIX: >- + WINDOWS_ARM64_BUILD_MATRIX: >- + { + "include": [ + { + "arch": "arm64", + "compiler_target": "aarch64-unknown-windows-msvc", + "os": "Windows", + "cc": "cl", + "cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}", + "cxx": "cl", + "cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}", + "swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}", + "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=ARM64 -D CMAKE_MT=mt" + } + ] + } + WINDOWS_X64_TARGET_MATRIX: >- { "include": [ { @@ -418,6 +502,41 @@ jobs: } ] } + WINDOWS_ARM64_TARGET_MATRIX: >- + { + "include": [ + { + "arch": "amd64", + "os": "Windows", + "cc": "cl", + "cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}", + "cxx": "cl", + "cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}", + "swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}", + "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=AMD64 -D CMAKE_MT=mt" + }, + { + "arch": "arm64", + "os": "Windows", + "cc": "cl", + "cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}", + "cxx": "cl", + "cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}", + "swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}", + "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=ARM64 -D CMAKE_MT=mt" + }, + { + "arch": "x86", + "os": "Windows", + "cc": "cl", + "cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}", + "cxx": "cl", + "cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}", + "swiftflags": "", + "extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=X86 -D CMAKE_MT=mt" + } + ] + } DARWIN_HOST_MATRIX: >- { "include": [ @@ -486,9 +605,12 @@ jobs: ] } run: | - echo "windows_host_matrix=$(jq -r -c '.' <<< ${WINDOWS_HOST_MATRIX})" >> ${GITHUB_OUTPUT} - echo "windows_build_matrix=$(jq -r -c '.' <<< ${WINDOWS_BUILD_MATRIX})" >> ${GITHUB_OUTPUT} - echo "windows_target_matrix=$(jq -r -c '.' <<< ${WINDOWS_TARGET_MATRIX})" >> ${GITHUB_OUTPUT} + echo "windows_x64_host_matrix=$(jq -r -c '.' <<< ${WINDOWS_X64_HOST_MATRIX})" >> ${GITHUB_OUTPUT} + echo "windows_arm64_host_matrix=$(jq -r -c '.' <<< ${WINDOWS_ARM64_HOST_MATRIX})" >> ${GITHUB_OUTPUT} + echo "windows_x64_build_matrix=$(jq -r -c '.' <<< ${WINDOWS_X64_BUILD_MATRIX})" >> ${GITHUB_OUTPUT} + echo "windows_arm64_build_matrix=$(jq -r -c '.' <<< ${WINDOWS_ARM64_BUILD_MATRIX})" >> ${GITHUB_OUTPUT} + echo "windows_x64_target_matrix=$(jq -r -c '.' <<< ${WINDOWS_X64_TARGET_MATRIX})" >> ${GITHUB_OUTPUT} + echo "windows_arm64_target_matrix=$(jq -r -c '.' <<< ${WINDOWS_ARM64_TARGET_MATRIX})" >> ${GITHUB_OUTPUT} echo "darwin_host_matrix=$(jq -r -c '.' <<< ${DARWIN_HOST_MATRIX})" >> ${GITHUB_OUTPUT} echo "darwin_build_matrix=$(jq -r -c '.' <<< ${DARWIN_BUILD_MATRIX})" >> ${GITHUB_OUTPUT} echo "darwin_target_matrix=$(jq -r -c '.' <<< ${DARWIN_TARGET_MATRIX})" >> ${GITHUB_OUTPUT} @@ -496,13 +618,14 @@ jobs: windows-build: needs: [context] name: Windows Swift Toolchains Build + uses: ./.github/workflows/swift-toolchain.yml with: build_os: Windows - build_arch: amd64 - build_matrix: ${{ needs.context.outputs.windows_build_matrix }} - host_matrix: ${{ needs.context.outputs.windows_host_matrix }} - target_matrix: ${{ needs.context.outputs.windows_target_matrix }} + build_arch: ${{ inputs.windows_build_arch }} + build_matrix: ${{ needs.context.outputs[format('windows_{0}_build_matrix', needs.context.outputs.windows_build_cpu)] }} + host_matrix: ${{ needs.context.outputs[format('windows_{0}_host_matrix', needs.context.outputs.windows_build_cpu)] }} + target_matrix: ${{ needs.context.outputs[format('windows_{0}_target_matrix', needs.context.outputs.windows_build_cpu)] }} curl_revision: ${{ needs.context.outputs.curl_revision }} curl_version: ${{ needs.context.outputs.curl_version }} ds2_revision: ${{ needs.context.outputs.ds2_revision }} @@ -557,8 +680,8 @@ jobs: signed: ${{ fromJSON(needs.context.outputs.signed) }} swift_version: ${{ needs.context.outputs.swift_version }} swift_tag: ${{ needs.context.outputs.swift_tag }} - default_build_runner: ${{ needs.context.outputs.windows_build_runner }} - compilers_build_runner: ${{ needs.context.outputs.windows_compilers_runner }} + default_build_runner: ${{ needs.context.outputs[format('windows_{0}_build_runner', needs.context.outputs.windows_build_cpu)] }} + compilers_build_runner: ${{ needs.context.outputs[format('windows_{0}_compilers_runner', needs.context.outputs.windows_build_cpu)] }} secrets: SYMBOL_SERVER_PAT: ${{ secrets.SYMBOL_SERVER_PAT }} CERTIFICATE: ${{ secrets.CERTIFICATE }} @@ -640,7 +763,7 @@ jobs: snapshot: runs-on: ubuntu-latest needs: [context, windows-build] - if: github.event_name == 'schedule' + if: inputs.create_snapshot == true && github.event_name == 'schedule' steps: - uses: actions/checkout@v4 with: @@ -667,12 +790,12 @@ jobs: steps: - uses: actions/download-artifact@v4 with: - name: installer-amd64 + name: installer-amd64-built-on-amd64 path: ${{ github.workspace }}/tmp/amd64 - uses: actions/download-artifact@v4 with: - name: installer-arm64 + name: installer-arm64-built-on-amd64 path: ${{ github.workspace }}/tmp/arm64 - name: Create Release diff --git a/.github/workflows/pull-request-swift-toolchain-cirun.yml b/.github/workflows/pull-request-swift-toolchain-cirun.yml index 549b62ed..d3bde0c3 100644 --- a/.github/workflows/pull-request-swift-toolchain-cirun.yml +++ b/.github/workflows/pull-request-swift-toolchain-cirun.yml @@ -17,8 +17,10 @@ jobs: uses: ./.github/workflows/build-toolchain.yml with: create_release: false - windows_default_runner: "cirun-win11-23h2-pro-x64-16-2024-10-10--${{ github.run_id }}" - windows_compilers_runner: "cirun-win11-23h2-pro-x64-64-2024-10-10--${{ github.run_id }}" + windows_x64_default_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-16-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-8-cores' }} + windows_x64_compilers_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-64-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-64-cores' }} + windows_arm64_default_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-arm64-16-2024-10-10--{0}', github.run_id) || 'swift-build-windows-arm64-latest-8-cores' }} + windows_arm64_compilers_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-arm64-64-2024-10-10--{0}', github.run_id) || 'swift-build-windows-arm64-latest-32-cores' }} android_api_level: 28 secrets: inherit permissions: diff --git a/.github/workflows/pull-request-swift-toolchain-github.yml b/.github/workflows/pull-request-swift-toolchain-github.yml index 47834bf4..41d49962 100644 --- a/.github/workflows/pull-request-swift-toolchain-github.yml +++ b/.github/workflows/pull-request-swift-toolchain-github.yml @@ -16,8 +16,10 @@ jobs: uses: ./.github/workflows/build-toolchain.yml with: create_release: false - windows_default_runner: "swift-build-windows-latest-8-cores" - windows_compilers_runner: "swift-build-windows-latest-64-cores" + windows_x64_default_runner: "swift-build-windows-latest-8-cores" + windows_x64_compilers_runner: "swift-build-windows-latest-64-cores" + windows_arm64_default_runner: "swift-build-windows-arm64-latest-8-cores" + windows_arm64_compilers_runner: "swift-build-windows-arm64-latest-32-cores" android_api_level: 28 secrets: inherit permissions: diff --git a/.github/workflows/schedule-swift-toolchain-windows-arm64.yml b/.github/workflows/schedule-swift-toolchain-windows-arm64.yml new file mode 100644 index 00000000..5cd8862c --- /dev/null +++ b/.github/workflows/schedule-swift-toolchain-windows-arm64.yml @@ -0,0 +1,28 @@ +name: Schedule - Development Snapshot Windows/ARM64 + +on: + schedule: + - cron: "0 */6 * * *" + + # Allows us to trigger toolchain builds on-demand using the same inputs as scheduled builds. + # For more control over the swift-toolchain.yml's inputs, trigger that workflow directly. + workflow_dispatch: + +jobs: + call_development_snapshot: + name: Development Snapshot + uses: ./.github/workflows/build-toolchain.yml + with: + create_release: false + create_snapshot: false + windows_build_arch: arm64 + windows_x64_default_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-16-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-8-cores' }} + windows_x64_compilers_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-64-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-64-cores' }} + windows_arm64_default_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-arm64-16-2024-10-10--{0}', github.run_id) || 'swift-build-windows-arm64-latest-8-cores' }} + windows_arm64_compilers_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-arm64-64-2024-10-10--{0}', github.run_id) || 'swift-build-windows-arm64-latest-32-cores' }} + android_api_level: 28 + secrets: inherit + permissions: + contents: write + packages: write + id-token: write diff --git a/.github/workflows/schedule-swift-toolchain.yml b/.github/workflows/schedule-swift-toolchain.yml index 1f1013f8..977e27c3 100644 --- a/.github/workflows/schedule-swift-toolchain.yml +++ b/.github/workflows/schedule-swift-toolchain.yml @@ -13,9 +13,30 @@ jobs: name: Development Snapshot uses: ./.github/workflows/build-toolchain.yml with: - create_release: true - windows_default_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-16-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-8-cores' }} - windows_compilers_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-64-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-64-cores' }} + windows_build_arch: amd64 + windows_x64_default_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-16-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-8-cores' }} + windows_x64_compilers_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-64-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-64-cores' }} + windows_arm64_default_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-arm64-16-2024-10-10--{0}', github.run_id) || 'swift-build-windows-arm64-latest-8-cores' }} + windows_arm64_compilers_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-arm64-64-2024-10-10--{0}', github.run_id) || 'swift-build-windows-arm64-latest-32-cores' }} + android_api_level: 28 + secrets: inherit + permissions: + contents: write + packages: write + id-token: write + + call_development_snapshot_win_arm64: + if: false + name: Development Snapshot on Windows/ARM64 + uses: ./.github/workflows/build-toolchain.yml + with: + create_release: false + create_snapshot: false + windows_build_arch: arm64 + windows_x64_default_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-16-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-8-cores' }} + windows_x64_compilers_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-x64-64-2024-10-10--{0}', github.run_id) || 'swift-build-windows-latest-64-cores' }} + windows_arm64_default_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-arm64-16-2024-10-10--{0}', github.run_id) || 'swift-build-windows-arm64-latest-8-cores' }} + windows_arm64_compilers_runner: ${{ vars.USE_CIRUN == 'true' && format('cirun-win11-23h2-pro-arm64-64-2024-10-10--{0}', github.run_id) || 'swift-build-windows-arm64-latest-32-cores' }} android_api_level: 28 secrets: inherit permissions: diff --git a/.github/workflows/swift-toolchain.yml b/.github/workflows/swift-toolchain.yml index 61f8832c..b5f43f1c 100644 --- a/.github/workflows/swift-toolchain.yml +++ b/.github/workflows/swift-toolchain.yml @@ -340,7 +340,7 @@ jobs: ds2_tools: # TODO: Build this on macOS or make an equivalent Mac-only job - if: inputs.build_os == 'Windows' + if: inputs.build_os == 'Windows' && inputs.build_arch == 'amd64' runs-on: ${{ inputs.default_build_runner }} name: ds2 Build Tools @@ -355,7 +355,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: amd64 @@ -389,7 +389,7 @@ jobs: ds2: # TODO: Build this on macOS or make an equivalent Mac-only job - if: inputs.build_os == 'Windows' + if: inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' needs: [ds2_tools] runs-on: ${{ inputs.default_build_runner }} @@ -441,7 +441,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -592,6 +592,10 @@ jobs: show-progress: false - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main + with: + host_arch: ${{ inputs.build_arch }} + components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' + arch: ${{ matrix.arch }} - uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master if: inputs.build_os == 'Darwin' @@ -827,15 +831,7 @@ jobs: strategy: fail-fast: false - matrix: - include: - - arch: 'amd64' - cpu: 'x86_64' - triple: 'x86_64-unknown-windows-msvc' - - - arch: 'arm64' - cpu: 'aarch64' - triple: 'aarch64-unknown-windows-msvc' + matrix: ${{ fromJSON(inputs.host_matrix) }} name: Windows ${{ matrix.arch }} Toolchain @@ -881,17 +877,19 @@ jobs: show-progress: false - name: Install Python ${{ env.PYTHON_VERSION }} (Host) + if: matrix.arch == 'amd64' || inputs.build_arch == 'amd64' uses: actions/setup-python@v5 id: python with: python-version: '${{ env.PYTHON_VERSION }}' + architecture: x64 - uses: nuget/setup-nuget@v2 - if: matrix.arch == 'arm64' + if: matrix.arch == 'arm64' || inputs.build_arch == 'arm64' # TODO(lxbndr) use actions/cache to improve this step timings - name: Install Python ${{ env.PYTHON_VERSION }} (arm64) - if: matrix.arch == 'arm64' + if: matrix.arch == 'arm64' || inputs.build_arch == 'arm64' run: | $NugetSources=[string](nuget Sources List -Format short) if (-Not ($NugetSources.contains("api.nuget.org"))) { @@ -906,19 +904,29 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} - name: Install Swift Toolchain + if: inputs.build_arch == 'amd64' uses: compnerd/gha-setup-swift@b6c5fc1ed5b5439ada8e7661985acb09ad8c3ba2 # main with: github-repo: thebrowsercompany/swift-build github-token: ${{ secrets.GITHUB_TOKEN }} - release-asset-name: installer-amd64.exe + release-asset-name: installer-${{ inputs.build_arch }}.exe release-tag-name: '20231016.5' + - name: Install Swift Toolchain + if: inputs.build_arch == 'arm64' + uses: compnerd/gha-setup-swift@b6c5fc1ed5b5439ada8e7661985acb09ad8c3ba2 # main + with: + github-repo: thebrowsercompany/swift-build + github-token: ${{ secrets.GITHUB_TOKEN }} + release-asset-name: installer-${{ inputs.build_arch }}.exe + release-tag-name: '20231016.0' - uses: nttld/setup-ndk@v1 + if: inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' id: setup-ndk with: ndk-version: ${{ inputs.ANDROID_NDK_VERSION }} @@ -943,8 +951,6 @@ jobs: variant: sccache - name: Configure Compilers - env: - NDKPATH: ${{ steps.setup-ndk.outputs.ndk-path }} run: | if ( "${{ matrix.arch }}" -eq "arm64" ) { $CMAKE_SYSTEM_NAME="-D CMAKE_SYSTEM_NAME=Windows" @@ -1111,7 +1117,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -1137,15 +1143,19 @@ jobs: variant: sccache - uses: nttld/setup-ndk@v1 + if: inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' id: setup-ndk with: ndk-version: ${{ inputs.ANDROID_NDK_VERSION }} - name: Configure zlib run: | - $NDKPATH = "${{ steps.setup-ndk.outputs.ndk-path }}" - if ( "${{ inputs.build_os }}" -eq "Windows" ) { - $NDKPATH = cygpath -m $NDKPATH + if ( "${{ inputs.build_os }}" -ne "Windows" -or "${{ inputs.build_arch }}" -ne "arm64" ) { + $NDKPATH = "${{ steps.setup-ndk.outputs.ndk-path }}" + if ( "${{ inputs.build_os }}" -eq "Windows" ) { + $NDKPATH = cygpath -m $NDKPATH + } + $CMAKE_NDK_FLAG = "-DCMAKE_ANDROID_NDK=$NDKPATH" } cmake -B ${{ github.workspace }}/BinaryCache/zlib-${{ inputs.zlib_version }} ` -D BUILD_SHARED_LIBS=NO ` @@ -1158,7 +1168,7 @@ jobs: -D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" ` -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/zlib-${{ inputs.zlib_version }}/usr ` -D CMAKE_SYSTEM_NAME=${{ matrix.os }} ` - -D CMAKE_ANDROID_NDK=$NDKPATH ` + $CMAKE_NDK_FLAG ` -D CMAKE_POSITION_INDEPENDENT_CODE=YES ` ${{ matrix.extra_flags }} ` -G Ninja ` @@ -1199,7 +1209,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -1225,15 +1235,19 @@ jobs: variant: sccache - uses: nttld/setup-ndk@v1 + if: inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' id: setup-ndk with: ndk-version: ${{ inputs.ANDROID_NDK_VERSION }} - name: Configure curl run: | - $NDKPATH = "${{ steps.setup-ndk.outputs.ndk-path }}" - if ( "${{ inputs.build_os }}" -eq "Windows" ) { - $NDKPATH = cygpath -m $NDKPATH + if ( "${{ inputs.build_os }}" -ne "Windows" -or "${{ inputs.build_arch }}" -ne "arm64" ) { + $NDKPATH = "${{ steps.setup-ndk.outputs.ndk-path }}" + if ( "${{ inputs.build_os }}" -eq "Windows" ) { + $NDKPATH = cygpath -m $NDKPATH + } + $CMAKE_NDK_FLAG = "-DCMAKE_ANDROID_NDK=$NDKPATH" } cmake -B ${{ github.workspace }}/BinaryCache/curl-${{ inputs.curl_version }} ` -D BUILD_SHARED_LIBS=NO ` @@ -1328,7 +1342,7 @@ jobs: -D ZLIB_ROOT=${{ github.workspace }}/BuildRoot/Library/zlib-${{ inputs.zlib_version }}/usr ` -D ZLIB_LIBRARY=${{ github.workspace }}/BuildRoot/Library/zlib-${{ inputs.zlib_version }}/usr/lib/zlibstatic.lib ` -D CMAKE_POSITION_INDEPENDENT_CODE=YES ` - -D CMAKE_ANDROID_NDK=$NDKPATH + $CMAKE_NDK_FLAG - name: Build curl run: cmake --build ${{ github.workspace }}/BinaryCache/curl-${{ inputs.curl_version }} - name: Install curl @@ -1358,7 +1372,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -1385,15 +1399,19 @@ jobs: variant: sccache - uses: nttld/setup-ndk@v1 + if: inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' id: setup-ndk with: ndk-version: ${{ inputs.ANDROID_NDK_VERSION }} - name: Configure libxml2 run: | - $NDKPATH = "${{ steps.setup-ndk.outputs.ndk-path }}" - if ( "${{ inputs.build_os }}" -eq "Windows" ) { - $NDKPATH = cygpath -m $NDKPATH + if ( "${{ inputs.build_os }}" -ne "Windows" -or "${{ inputs.build_arch }}" -ne "arm64" ) { + $NDKPATH = "${{ steps.setup-ndk.outputs.ndk-path }}" + if ( "${{ inputs.build_os }}" -eq "Windows" ) { + $NDKPATH = cygpath -m $NDKPATH + } + $CMAKE_NDK_FLAG = "-DCMAKE_ANDROID_NDK=$NDKPATH" } cmake -B ${{ github.workspace }}/BinaryCache/libxml2-${{ inputs.libxml2_version }} ` -D BUILD_SHARED_LIBS=NO ` @@ -1417,7 +1435,7 @@ jobs: -D LIBXML2_WITH_THREADS=YES ` -D LIBXML2_WITH_ZLIB=NO ` -D CMAKE_POSITION_INDEPENDENT_CODE=YES ` - -D CMAKE_ANDROID_NDK=$NDKPATH + $CMAKE_NDK_FLAG - name: Build libxml2 run: cmake --build ${{ github.workspace }}/BinaryCache/libxml2-${{ inputs.libxml2_version }} - name: Install libxml2 @@ -1542,7 +1560,7 @@ jobs: - name: Download Compilers uses: actions/download-artifact@v4 with: - name: compilers-amd64 + name: compilers-${{ inputs.build_arch }} path: ${{ github.workspace }}/BuildRoot/Library - uses: actions/checkout@v4 with: @@ -1574,32 +1592,46 @@ jobs: # we have not yet built the runtime, this requires that we use the runtime # from the previous build. - name: Install Swift Toolchain + if: inputs.build_arch == 'amd64' uses: compnerd/gha-setup-swift@b6c5fc1ed5b5439ada8e7661985acb09ad8c3ba2 # main with: github-repo: thebrowsercompany/swift-build github-token: ${{ secrets.GITHUB_TOKEN }} - release-asset-name: installer-amd64.exe + release-asset-name: installer-${{ inputs.build_arch }}.exe release-tag-name: '20231016.5' + - name: Install Swift Toolchain + if: inputs.build_arch == 'arm64' + uses: compnerd/gha-setup-swift@b6c5fc1ed5b5439ada8e7661985acb09ad8c3ba2 # main + with: + github-repo: thebrowsercompany/swift-build + github-token: ${{ secrets.GITHUB_TOKEN }} + release-asset-name: installer-${{ inputs.build_arch }}.exe + release-tag-name: '20231016.0' # NOTE(compnerd): we execute unconditionally as we use CMake from VSDevEnv - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} # NOTE(compnerd): we execute unconditionally as we reference outputs - uses: nttld/setup-ndk@v1 + if: inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' id: setup-ndk with: ndk-version: ${{ inputs.ANDROID_NDK_VERSION }} - name: Configure LLVM + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | # NOTE: used by `matrix.cc` $CLANG_CL = "cl" - $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} - + if ( "${{ inputs.build_os }}" -ne "Windows" -or "${{ inputs.build_arch }}" -ne "arm64" ) { + $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + $CMAKE_NDK_FLAG = "-DCMAKE_ANDROID_NDK=$NDKPATH" + $SWIFT_NDK_FLAG = "-DSWIFT_ANDROID_NDK_PATH=$NDKPATH" + } cmake -B ${{ github.workspace }}/BinaryCache/llvm ` -D CMAKE_BUILD_TYPE=Release ` -D CMAKE_C_COMPILER=${{ matrix.cc }} ` @@ -1611,19 +1643,24 @@ jobs: -D CMAKE_SYSTEM_NAME=${{ matrix.os }} ` ${{ matrix.llvm_flags }} ` ${{ matrix.extra_flags }} ` - -D CMAKE_ANDROID_NDK=${NDKPATH} ` - -D SWIFT_ANDROID_NDK_PATH=${NDKPATH} ` + $CMAKE_NDK_FLAG ` + $SWIFT_NDK_FLAG ` -G Ninja ` -S ${{ github.workspace }}/SourceCache/llvm-project/llvm ` -D LLVM_ENABLE_ASSERTIONS=YES - name: Configure Swift Standard Library + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | # NOTE: used by `matrix.cc` $CLANG_CL = cygpath -m ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang-cl.exe $SWIFTC = cygpath -m ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe - $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + if ( "${{ inputs.build_os }}" -ne "Windows" -or "${{ inputs.build_arch }}" -ne "arm64" ) { + $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + $CMAKE_NDK_FLAG = "-DCMAKE_ANDROID_NDK=$NDKPATH" + $SWIFT_NDK_FLAG = "-DSWIFT_ANDROID_NDK_PATH=$NDKPATH" + } $CMAKE_CPU = if ("${{ matrix.cpu }}" -eq "armv7") { "armv7-a" @@ -1653,8 +1690,8 @@ jobs: -D MSVC_CXX_ARCHITECTURE_ID=${{ matrix.arch }} ` ${{ matrix.linker_flags }} ` ${{ matrix.extra_flags }} ` - -D CMAKE_ANDROID_NDK=${NDKPATH} ` - -D SWIFT_ANDROID_NDK_PATH=${NDKPATH} ` + $CMAKE_NDK_FLAG ` + $SWIFT_NDK_FLAG ` -G Ninja ` -S ${{ github.workspace }}/SourceCache/swift ` -D LLVM_DIR=${{ github.workspace }}/BinaryCache/llvm/lib/cmake/llvm ` @@ -1671,15 +1708,18 @@ jobs: -D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=${{ github.workspace }}/SourceCache/swift-syntax ` -D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=${{ github.workspace }}/SourceCache/swift-experimental-string-processing - name: Build Swift Standard Library + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | Remove-Item env:\SDKROOT cmake --build ${{ github.workspace }}/BinaryCache/swift - name: Install Swift Standard Library + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | Remove-Item env:\SDKROOT cmake --build ${{ github.workspace }}/BinaryCache/swift --target install - uses: actions/upload-artifact@v4 + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' with: name: ${{ matrix.os }}-stdlib-${{ matrix.arch }} path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.os }}.platform @@ -1732,7 +1772,7 @@ jobs: - name: Download Compilers uses: actions/download-artifact@v4 with: - name: compilers-amd64 + name: compilers-${{ inputs.build_arch }} path: ${{ github.workspace }}/BinaryCache/Library - name: Download swift-syntax uses: actions/download-artifact@v4 @@ -1746,7 +1786,7 @@ jobs: - uses: actions/download-artifact@v4 if: matrix.arch == 'arm64' with: - name: Windows-stdlib-amd64 + name: Windows-stdlib-${{ inputs.build_arch }} path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform - uses: actions/download-artifact@v4 with: @@ -1774,7 +1814,7 @@ jobs: # NOTE(compnerd): we execute unconditionally as we use CMake from VSDevEnv - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -1961,14 +2001,17 @@ jobs: steps: - uses: actions/download-artifact@v4 + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' with: name: libxml2-${{ matrix.os }}-${{ matrix.arch }}-${{ inputs.libxml2_version }} path: ${{ github.workspace }}/BuildRoot/Library/libxml2-${{ inputs.libxml2_version }}/usr - uses: actions/download-artifact@v4 + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' with: name: curl-${{ matrix.os }}-${{ matrix.arch }}-${{ inputs.curl_version }} path: ${{ github.workspace }}/BuildRoot/Library/curl-${{ inputs.curl_version }}/usr - uses: actions/download-artifact@v4 + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' with: name: zlib-${{ matrix.os }}-${{ matrix.arch }}-${{ inputs.zlib_version }} path: ${{ github.workspace }}/BuildRoot/Library/zlib-${{ inputs.zlib_version }}/usr @@ -1976,15 +2019,16 @@ jobs: - name: Download Compilers uses: actions/download-artifact@v4 with: - name: compilers-amd64 + name: compilers-${{ inputs.build_arch }} path: ${{ github.workspace }}/BinaryCache/Library - uses: actions/download-artifact@v4 + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' with: name: ${{ matrix.os }}-stdlib-${{ matrix.arch }} path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/${{ matrix.os }}.platform - uses: actions/download-artifact@v4 with: - name: Windows-stdlib-amd64 + name: Windows-stdlib-${{ inputs.build_arch }} path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform - uses: actions/download-artifact@v4 if: matrix.os == 'Windows' @@ -1993,7 +2037,7 @@ jobs: path: ${{ github.workspace }}/BinaryCache/swift/stdlib - uses: actions/download-artifact@v4 with: - name: macros-amd64 + name: macros-${{ inputs.build_arch }} path: ${{ github.workspace }}/BinaryCache/Library - uses: actions/checkout@v4 with: @@ -2056,7 +2100,7 @@ jobs: # NOTE(compnerd): we execute unconditionally as we use CMake from VSDevEnv - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -2067,17 +2111,23 @@ jobs: # NOTE(compnerd): we execute unconditionally as we reference outputs - uses: nttld/setup-ndk@v1 + if: inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' id: setup-ndk with: ndk-version: ${{ inputs.ANDROID_NDK_VERSION }} - name: Configure libdispatch + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | # Workaround CMake 3.20 issue $CLANG_CL = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang-cl.exe $SWIFTC = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe - $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + if ( "${{ inputs.build_os }}" -ne "Windows" -or "${{ inputs.build_arch }}" -ne "arm64" ) { + $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + $CMAKE_NDK_FLAG = "-DCMAKE_ANDROID_NDK=$NDKPATH" + $SWIFT_NDK_FLAG = "-DSWIFT_ANDROID_NDK_PATH=$NDKPATH" + } $WINDOWS_VFS_OVERLAY = cygpath -m ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml $OVERLAY_FLAGS = if ("${{ matrix.os }}" -eq "Windows") { @@ -2109,23 +2159,29 @@ jobs: -D MSVC_CXX_ARCHITECTURE_ID=${{ matrix.arch }} ` ${{ matrix.linker_flags }} ` ${{ matrix.extra_flags }} ` - -D CMAKE_ANDROID_NDK=$NDKPATH ` - -D SWIFT_ANDROID_NDK_PATH=$NDKPATH ` + $CMAKE_NDK_FLAG ` + $SWIFT_NDK_FLAG ` -G Ninja ` -S ${{ github.workspace }}/SourceCache/swift-corelibs-libdispatch ` -D BUILD_TESTING=NO ` -D ENABLE_SWIFT=YES - name: Build libdispatch + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | cmake --build ${{ github.workspace }}/BinaryCache/libdispatch - name: Configure Foundation + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | # Workaround CMake 3.20 issue $CLANG_CL = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang-cl.exe $SWIFTC = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe - $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + if ( "${{ inputs.build_os }}" -ne "Windows" -or "${{ inputs.build_arch }}" -ne "arm64" ) { + $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + $CMAKE_NDK_FLAG = "-DCMAKE_ANDROID_NDK=$NDKPATH" + $SWIFT_NDK_FLAG = "-DSWIFT_ANDROID_NDK_PATH=$NDKPATH" + } $WINDOWS_VFS_OVERLAY = cygpath -m ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml $OVERLAY_FLAGS = if ("${{ matrix.os }}" -eq "Windows") { @@ -2170,8 +2226,8 @@ jobs: -D MSVC_CXX_ARCHITECTURE_ID=${{ matrix.arch }} ` ${{ matrix.linker_flags }} ` ${{ matrix.extra_flags }} ` - -D CMAKE_ANDROID_NDK=$NDKPATH ` - -D SWIFT_ANDROID_NDK_PATH=$NDKPATH ` + $CMAKE_NDK_FLAG ` + $SWIFT_NDK_FLAG ` -G Ninja ` -S ${{ github.workspace }}/SourceCache/swift-corelibs-foundation ` -D dispatch_DIR=${{ github.workspace }}/BinaryCache/libdispatch/cmake/modules ` @@ -2189,17 +2245,23 @@ jobs: -D ZLIB_LIBRARY=${{ github.workspace }}/BuildRoot/Library/zlib-${{ inputs.zlib_version }}/usr/lib/$LIBZ ` -D SwiftFoundation_MACRO=${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin - name: Build foundation + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | cmake --build ${{ github.workspace }}/BinaryCache/foundation # TODO(compnerd) correctly version XCTest - name: Configure xctest + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | # Workaround CMake 3.20 issue $CLANG_CL = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang-cl.exe $SWIFTC = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe - $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + if ( "${{ inputs.build_os }}" -ne "Windows" -or "${{ inputs.build_arch }}" -ne "arm64" ) { + $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + $CMAKE_NDK_FLAG = "-DCMAKE_ANDROID_NDK=$NDKPATH" + $SWIFT_NDK_FLAG = "-DSWIFT_ANDROID_NDK_PATH=$NDKPATH" + } $WINDOWS_VFS_OVERLAY = cygpath -m ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml $OVERLAY_FLAGS = if ("${{ matrix.os }}" -eq "Windows") { @@ -2230,24 +2292,30 @@ jobs: -D CMAKE_SYSTEM_PROCESSOR=${CMAKE_CPU} ` ${{ matrix.linker_flags }} ` ${{ matrix.extra_flags }} ` - -D CMAKE_ANDROID_NDK=$NDKPATH ` - -D SWIFT_ANDROID_NDK_PATH=$NDKPATH ` + $CMAKE_NDK_FLAG ` + $SWIFT_NDK_FLAG ` -G Ninja ` -S ${{ github.workspace }}/SourceCache/swift-corelibs-xctest ` -D dispatch_DIR=${{ github.workspace }}/BinaryCache/libdispatch/cmake/modules ` -D Foundation_DIR=${{ github.workspace }}/BinaryCache/foundation/cmake/modules ` -D ENABLE_TESTING=NO - name: Build xctest + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | cmake --build ${{ github.workspace }}/BinaryCache/xctest - name: Configure Testing + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | # Workaround CMake 3.20 issue $CLANG_CL = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang-cl.exe $SWIFTC = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe - $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + if ( "${{ inputs.build_os }}" -ne "Windows" -or "${{ inputs.build_arch }}" -ne "arm64" ) { + $NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }} + $CMAKE_NDK_FLAG = "-DCMAKE_ANDROID_NDK=$NDKPATH" + $SWIFT_NDK_FLAG = "-DSWIFT_ANDROID_NDK_PATH=$NDKPATH" + } $WINDOWS_VFS_OVERLAY = cygpath -m ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml $OVERLAY_FLAGS = if ("${{ matrix.os }}" -eq "Windows") { @@ -2277,32 +2345,38 @@ jobs: -D CMAKE_SYSTEM_PROCESSOR=${CMAKE_CPU} ` ${{ matrix.linker_flags }} ` ${{ matrix.extra_flags }} ` - -D CMAKE_ANDROID_NDK=${NDKPATH} ` - -D SWIFT_ANDROID_NDK_PATH=${NDKPATH} ` + $CMAKE_NDK_FLAG ` + $SWIFT_NDK_FLAG ` -G Ninja ` -S ${{ github.workspace }}/SourceCache/swift-testing ` -D dispatch_DIR=${{ github.workspace }}/BinaryCache/libdispatch/cmake/modules ` -D Foundation_DIR=${{ github.workspace }}/BinaryCache/foundation/cmake/modules ` -D SwiftTesting_MACRO=${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/TestingMacros.dll - name: Build Testing + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | cmake --build ${{ github.workspace }}/BinaryCache/testing - name: Install Testing + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | cmake --build ${{ github.workspace }}/BinaryCache/testing --target install - name: Install xctest + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | cmake --build ${{ github.workspace }}/BinaryCache/xctest --target install - name: Install foundation + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | cmake --build ${{ github.workspace }}/BinaryCache/foundation --target install - name: Install libdispatch + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' run: | cmake --build ${{ github.workspace }}/BinaryCache/libdispatch --target install - uses: actions/setup-python@v5 - uses: jannekem/run-python-script-action@v1 + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' with: script: | import os @@ -2320,6 +2394,7 @@ jobs: plistlib.dump({ 'DefaultProperties': { 'DEFAULT_USE_RUNTIME': 'MD' } }, plist) - uses: actions/upload-artifact@v4 + if: matrix.os != 'Android' || inputs.build_os != 'Windows' || inputs.build_arch != 'arm64' with: name: ${{ matrix.os }}-sdk-${{ matrix.arch }} path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.os }}.platform @@ -2350,15 +2425,7 @@ jobs: strategy: fail-fast: false - matrix: - include: - - arch: 'amd64' - cpu: 'x86_64' - triple: 'x86_64-unknown-windows-msvc' - - - arch: 'arm64' - cpu: 'aarch64' - triple: 'aarch64-unknown-windows-msvc' + matrix: ${{ fromJSON(inputs.host_matrix) }} name: Windows ${{ matrix.arch }} Developer Tools @@ -2371,7 +2438,7 @@ jobs: - name: Download Compilers uses: actions/download-artifact@v4 with: - name: compilers-amd64 + name: compilers-${{ inputs.build_arch }} path: ${{ github.workspace }}/BinaryCache/Library - uses: actions/download-artifact@v4 with: @@ -2383,7 +2450,7 @@ jobs: path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform - uses: actions/download-artifact@v4 with: - name: macros-amd64 + name: macros-${{ inputs.build_arch }} path: ${{ github.workspace }}/BinaryCache/Library - uses: actions/download-artifact@v4 with: @@ -2500,7 +2567,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -2524,11 +2591,11 @@ jobs: # Download host libraries for the windows amd64 host, after moving the target libraries to the target-specific directory. - uses: actions/download-artifact@v4 with: - name: Windows-stdlib-amd64 + name: Windows-stdlib-${{ inputs.build_arch }} path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform - uses: actions/download-artifact@v4 with: - name: Windows-sdk-amd64 + name: Windows-sdk-${{ inputs.build_arch }} path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform - name: Configure swift-argument-parser @@ -3061,14 +3128,7 @@ jobs: strategy: fail-fast: false - matrix: - include: - - arch: amd64 - cpu: x86_64 - triple: x86_64-unknown-windows-msvc - - arch: arm64 - cpu: aarch64 - triple: aarch64-unknown-windows-msvc + matrix: ${{ fromJSON(inputs.host_matrix) }} name: Windows ${{ matrix.arch }} Debugging Tools @@ -3076,12 +3136,12 @@ jobs: - name: Download Compilers uses: actions/download-artifact@v4 with: - name: compilers-amd64 + name: compilers-${{ inputs.build_arch }} path: ${{ github.workspace }}/BuildRoot/Library - name: Download Devtools uses: actions/download-artifact@v4 with: - name: devtools-amd64 + name: devtools-${{ inputs.build_arch }} path: ${{ github.workspace }}/BuildRoot/Library - name: Download stdlib uses: actions/download-artifact@v4 @@ -3126,11 +3186,11 @@ jobs: # Download host SDK on top of the target SDK, so that the runtime DLLs are the host ones. - uses: actions/download-artifact@v4 with: - name: Windows-stdlib-amd64 + name: Windows-stdlib-${{ inputs.build_arch }} path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Windows.platform - uses: actions/download-artifact@v4 with: - name: Windows-sdk-amd64 + name: Windows-sdk-${{ inputs.build_arch }} path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Windows.platform - name: Move host libs to the host architecture directory @@ -3202,8 +3262,8 @@ jobs: strategy: fail-fast: false - matrix: - arch: ['amd64' , 'arm64'] + + matrix: ${{ fromJSON(inputs.host_matrix) }} steps: - name: Download Debugging Tools @@ -3239,7 +3299,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -3409,7 +3469,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -3477,7 +3537,7 @@ jobs: package_android_sdk_runtime: # TODO: Build this on macOS or make an equivalent Mac-only job - if: inputs.build_os == 'Windows' + if: inputs.build_os == 'Windows' && inputs.build_arch == 'amd64' name: Package Android SDK & Runtime needs: [stdlib, ds2, sdk] runs-on: ${{ inputs.default_build_runner }} @@ -3523,7 +3583,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -3547,7 +3607,7 @@ jobs: -p:BaseOutputPath=${{ github.workspace }}\BinaryCache\installer\ ` -p:Configuration=Release ` -p:SignOutput=${{ inputs.signed }} ` - -p:ANDROID_INCLUDE_DS2=true ` + -p:ANDROID_INCLUDE_DS2=${{ inputs.build_arch == 'amd64' && true || false }} ` -p:CERTIFICATE=${env:CERTIFICATE} ` -p:PASSPHRASE=${{ secrets.PASSPHRASE }} ` -p:PLATFORM_ROOT=${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Android.platform ` @@ -3571,8 +3631,7 @@ jobs: strategy: fail-fast: false - matrix: - arch: ['amd64' , 'arm64'] + matrix: ${{ fromJSON(inputs.host_matrix) }} steps: - uses: actions/download-artifact@v4 @@ -3620,18 +3679,22 @@ jobs: name: sdk-windows-arm64-msi path: ${{ github.workspace }}/BinaryCache/installer/Release/arm64 - uses: actions/download-artifact@v4 + if: inputs.build_arch == 'amd64' with: name: sdk-android-arm64-msi path: ${{ github.workspace }}/BinaryCache/installer/Release/aarch64 - uses: actions/download-artifact@v4 + if: inputs.build_arch == 'amd64' with: name: sdk-android-x86_64-msi path: ${{ github.workspace }}/BinaryCache/installer/Release/x86_64 - uses: actions/download-artifact@v4 + if: inputs.build_arch == 'amd64' with: name: sdk-android-armv7-msi path: ${{ github.workspace }}/BinaryCache/installer/Release/armv7 - uses: actions/download-artifact@v4 + if: inputs.build_arch == 'amd64' with: name: sdk-android-i686-msi path: ${{ github.workspace }}/BinaryCache/installer/Release/i686 @@ -3645,7 +3708,7 @@ jobs: - uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main with: - host_arch: amd64 + host_arch: ${{ inputs.build_arch }} components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64' arch: ${{ matrix.arch }} @@ -3689,10 +3752,10 @@ jobs: -p:INCLUDE_AMD64_SDK=true ` -p:INCLUDE_X86_SDK=true ` -p:INCLUDE_ARM64_SDK=true ` - -p:ANDROID_INCLUDE_ARM64_SDK=true ` - -p:ANDROID_INCLUDE_x86_64_SDK=true ` - -p:ANDROID_INCLUDE_ARM_SDK=true ` - -p:ANDROID_INCLUDE_X86_SDK=true ` + -p:ANDROID_INCLUDE_ARM64_SDK=${{ inputs.build_arch == 'amd64' && true || false }} ` + -p:ANDROID_INCLUDE_x86_64_SDK=${{ inputs.build_arch == 'amd64' && true || false }} ` + -p:ANDROID_INCLUDE_ARM_SDK=${{ inputs.build_arch == 'amd64' && true || false }} ` + -p:ANDROID_INCLUDE_X86_SDK=${{ inputs.build_arch == 'amd64' && true || false }} ` -p:ProductArchitecture=${{ matrix.arch }} ` -p:ProductVersion=${{ inputs.swift_version }}-${{ inputs.swift_tag }} ` ${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bundle/installer.wixproj @@ -3711,7 +3774,7 @@ jobs: steps: - uses: actions/download-artifact@v4 with: - name: installer-amd64 + name: installer-${{ inputs.build_arch }} path: ${{ github.workspace }}/tmp # TODO(compnerd): migrate this to compnerd/gha-setup-swift after the work that @mangini is doing is completed