Skip to content

Commit c0724a5

Browse files
committed
GHA: add the ability to update the module map
Introduce a new option to update the Windows SDK modularization to the latest version in Swift.
1 parent 461d602 commit c0724a5

File tree

3 files changed

+88
-4
lines changed

3 files changed

+88
-4
lines changed

.github/workflows/test-install.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,26 @@ jobs:
6969
shell: pwsh
7070
run: |
7171
-not (Get-Command sourcekit-lsp.exe -ErrorAction SilentlyContinue)
72+
73+
windows-update-sdk-modules:
74+
name: Test SDK module updates on Windows
75+
runs-on: windows-latest
76+
77+
steps:
78+
- uses: actions/checkout@v3
79+
- uses: compnerd/gha-setup-vsdevenv@main
80+
81+
- name: Install Swift with SDK module updates
82+
uses: ./
83+
with:
84+
swift-version: swift-5.5-release
85+
swift-build: 5.5-RELEASE
86+
update-sdk-modules: true
87+
88+
- name: Verify Swift installation
89+
run: swift --version
90+
91+
- name: Smoke test
92+
run: |
93+
swift package init --type executable
94+
swift build

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ jobs:
5353
- `swift-version`: (**Note:** this is not a git branch name) the Swift "version" to be installed. This may be either a pre-release branch (e.g. `swift-5.5-branch`), a release branch (e.g. `swift-5.5-release`) or the development branch (`swift-development`).
5454
- `swift-build`: (**Note:** this is not a git tag name) the actual build tag to install, minus the "`swift-`" prefix. May indicate a release snapshot (e.g. `5.5-DEVELOPMENT-SNAPSHOT-2021-09-18-a`), development snapshot (e.g. `DEVELOPMENT-SNAPSHOT-2021-09-28-a`), or a release (e.g. `5.5-RELEASE`).
5555

56-
#### Deprecated Parameters (will be removed in a future version):
57-
- `branch`: **[DEPRECATED]** Use `swift-version` instead.
58-
- `tag`: **[DEPRECATED]** Use `swift-build` instead.
59-
6056
#### When using Swift builds from a Github repository release:
6157
- `github-repo`: Github repo in "owner/repo" format
6258
- `release-tag-name`: Release tag name, can be found in `github.com/<owner>/<repo>/releases`
6359
- `release-asset-name`: Asset name for the Swift installer executable in the release
6460
- `github-token`: Optional Github token for fetching a release from a private repository
61+
62+
#### Additional Options:
63+
- `update-sdk-modules`: Update SDK module definitions to latest version after installation (Windows only, default: false)
64+
- `installer-args`: Additional arguments to pass to the installer, space-delimited
65+
66+
#### Deprecated Parameters (will be removed in a future version):
67+
- `branch`: **[DEPRECATED]** Use `swift-version` instead.
68+
- `tag`: **[DEPRECATED]** Use `swift-build` instead.

action.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ inputs:
5050
description: 'Additional arguments to pass to the installer, space-delimited (double quotes are not supported)'
5151
required: false
5252
default: ''
53+
update-sdk-modules:
54+
description: 'Update SDK module definitions to latest version after installation (Windows only)'
55+
required: false
56+
default: 'false'
57+
type: boolean
5358

5459
runs:
5560
using: 'composite'
@@ -216,6 +221,58 @@ runs:
216221
Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap"
217222
shell: pwsh
218223

224+
- name: Update SDK Module Definitions
225+
if: runner.os == 'Windows' && inputs.update-sdk-modules == 'true'
226+
run: |
227+
Write-Host "::notice::Updating SDK module definitions to latest version..."
228+
229+
$SwiftRoot = Split-Path -Path (Split-Path -Path (Get-Command swift).Source -Parent) -Parent
230+
$SwiftClangIncludeFolder = Join-Path $SwiftRoot "lib" "swift" "clang" "include"
231+
232+
curl -s `
233+
-o (Join-Path $SwiftClangIncludeFolder "module.modulemap") `
234+
https://raw.githubusercontent.com/llvm/llvm-project/main/clang/lib/Headers/module.modulemap
235+
if ($LASTEXITCODE -ne 0) {
236+
Write-Host "::error::Failed to update Clang module map"
237+
exit 1
238+
}
239+
240+
curl -s `
241+
-o (Join-Path "${env:SDKROOT}" "usr" "share" "winsdk.modulemap") `
242+
https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/winsdk.modulemap
243+
if ($LASTEXITCODE -ne 0) {
244+
Write-Host "::error::Failed to update WinSDK module map"
245+
exit 1
246+
}
247+
248+
curl -s `
249+
-o (Join-Path "${env:SDKROOT}" "usr" "share" "ucrt.modulemap") `
250+
https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/ucrt.modulemap
251+
if ($LASTEXITCODE -ne 0) {
252+
Write-Host "::error::Failed to update UCRT module map"
253+
exit 1
254+
}
255+
256+
curl -s `
257+
-o (Join-Path "${env:SDKROOT}" "usr" "share" "vcruntime.modulemap") `
258+
https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/vcruntime.modulemap
259+
if ($LASTEXITCODE -ne 0) {
260+
Write-Host "::error::Failed to update VCRuntime module map"
261+
exit 1
262+
}
263+
264+
curl -s `
265+
-H "Authorization: Bearer ${{ github.token }}" `
266+
-o (Join-Path "${env:SDKROOT}" "usr" "share" "vcruntime.apinotes") `
267+
https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/vcruntime.apinotes
268+
if ($LASTEXITCODE -ne 0) {
269+
Write-Host "::error::Failed to update VCRuntime API notes"
270+
exit 1
271+
}
272+
273+
Write-Host "::notice::SDK module definitions updated successfully"
274+
shell: pwsh
275+
219276
- name: Install Swift
220277
if: runner.os == 'Linux'
221278
run: |

0 commit comments

Comments
 (0)