Skip to content

Commit 41c8474

Browse files
committed
GHA: switch to CMake to build swift-inspect
This switches to CMake to build swift-inspect, allowing it to cross-compile, and then package.
1 parent 3b0b63a commit 41c8474

File tree

1 file changed

+58
-74
lines changed

1 file changed

+58
-74
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 58 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,7 @@ jobs:
28902890
-D CMAKE_CXX_COMPILER=${CLANG_CL} `
28912891
-D CMAKE_CXX_COMPILER_TARGET=${{ matrix.triple }} `
28922892
-D CMAKE_CXX_FLAGS="${{ inputs.WINDOWS_CMAKE_CXX_FLAGS }}" `
2893+
-D CMAKE_MT=mt `
28932894
-D CMAKE_Swift_COMPILER=${SWIFTC} `
28942895
-D CMAKE_Swift_COMPILER_TARGET=${{ matrix.triple }} `
28952896
-D CMAKE_Swift_COMPILER_WORKS=YES `
@@ -2917,6 +2918,7 @@ jobs:
29172918
-D CMAKE_C_COMPILER=${CLANG_CL} `
29182919
-D CMAKE_C_COMPILER_TARGET=${{ matrix.triple }} `
29192920
-D CMAKE_C_FLAGS="${{ inputs.WINDOWS_CMAKE_C_FLAGS }}" `
2921+
-D CMAKE_MT=mt `
29202922
-D CMAKE_Swift_COMPILER=${SWIFTC} `
29212923
-D CMAKE_Swift_COMPILER_TARGET=${{ matrix.triple }} `
29222924
-D CMAKE_Swift_COMPILER_WORKS=YES `
@@ -3026,6 +3028,11 @@ jobs:
30263028
name: devtools-${{ matrix.arch }}
30273029
path: ${{ github.workspace }}/BuildRoot/Library
30283030

3031+
- uses: actions/upload-artifact@v4
3032+
with:
3033+
name: swift-argument-parser-Windows-${{ matrix.arch }}
3034+
path: ${{ github.workspace }}/BinaryCache/swift-argument-parser
3035+
30293036
- name: Upload PDBs to Azure
30303037
uses: microsoft/[email protected]
30313038
if: ${{ inputs.debug_info }}
@@ -3066,45 +3073,55 @@ jobs:
30663073
- arch: amd64
30673074
cpu: x86_64
30683075
triple: x86_64-unknown-windows-msvc
3076+
30693077
- arch: arm64
30703078
cpu: aarch64
30713079
triple: aarch64-unknown-windows-msvc
30723080

30733081
name: Windows ${{ matrix.arch }} Debugging Tools
30743082

30753083
steps:
3076-
- name: Download Compilers
3084+
- name: Download swift-argument-parser
30773085
uses: actions/download-artifact@v4
30783086
with:
3079-
name: compilers-amd64
3080-
path: ${{ github.workspace }}/BuildRoot/Library
3081-
- name: Download Devtools
3087+
name: swift-argument-parser-Windows-${{ matrix.arch }}
3088+
path: ${{ github.workspace }}/BinaryCache/swift-argument-parser
3089+
3090+
- name: Download Compilers
30823091
uses: actions/download-artifact@v4
30833092
with:
3084-
name: devtools-amd64
3085-
path: ${{ github.workspace }}/BuildRoot/Library
3093+
name: compilers-amd64
3094+
path: ${{ github.workspace }}/BinaryCache/Library
30863095
- name: Download stdlib
30873096
uses: actions/download-artifact@v4
30883097
with:
30893098
name: Windows-stdlib-${{ matrix.arch }}
3090-
path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Windows.platform
3099+
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
30913100
- name: Download SDK
30923101
uses: actions/download-artifact@v4
30933102
with:
30943103
name: Windows-sdk-${{ matrix.arch }}
3095-
path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Windows.platform
3104+
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
30963105

3097-
- name: Update environment variables
3098-
run: |
3099-
$SDKRoot = cygpath -w "${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk"
3100-
echo "SDKROOT=${SDKRoot}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
3106+
- uses: actions/checkout@v4
3107+
with:
3108+
repository: swiftlang/swift
3109+
ref: ${{ inputs.swift_revision }}
3110+
path: ${{ github.workspace }}/SourceCache/swift
3111+
show-progress: false
3112+
3113+
- run: |
3114+
$RTLPath = cygpath -w "${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/bin"
3115+
echo ${RTLPath} | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
31013116
3102-
$ToolchainPath = cygpath -w "${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin"
3103-
echo "${ToolchainPath}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
3104-
echo "AR=${ToolchainPath}\llvm-ar.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
3117+
$SDKRoot = cygpath -w "${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk"
3118+
echo "SDKROOT=${SDKRoot}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
31053119
3106-
$RTLPath = cygpath -w "${{ github.workspace }}/BinaryCache/Developer/SDKs/Windows.sdk/usr/bin"
3107-
echo "${RTLPath}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
3120+
- uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main
3121+
with:
3122+
host_arch: amd64
3123+
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
3124+
arch: ${{ matrix.arch }}
31083125

31093126
- run: |
31103127
Move-Item ${env:SDKROOT}/usr/lib/swift/dispatch ${env:SDKROOT}/usr/include/
@@ -3127,71 +3144,40 @@ jobs:
31273144
- uses: actions/download-artifact@v4
31283145
with:
31293146
name: Windows-stdlib-amd64
3130-
path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Windows.platform
3147+
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
31313148
- uses: actions/download-artifact@v4
31323149
with:
31333150
name: Windows-sdk-amd64
3134-
path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Windows.platform
3135-
3136-
- name: Move host libs to the host architecture directory
3137-
if: matrix.arch == 'arm64'
3138-
run: |
3139-
Move-Item ${env:SDKROOT}/usr/lib/swift/windows/BlocksRuntime.lib ${env:SDKROOT}/usr/lib/swift/windows/x86_64/
3140-
Move-Item ${env:SDKROOT}/usr/lib/swift/windows/dispatch.lib ${env:SDKROOT}/usr/lib/swift/windows/x86_64/
3141-
Move-Item ${env:SDKROOT}/usr/lib/swift/windows/swiftDispatch.lib ${env:SDKROOT}/usr/lib/swift/windows/x86_64/
3142-
Move-Item ${env:SDKROOT}/usr/lib/swift/windows/Foundation.lib ${env:SDKROOT}/usr/lib/swift/windows/x86_64/
3143-
Move-Item ${env:SDKROOT}/usr/lib/swift/windows/FoundationXML.lib ${env:SDKROOT}/usr/lib/swift/windows/x86_64/
3144-
Move-Item ${env:SDKROOT}/usr/lib/swift/windows/FoundationNetworking.lib ${env:SDKROOT}/usr/lib/swift/windows/x86_64/
3145-
Move-Item ${env:SDKROOT}/usr/lib/swift/windows/_FoundationICU.lib ${env:SDKROOT}/usr/lib/swift/windows/x86_64/
3146-
Move-Item ${env:SDKROOT}/usr/lib/swift/windows/FoundationEssentials.lib ${env:SDKROOT}/usr/lib/swift/windows/x86_64/
3147-
Move-Item ${env:SDKROOT}/usr/lib/swift/windows/FoundationInternationalization.lib ${env:SDKROOT}/usr/lib/swift/windows/x86_64/
3151+
path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform
31483152

3149-
- name: Move host runtime DLLs to the runtime binary directory.
3153+
- name: Configure swift-inspect
31503154
run: |
3151-
Remove-Item -Path ${env:SDKROOT}/usr/lib/swift/dispatch -Recurse -Force
3152-
Remove-Item -Path ${env:SDKROOT}/usr/lib/swift/os -Recurse -Force
3153-
Remove-Item -Path ${env:SDKROOT}/usr/lib/swift/Block -Recurse -Force
3154-
Remove-Item -Path ${env:SDKROOT}/usr/lib/swift/_foundation_unicode -Recurse -Force
3155-
Remove-Item -Path ${env:SDKROOT}/usr/lib/swift/_FoundationCShims -Recurse -Force
3156-
3157-
$RTLPath = cygpath -w "${{ github.workspace }}/BinaryCache/Developer/SDKs/Windows.sdk/usr/bin"
3158-
mkdir $RTLPath
3159-
Get-ChildItem -Path ${env:SDKROOT}/usr/bin -Filter "*.dll" | Move-Item -Destination $RTLPath
3160-
3161-
- uses: actions/checkout@v4
3162-
with:
3163-
repository: swiftlang/swift
3164-
ref: ${{ inputs.swift_revision }}
3165-
path: ${{ github.workspace }}/SourceCache/swift
3166-
show-progress: false
3155+
$SWIFTC = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc.exe
31673156
3157+
cmake -B ${{ github.workspace }}/BinaryCache/${{ matrix.arch }}/swift-inspect `
3158+
-D CMAKE_BUILD_TYPE=Release `
3159+
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
3160+
-D CMAKE_MT=mt `
3161+
-D CMAKE_Swift_COMPILER=${SWIFTC} `
3162+
-D CMAKE_Swift_COMPILER_TARGET=${{ matrix.triple }} `
3163+
-D CMAKE_Swift_COMPILER_WORKS=YES `
3164+
-D CMAKE_Swift_FLAGS="-sdk ${env:SDKROOT} ${{ inputs.CMAKE_Swift_FLAGS }} -Xcc `"-I${env:SDKROOT}/usr/include/swift/SwiftRemoteMirror`"" `
3165+
-D CMAKE_Swift_FLAGS_RELEASE="-O" `
3166+
-D CMAKE_SYSTEM_NAME=Windows `
3167+
-D CMAKE_SYSTEM_PROCESSOR=${{ matrix.cpu }} `
3168+
-G Ninja `
3169+
-S ${{ github.workspace }}/SourceCache/swift/tools/swift-inspect `
3170+
-D ArgumentParser_DIR=${{ github.workspace }}/BinaryCache/swift-argument-parser/cmake/modules
31683171
- name: Build swift-inspect
3169-
id: swift_inspect
3170-
shell: cmd
3171-
run: |
3172-
swift build ^
3173-
--triple=${{ matrix.triple }} ^
3174-
--scratch-path="${{ github.workspace }}/BinaryCache/${{ matrix.arch }}/swift-inspect" ^
3175-
--sdk="%SDKROOT%" ^
3176-
--package-path="${{ github.workspace }}/SourceCache/swift/tools/swift-inspect" ^
3177-
-c="release" ^
3178-
-Xbuild-tools-swiftc="-L%SDKROOT%/usr/lib/swift/windows" ^
3179-
-Xbuild-tools-swiftc="-I%SDKROOT%/usr/lib/swift" ^
3180-
-Xbuild-tools-swiftc="-use-ld=lld" ^
3181-
-Xcc="-I%SDKROOT%/usr/include/swift/SwiftRemoteMirror" ^
3182-
-Xswiftc="-use-ld=lld" ^
3183-
-Xlinker="%SDKROOT%/usr/lib/swift/windows/${{ matrix.cpu }}/swiftRemoteMirror.lib"
3184-
3185-
- name: Copy swift-inspect executable
3186-
run: |
3187-
New-Item -Path ${{ github.workspace }}/BuildRoot-DebuggingTools/swift-inspect -ItemType Directory -Force | Out-Null
3188-
$SwiftInspectPath="${{ github.workspace }}/BinaryCache/${{ matrix.arch }}/swift-inspect/${{ matrix.triple }}/release/swift-inspect.exe"
3189-
Copy-Item ${SwiftInspectPath} -Destination "${{ github.workspace }}/BuildRoot-DebuggingTools/swift-inspect/"
3172+
run: cmake --build ${{ github.workspace }}/BinaryCache/${{ matrix.arch }}/swift-inspect
3173+
3174+
- name: Install swift-inspect
3175+
run: cmake --build ${{ github.workspace }}/BinaryCache/${{ matrix.arch }}/swift-inspect --target install
31903176

31913177
- uses: actions/upload-artifact@v4
31923178
with:
31933179
name: debugging_tools-${{ matrix.arch }}
3194-
path: ${{ github.workspace }}/BuildRoot-DebuggingTools
3180+
path: ${{ github.workspace }}/BuildRoot/Library
31953181

31963182
package_tools:
31973183
# TODO: Build this on macOS or make an equivalent Mac-only job
@@ -3210,7 +3196,7 @@ jobs:
32103196
uses: actions/download-artifact@v4
32113197
with:
32123198
name: debugging_tools-${{ matrix.arch }}
3213-
path: ${{ github.workspace }}/BuildRoot/DebuggingTools
3199+
path: ${{ github.workspace }}/BuildRoot/Library
32143200

32153201
- name: Download Compilers
32163202
uses: actions/download-artifact@v4
@@ -3328,8 +3314,6 @@ jobs:
33283314
-p:CERTIFICATE=${env:CERTIFICATE} `
33293315
-p:PASSPHRASE=${{ secrets.PASSPHRASE }} `
33303316
-p:TOOLCHAIN_ROOT=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain `
3331-
-p:INCLUDE_SWIFT_INSPECT=true `
3332-
-p:SWIFT_INSPECT_BUILD=${{ github.workspace }}/BuildRoot/DebuggingTools/swift-inspect `
33333317
-p:ProductArchitecture=${{ matrix.arch }} `
33343318
-p:ProductVersion=${{ inputs.swift_version }} `
33353319
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/dbg/dbg.wixproj

0 commit comments

Comments
 (0)