Skip to content

Commit 400fce1

Browse files
compnerdhyp
andcommitted
GHA: introduce a new macros build phase
Introduce a new macros build phase for the Foundation (and eventually Testing) macros. This depends on the previously introduced stdlib phase as the macros use the standard library. We build the macros for the compiler hosts, reusing them to build the SDK content. Wire this into the packaging step for the build tools as well. Co-authored-by: Alex Lorenz <[email protected]>
1 parent 1177dfa commit 400fce1

File tree

1 file changed

+167
-35
lines changed

1 file changed

+167
-35
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 167 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,9 +1487,145 @@ jobs:
14871487
symbolsFolder: ${{ github.workspace }}/BinaryCache
14881488
searchPattern: '**/*.dll'
14891489

1490+
macros:
1491+
needs: [context, compilers, cmark_gfm, stdlib]
1492+
runs-on: ${{ needs.context.outputs.windows_build_runner }}
1493+
1494+
strategy:
1495+
fail-fast: false
1496+
matrix:
1497+
include:
1498+
- arch: 'amd64'
1499+
cpu: 'x86_64'
1500+
triple: 'x86_64-unknown-windows-msvc'
1501+
1502+
- arch: 'arm64'
1503+
cpu: 'aarch64'
1504+
triple: 'aarch64-unknown-windows-msvc'
1505+
1506+
name: Windows ${{ matrix.arch }} Macros
1507+
1508+
steps:
1509+
- name: Download Compilers
1510+
uses: actions/download-artifact@v4
1511+
with:
1512+
name: compilers-amd64
1513+
path: ${{ github.workspace }}/BinaryCache/Library
1514+
- name: Download swift-syntax
1515+
uses: actions/download-artifact@v4
1516+
with:
1517+
name: swift-syntax-${{ matrix.arch }}
1518+
path: ${{ github.workspace }}/BinaryCache/swift-syntax
1519+
- uses: actions/download-artifact@v4
1520+
with:
1521+
name: Windows-stdlib-${{ matrix.arch }}
1522+
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
1523+
- uses: actions/download-artifact@v4
1524+
if: matrix.arch == 'arm64'
1525+
with:
1526+
name: Windows-stdlib-amd64
1527+
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
1528+
- uses: actions/download-artifact@v4
1529+
with:
1530+
name: windows-vfs-overlay-${{ matrix.arch }}
1531+
path: ${{ github.workspace }}/BinaryCache/swift/stdlib
1532+
- uses: actions/download-artifact@v4
1533+
with:
1534+
name: cmark-gfm-amd64-0.29.0.gfm.13
1535+
path: ${{ github.workspace }}/BinaryCache/Library/cmark-gfm-0.29.0.gfm.13/usr
1536+
1537+
- name: cmark-gfm Setup
1538+
run: Copy-Item ${{ github.workspace }}/BinaryCache/Library/cmark-gfm-0.29.0.gfm.13/usr/bin/*.dll ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/
1539+
1540+
- uses: actions/checkout@v4
1541+
with:
1542+
repository: apple/swift
1543+
ref: ${{ needs.context.outputs.swift_revision }}
1544+
path: ${{ github.workspace }}/SourceCache/swift
1545+
show-progress: false
1546+
- uses: actions/checkout@v4
1547+
with:
1548+
repository: apple/swift-foundation
1549+
ref: ${{ needs.context.outputs.swift_foundation_revision }}
1550+
path: ${{ github.workspace }}/SourceCache/swift-foundation
1551+
show-progress: false
1552+
1553+
# NOTE(compnerd): we execute unconditionally as we use CMake from VSDevEnv
1554+
- uses: compnerd/gha-setup-vsdevenv@main
1555+
with:
1556+
host_arch: amd64
1557+
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
1558+
arch: ${{ matrix.arch }}
1559+
1560+
- run: |
1561+
$RTLPath = cygpath -w ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/bin
1562+
echo ${RTLPath} | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
1563+
1564+
- name: extract swift-syntax
1565+
run: |
1566+
$module = "${{ github.workspace }}/BinaryCache/swift-syntax/cmake/modules/SwiftSyntaxConfig.cmake"
1567+
$bindir = cygpath -m ${{ github.workspace }}/BinaryCache/swift-syntax
1568+
(Get-Content $module).Replace('<BINARY_DIR>', "${bindir}") | Set-Content $module
1569+
1570+
- name: Configure Foundation Macros
1571+
run: |
1572+
$WINDOWS_VFS_OVERLAY = cygpath -m ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml
1573+
$SWIFTC = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe
1574+
1575+
cmake -B ${{ github.workspace }}/BinaryCache/swift-foundation-macros `
1576+
-D CMAKE_BUILD_TYPE=Release `
1577+
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
1578+
-D CMAKE_Swift_COMPILER=${SWIFTC} `
1579+
-D CMAKE_Swift_COMPILER_TARGET=${{ matrix.triple }} `
1580+
-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 ${{ needs.context.otuputs.CMAKE_Swift_FLAGS }}" `
1581+
-D CMAKE_Swift_FLAGS_RELEASE="-O" `
1582+
-D CMAKE_SYSTEM_NAME=Windows `
1583+
-D CMAKE_SYSTEM_PROCESSOR=${{ matrix.cpu }} `
1584+
-G Ninja `
1585+
-S ${{ github.workspace }}/SourceCache/swift-foundation/Sources/FoundationMacros `
1586+
-D SwiftSyntax_DIR=${{ github.workspace }}/BinaryCache/swift-syntax/cmake/modules
1587+
- name: Build Foundation Macros
1588+
run: cmake --build ${{ github.workspace }}/BinaryCache/swift-foundation-macros
1589+
1590+
- name: Install Foundation Macros
1591+
run: cmake --build ${{ github.workspace }}/BinaryCache/swift-foundation-macros --target install
1592+
1593+
- name: Upload macros
1594+
uses: actions/upload-artifact@v4
1595+
with:
1596+
name: macros-${{ matrix.arch }}
1597+
path: ${{ github.workspace }}/BuildRoot/Library
1598+
1599+
- name: Upload PDBs to Azure
1600+
uses: microsoft/[email protected]
1601+
if: ${{ needs.context.outputs.debug_info }}
1602+
with:
1603+
accountName: ${{ vars.SYMBOL_SERVER_ACCOUNT }}
1604+
personalAccessToken: ${{ secrets.SYMBOL_SERVER_PAT }}
1605+
symbolsFolder: ${{ github.workspace }}/BinaryCache/swift-foundation-macros
1606+
searchPattern: '**/*.pdb'
1607+
1608+
- name: Upload DLLs to Azure
1609+
uses: microsoft/[email protected]
1610+
if: ${{ needs.context.outputs.debug_info }}
1611+
with:
1612+
accountName: ${{ vars.SYMBOL_SERVER_ACCOUNT }}
1613+
personalAccessToken: ${{ secrets.SYMBOL_SERVER_PAT }}
1614+
symbolsFolder: ${{ github.workspace }}/BinaryCache/swift-foundation-macros
1615+
searchPattern: '**/*.dll'
1616+
1617+
- name: Upload EXEs to Azure
1618+
uses: microsoft/[email protected]
1619+
if: ${{ needs.context.outputs.debug_info }}
1620+
with:
1621+
accountName: ${{ vars.SYMBOL_SERVER_ACCOUNT }}
1622+
personalAccessToken: ${{ secrets.SYMBOL_SERVER_PAT }}
1623+
symbolsFolder: ${{ github.workspace }}/BinaryCache/swift-foundation-macros
1624+
searchPattern: '**/*.exe'
1625+
14901626
sdk:
14911627
continue-on-error: ${{ matrix.arch != 'amd64' }}
1492-
needs: [context, libxml2, curl, zlib, compilers, cmark_gfm, stdlib]
1628+
needs: [context, libxml2, curl, zlib, compilers, cmark_gfm, stdlib, macros]
14931629
runs-on: ${{ needs.context.outputs.windows_build_runner }}
14941630

14951631
strategy:
@@ -1602,36 +1738,37 @@ jobs:
16021738
with:
16031739
name: zlib-${{ matrix.os }}-${{ matrix.arch }}-1.3
16041740
path: ${{ github.workspace }}/BuildRoot/Library/zlib-1.3/usr
1741+
16051742
- name: Download Compilers
16061743
uses: actions/download-artifact@v4
16071744
with:
16081745
name: compilers-amd64
1609-
path: ${{ github.workspace }}/BuildRoot/Library
1746+
path: ${{ github.workspace }}/BinaryCache/Library
16101747
- uses: actions/download-artifact@v4
16111748
with:
1612-
name: cmark-gfm-amd64-0.29.0.gfm.13
1613-
path: ${{ github.workspace }}/BuildRoot/Library/cmark-gfm-0.29.0.gfm.13/usr
1614-
1615-
- name: cmark-gfm Setup
1616-
run: Copy-Item ${{ github.workspace }}/BuildRoot/Library/cmark-gfm-0.29.0.gfm.13/usr/bin/*.dll ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/
1617-
1749+
name: ${{ matrix.os }}-stdlib-${{ matrix.arch }}
1750+
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/${{ matrix.os }}.platform
16181751
- uses: actions/download-artifact@v4
16191752
with:
1620-
name: ${{ matrix.os }}-stdlib-${{ matrix.arch }}
1621-
path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.os }}.platform
1622-
1753+
name: Windows-stdlib-amd64
1754+
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
16231755
- uses: actions/download-artifact@v4
16241756
if: matrix.os == 'Windows'
16251757
with:
16261758
name: windows-vfs-overlay-${{ matrix.arch }}
1627-
path: ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml
1628-
1629-
- uses: actions/checkout@v4
1759+
path: ${{ github.workspace }}/BinaryCache/swift/stdlib
1760+
- uses: actions/download-artifact@v4
16301761
with:
1631-
repository: apple/swift-syntax
1632-
ref: ${{ needs.context.outputs.swift_syntax_revision }}
1633-
path: ${{ github.workspace }}/SourceCache/swift-syntax
1634-
show-progress: false
1762+
name: macros-amd64
1763+
path: ${{ github.workspace }}/BinaryCache/Library
1764+
- uses: actions/download-artifact@v4
1765+
with:
1766+
name: cmark-gfm-amd64-0.29.0.gfm.13
1767+
path: ${{ github.workspace }}/BinaryCache/Library/cmark-gfm-0.29.0.gfm.13/usr
1768+
1769+
- name: cmark-gfm Setup
1770+
run: Copy-Item ${{ github.workspace }}/BuildRoot/Library/cmark-gfm-0.29.0.gfm.13/usr/bin/*.dll ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/
1771+
16351772
- uses: actions/checkout@v4
16361773
with:
16371774
repository: apple/swift-corelibs-libdispatch
@@ -1676,17 +1813,14 @@ jobs:
16761813
ref: ${{ needs.context.outputs.swift_corelibs_xctest_revision }}
16771814
path: ${{ github.workspace }}/SourceCache/swift-corelibs-xctest
16781815
show-progress: false
1679-
- uses: actions/checkout@v4
1680-
with:
1681-
repository: apple/swift-experimental-string-processing
1682-
ref: ${{ needs.context.outputs.swift_experimental_string_processing_revision }}
1683-
path: ${{ github.workspace }}/SourceCache/swift-experimental-string-processing
1684-
show-progress: false
16851816

16861817
- run: |
16871818
$RTLPath = cygpath -w ${{ github.workspace }}/BinaryCache/Developer/SDKs/Windows.sdk/usr/bin
16881819
echo ${RTLPath} | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
16891820
1821+
$SDKRoot = cygpath -w ${{ github.workspace }}/BinaryCache/Developer/SDKs/Windows.sdk
1822+
echo "SDKROOT=${SDKRoot}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
1823+
16901824
# NOTE(compnerd): we execute unconditionally as we use CMake from VSDevEnv
16911825
- uses: compnerd/gha-setup-vsdevenv@main
16921826
with:
@@ -1717,7 +1851,6 @@ jobs:
17171851
17181852
$CMAKE_CPU = if ("${{ matrix.cpu }}" -eq "armv7") { "armv7-a" } else { "${{ matrix.cpu }}" }
17191853
1720-
Remove-Item env:\SDKROOT
17211854
cmake -B ${{ github.workspace }}/BinaryCache/libdispatch `
17221855
-D BUILD_SHARED_LIBS=YES `
17231856
-D CMAKE_BUILD_TYPE=Release `
@@ -1747,7 +1880,6 @@ jobs:
17471880
-D ENABLE_SWIFT=YES
17481881
- name: Build libdispatch
17491882
run: |
1750-
Remove-Item env:\SDKROOT
17511883
cmake --build ${{ github.workspace }}/BinaryCache/libdispatch
17521884
17531885
- name: Configure Foundation
@@ -1771,7 +1903,6 @@ jobs:
17711903
17721904
$build_tools = if ("${{ matrix.os }}" -eq "Windows") { "YES" } else { "NO" }
17731905
1774-
Remove-Item env:\SDKROOT
17751906
cmake -B ${{ github.workspace }}/BinaryCache/foundation `
17761907
-D BUILD_SHARED_LIBS=YES `
17771908
-D CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL="/MD" `
@@ -1803,6 +1934,7 @@ jobs:
18031934
-D dispatch_DIR=${{ github.workspace }}/BinaryCache/libdispatch/cmake/modules `
18041935
-D CURL_DIR=${{ github.workspace }}/BuildRoot/Library/curl-8.9.1/usr/lib/cmake/CURL `
18051936
-D FOUNDATION_BUILD_TOOLS=${build_tools} `
1937+
-D Foundation_MACRO=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin `
18061938
-D ENABLE_TESTING=NO `
18071939
-D _SwiftFoundation_SourceDIR=$SWIFT_FOUNDATION_SOURCE_DIR `
18081940
-D _SwiftFoundationICU_SourceDIR=$SWIFT_FOUNDATION_ICU_SOURCE_DIR `
@@ -1814,7 +1946,6 @@ jobs:
18141946
-D ZLIB_LIBRARY=${{ github.workspace }}/BuildRoot/Library/zlib-1.3/usr/lib/$zlib_lib
18151947
- name: Build foundation
18161948
run: |
1817-
Remove-Item env:\SDKROOT
18181949
cmake --build ${{ github.workspace }}/BinaryCache/foundation
18191950
18201951
# TODO(compnerd) correctly version XCTest
@@ -1830,7 +1961,6 @@ jobs:
18301961
18311962
$CMAKE_CPU = if ("${{ matrix.cpu }}" -eq "armv7") { "armv7-a" } else { "${{ matrix.cpu }}" }
18321963
1833-
Remove-Item env:\SDKROOT
18341964
cmake -B ${{ github.workspace }}/BinaryCache/xctest `
18351965
-D BUILD_SHARED_LIBS=YES `
18361966
-D CMAKE_BUILD_TYPE=Release `
@@ -1860,20 +1990,16 @@ jobs:
18601990
-D ENABLE_TESTING=NO
18611991
- name: Build xctest
18621992
run: |
1863-
Remove-Item env:\SDKROOT
18641993
cmake --build ${{ github.workspace }}/BinaryCache/xctest
18651994
18661995
- name: Install xctest
18671996
run: |
1868-
Remove-Item env:\SDKROOT
18691997
cmake --build ${{ github.workspace }}/BinaryCache/xctest --target install
18701998
- name: Install foundation
18711999
run: |
1872-
Remove-Item env:\SDKROOT
18732000
cmake --build ${{ github.workspace }}/BinaryCache/foundation --target install
18742001
- name: Install libdispatch
18752002
run: |
1876-
Remove-Item env:\SDKROOT
18772003
cmake --build ${{ github.workspace }}/BinaryCache/libdispatch --target install
18782004
18792005
- uses: actions/setup-python@v5
@@ -1952,7 +2078,7 @@ jobs:
19522078
with:
19532079
name: Windows-sdk-${{ matrix.arch }}
19542080
path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Windows.platform
1955-
- name: Downlaod swift-syntax
2081+
- name: Download swift-syntax
19562082
uses: actions/download-artifact@v4
19572083
with:
19582084
name: swift-syntax-${{ matrix.arch }}
@@ -2761,7 +2887,7 @@ jobs:
27612887

27622888
package_tools:
27632889
name: Package Tools
2764-
needs: [context, compilers, debugging_tools, devtools]
2890+
needs: [context, compilers, macros, debugging_tools, devtools]
27652891
runs-on: ${{ needs.context.outputs.windows_build_runner }}
27662892

27672893
strategy:
@@ -2788,6 +2914,12 @@ jobs:
27882914
name: devtools-${{ matrix.arch }}
27892915
path: ${{ github.workspace }}/BuildRoot/Library
27902916

2917+
- name: Download Macros
2918+
uses: actions/download-artifact@v4
2919+
with:
2920+
name: macros-${{ matrix.arch }}
2921+
path: ${{ github.workspace }}/BuildRoot/Library
2922+
27912923
- name: Download cmark-gfm
27922924
uses: actions/download-artifact@v4
27932925
with:

0 commit comments

Comments
 (0)