Skip to content

Commit

Permalink
[wip][Mac build] Add macros build
Browse files Browse the repository at this point in the history
  • Loading branch information
Steelskin committed Nov 8, 2024
1 parent 224bb19 commit d6196d1
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 48 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ jobs:
"include": [
{
"arch": "amd64",
"cpu": "x86_64",
"os": "Windows",
"platform": "Windows",
"triple": "x86_64-unknown-windows-msvc",
"cc": "cl",
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
"cxx": "cl",
Expand All @@ -323,7 +326,10 @@ jobs:
},
{
"arch": "arm64",
"cpu": "aarch64",
"os": "Windows",
"platform": "Windows",
"triple": "aarch64-unknown-windows-msvc",
"cc": "cl",
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
"cxx": "cl",
Expand Down Expand Up @@ -471,7 +477,10 @@ jobs:
"include": [
{
"arch": "x86_64",
"cpu": "x86_64",
"os": "Darwin",
"platform": "MacOSX",
"triple": "x86_64-apple-macosx15.0",
"cc": "clang",
"cflags": "${{ steps.context.outputs.DARWIN_CMAKE_C_FLAGS }}",
"cxx": "clang++",
Expand All @@ -482,7 +491,10 @@ jobs:
},
{
"arch": "arm64",
"cpu": "aarch64",
"os": "Darwin",
"platform": "MacOSX",
"triple": "aarch64-apple-macosx15.0",
"cc": "clang",
"cflags": "${{ steps.context.outputs.DARWIN_CMAKE_C_FLAGS }}",
"cxx": "clang++",
Expand Down
109 changes: 61 additions & 48 deletions .github/workflows/swift-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1673,9 +1673,9 @@ jobs:
}
cmake --build ${{ github.workspace }}/BinaryCache/swift --target install
- uses: actions/upload-artifact@v4
- uses: thebrowsercompany/gha-upload-tar-artifact@main
with:
name: ${{ matrix.platform }}-stdlib-${{ matrix.arch }}
name: ${{ matrix.os }}-stdlib-${{ matrix.arch }}
path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.platform }}.platform

- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -1703,46 +1703,38 @@ jobs:
searchPattern: '**/*.dll'

macros:
# TODO: Build this on macOS or make an equivalent Mac-only job
if: always() && inputs.build_os == 'Windows' && needs.stdlib.result == 'success'
if: always() && needs.stdlib.result == 'success'
needs: [compilers, cmark_gfm, stdlib]
runs-on: ${{ inputs.default_build_runner }}

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 }} Macros
name: ${{ matrix.os }} ${{ matrix.arch }} Macros

steps:
- name: Download Compilers
uses: thebrowsercompany/gha-download-tar-artifact@main
with:
name: compilers-Windows-${{ inputs.build_arch }}
name: compilers-${{ inputs.build_os }}-${{ inputs.build_arch }}
path: ${{ github.workspace }}/BinaryCache/Library
- name: Download swift-syntax
uses: thebrowsercompany/gha-download-tar-artifact@main
with:
name: swift-syntax-Windows-${{ matrix.arch }}
name: swift-syntax-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ github.workspace }}/BinaryCache/swift-syntax
- uses: actions/download-artifact@v4
- uses: thebrowsercompany/gha-download-tar-artifact@main
with:
name: Windows-stdlib-${{ matrix.arch }}
name: ${{ matrix.os }}-stdlib-${{ matrix.arch }}
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
- uses: actions/download-artifact@v4
if: matrix.arch == 'arm64'
- uses: thebrowsercompany/gha-download-tar-artifact@main
if: matrix.os == 'Windows' && matrix.arch == 'arm64'
with:
name: Windows-stdlib-amd64
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
- uses: actions/download-artifact@v4
if: matrix.os == 'Windows'
with:
name: windows-vfs-overlay-${{ matrix.arch }}
path: ${{ github.workspace }}/BinaryCache/swift/stdlib
Expand Down Expand Up @@ -1772,29 +1764,53 @@ jobs:
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
arch: ${{ matrix.arch }}

- run: |
$RTLPath = cygpath -w ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/bin
echo ${RTLPath} | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: extract swift-syntax
- name: Setup configuration
id: setup-config
run: |
$PlatformLower = "${{ matrix.platform }}".ToLower()
$SDKRoot = "${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/${{ matrix.platform }}.platform/Developer/SDKs/${{ matrix.platform }}.sdk"
$bindir = "${{ github.workspace }}/BinaryCache/swift-syntax"
$SwiftFlags = "-resource-dir ${SDKRoot}/usr/lib/swift"
$SwiftFlags += " -L${SDKRoot}/usr/lib/swift/${PlatformLower}"
$SwiftFlags += " -strict-implicit-module-context"
$SwiftFlags += " ${{ matrix.swiftflags }}"
if ("${{ matrix.os }}" -eq "Windows") {
$SwiftC = "${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe"
$bindir = cygpath -w $bindir
# Export the path to the runtime libraries. This is only needed for Windows.
$RTLPath = cygpath -w ${SDKRoot}/usr/bin
Write-Output ${RTLPath} | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# VFS Overlay is only required on Windows.
$SwiftFlags += " -vfsoverlay ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml"
# Add the Windows SDK headers to the system include path for Windows.
$SwiftFlags += " -Xcc -Xclang -Xcc -fbuiltin-headers-in-system-modules"
} else {
$SwiftC = "${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc"
}
# Configure swift-syntax.
$module = "${{ github.workspace }}/BinaryCache/swift-syntax/cmake/modules/SwiftSyntaxConfig.cmake"
$bindir = cygpath -m ${{ github.workspace }}/BinaryCache/swift-syntax
(Get-Content $module).Replace('<BINARY_DIR>', "${bindir}") | Set-Content $module
# Export the configuration.
Write-Output "swiftc=${SwiftC}" | Out-File -FilePath ${env:GITHUB_OUTPUT} -Encoding utf8 -Append
Write-Output "swift-flags=${SwiftFlags}" | Out-File -FilePath ${env:GITHUB_OUTPUT} -Encoding utf8 -Append
- name: Configure Foundation Macros
run: |
$WINDOWS_VFS_OVERLAY = cygpath -m ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml
$SWIFTC = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe
cmake -B ${{ github.workspace }}/BinaryCache/swift-foundation-macros `
-D CMAKE_BUILD_TYPE=Release `
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
-D CMAKE_Swift_COMPILER=${SWIFTC} `
-D CMAKE_Swift_COMPILER=${{ steps.setup-config.outputs.swiftc }} `
-D CMAKE_Swift_COMPILER_TARGET=${{ matrix.triple }} `
-D CMAKE_Swift_FLAGS="-resource-dir ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/lib/swift -L${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/lib/swift/windows -vfsoverlay ${WINDOWS_VFS_OVERLAY} -strict-implicit-module-context -Xcc -Xclang -Xcc -fbuiltin-headers-in-system-modules ${{ inputs.CMAKE_Swift_FLAGS }}" `
-D CMAKE_Swift_FLAGS="${{ steps.setup-config.outputs.swift-flags }}" `
-D CMAKE_Swift_FLAGS_RELEASE="-O" `
-D CMAKE_SYSTEM_NAME=Windows `
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
-D CMAKE_SYSTEM_PROCESSOR=${{ matrix.cpu }} `
-G Ninja `
-S ${{ github.workspace }}/SourceCache/swift-foundation/Sources/FoundationMacros `
Expand All @@ -1804,16 +1820,13 @@ jobs:

- name: Configure Testing Macros
run: |
$WINDOWS_VFS_OVERLAY = cygpath -m ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml
$SWIFTC = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe
cmake -B ${{ github.workspace }}/BinaryCache/swift-testing-macros `
-D CMAKE_BUILD_TYPE=Release `
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
-D CMAKE_Swift_COMPILER=${SWIFTC} `
-D CMAKE_Swift_COMPILER=${{ steps.setup-config.outputs.swiftc }} `
-D CMAKE_Swift_COMPILER_TARGET=${{ matrix.triple }} `
-D CMAKE_Swift_FLAGS="-resource-dir ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/lib/swift -L${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/lib/swift/windows -vfsoverlay ${WINDOWS_VFS_OVERLAY} -strict-implicit-module-context -Xcc -Xclang -Xcc -fbuiltin-headers-in-system-modules ${{ inputs.CMAKE_Swift_FLAGS }}" `
-D CMAKE_SYSTEM_NAME=Windows `
-D CMAKE_Swift_FLAGS="${{ steps.setup-config.outputs.swift-flags }}" `
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
-D CMAKE_SYSTEM_PROCESSOR=${{ matrix.cpu }} `
-G Ninja `
-S ${{ github.workspace }}/SourceCache/swift-testing/Sources/TestingMacros `
Expand All @@ -1827,14 +1840,14 @@ jobs:
run: cmake --build ${{ github.workspace }}/BinaryCache/swift-testing-macros --target install

- name: Upload macros
uses: actions/upload-artifact@v4
uses: thebrowsercompany/gha-upload-tar-artifact@main
with:
name: macros-${{ matrix.arch }}
name: macros-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ github.workspace }}/BuildRoot/Library

- name: Upload PDBs to Azure
uses: microsoft/[email protected]
if: ${{ inputs.debug_info }}
if: ${{ inputs.debug_info && matrix.os == 'Windows' }}
with:
accountName: ${{ vars.SYMBOL_SERVER_ACCOUNT }}
personalAccessToken: ${{ secrets.SYMBOL_SERVER_PAT }}
Expand All @@ -1843,7 +1856,7 @@ jobs:

- name: Upload DLLs to Azure
uses: microsoft/[email protected]
if: ${{ inputs.debug_info }}
if: ${{ inputs.debug_info && matrix.os == 'Windows' }}
with:
accountName: ${{ vars.SYMBOL_SERVER_ACCOUNT }}
personalAccessToken: ${{ secrets.SYMBOL_SERVER_PAT }}
Expand Down Expand Up @@ -1985,9 +1998,9 @@ jobs:
with:
name: windows-vfs-overlay-${{ matrix.arch }}
path: ${{ github.workspace }}/BinaryCache/swift/stdlib
- uses: actions/download-artifact@v4
- uses: thebrowsercompany/gha-download-tar-artifact@main
with:
name: macros-amd64
name: macros-Windows-amd64
path: ${{ github.workspace }}/BinaryCache/Library
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -2375,9 +2388,9 @@ jobs:
with:
name: Windows-sdk-${{ matrix.arch }}
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
- uses: actions/download-artifact@v4
- uses: thebrowsercompany/gha-download-tar-artifact@main
with:
name: macros-amd64
name: macros-Windows-amd64
path: ${{ github.workspace }}/BinaryCache/Library
- uses: thebrowsercompany/gha-download-tar-artifact@main
with:
Expand Down Expand Up @@ -3218,9 +3231,9 @@ jobs:
path: ${{ github.workspace }}/BuildRoot/Library

- name: Download Macros
uses: actions/download-artifact@v4
uses: thebrowsercompany/gha-download-tar-artifact@main
with:
name: macros-${{ matrix.arch }}
name: macros-Windows-${{ matrix.arch }}
path: ${{ github.workspace }}/BuildRoot/Library

- uses: actions/checkout@v4
Expand Down

0 comments on commit d6196d1

Please sign in to comment.