Skip to content

Commit 7e2b9e4

Browse files
authored
Create vfs-overlay.yaml on demand (#931)
`vfs-overlay.yaml` created as part of the `stdlib` step refers to paths from the `swift` source directory, which may not be available in subsequent jobs, causing build issues. These changes generate a `vfs-overlay.yaml` file on demand for jobs that need it, to work around the issue.
1 parent 3a505da commit 7e2b9e4

File tree

1 file changed

+91
-16
lines changed

1 file changed

+91
-16
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 91 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,12 +1889,6 @@ jobs:
18891889
name: ${{ matrix.os }}-${{ matrix.arch }}-stdlib
18901890
path: ${{ github.workspace }}/BuildRoot/Library
18911891

1892-
- uses: actions/upload-artifact@v4
1893-
if: matrix.os == 'Windows'
1894-
with:
1895-
name: ${{ matrix.os }}-${{ matrix.arch }}-vfs-overlay
1896-
path: ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml
1897-
18981892
- name: Upload PDBs to Azure
18991893
uses: microsoft/[email protected]
19001894
if: ${{ inputs.debug_info && matrix.os == 'Windows' }}
@@ -1945,10 +1939,6 @@ jobs:
19451939
with:
19461940
name: Windows-${{ inputs.build_arch }}-stdlib
19471941
path: ${{ github.workspace }}/BinaryCache/Library
1948-
- uses: actions/download-artifact@v4
1949-
with:
1950-
name: Windows-${{ matrix.arch }}-vfs-overlay
1951-
path: ${{ github.workspace }}/BinaryCache/swift/stdlib
19521942
- uses: actions/[email protected]
19531943
with:
19541944
repository: swiftlang/swift
@@ -1980,12 +1970,56 @@ jobs:
19801970
$RTLPath = cygpath -w ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/bin
19811971
echo ${RTLPath} | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
19821972
1983-
- name: extract swift-syntax
1973+
- name: Extract swift-syntax
19841974
run: |
19851975
$module = "${{ github.workspace }}/BinaryCache/swift-syntax/cmake/modules/SwiftSyntaxConfig.cmake"
19861976
$bindir = cygpath -m ${{ github.workspace }}/BinaryCache/swift-syntax
19871977
(Get-Content $module).Replace('<BINARY_DIR>', "${bindir}") | Set-Content $module
19881978
1979+
- name: Create vfs-overlay
1980+
run: |
1981+
$VfsOverlay = "${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml"
1982+
$ModuleMapDir = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/share
1983+
$Win10SdkRoot = Get-ItemPropertyValue `
1984+
-Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots" `
1985+
-Name "KitsRoot10"
1986+
$Win10SdkRoot = cygpath -m ${Win10SdkRoot}
1987+
$InstallerLocation = Join-Path "${env:ProgramFiles(x86)}" "Microsoft Visual Studio" "Installer"
1988+
$VsWhere = Join-Path "${InstallerLocation}" "vswhere.exe"
1989+
$VsInstallPath = (& "$VsWhere" -latest -products * -format json | ConvertFrom-Json).installationPath
1990+
$VsInstallPath = cygpath -m ${VsInstallPath}
1991+
1992+
$ModuleMap = @"
1993+
version: 0
1994+
use-external-names: false
1995+
case-sensitive: false
1996+
roots:
1997+
- name: "${Win10SdkRoot}/Include/${env:WORKAROUND_WINDOWS_SDK_VERSION}/um"
1998+
type: directory
1999+
contents:
2000+
- name: module.modulemap
2001+
type: file
2002+
external-contents: "${ModuleMapDir}/winsdk.modulemap"
2003+
- name: "${Win10SdkRoot}/Include/${env:WORKAROUND_WINDOWS_SDK_VERSION}/ucrt"
2004+
type: directory
2005+
contents:
2006+
- name: module.modulemap
2007+
type: file
2008+
external-contents: "${ModuleMapDir}/ucrt.modulemap"
2009+
- name: "${VsInstallPath}/VC/Tools/MSVC/${env:WORKAROUND_WINDOWS_COMPILER_VERSION}/include"
2010+
type: directory
2011+
contents:
2012+
- name: module.modulemap
2013+
type: file
2014+
external-contents: "${ModuleMapDir}/vcruntime.modulemap"
2015+
- name: vcruntime.apinotes
2016+
type: file
2017+
external-contents: "${ModuleMapDir}/vcruntime.apinotes"
2018+
"@
2019+
$VfsOverlayDir = Split-Path -Parent $VfsOverlay
2020+
New-Item -ItemType Directory -Path $VfsOverlayDir
2021+
Write-Output $ModuleMap | Out-File -FilePath $VfsOverlay -Encoding utf8
2022+
19892023
- name: Configure Foundation Macros
19902024
run: |
19912025
$WINDOWS_VFS_OVERLAY = cygpath -m ${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml
@@ -2190,11 +2224,6 @@ jobs:
21902224
with:
21912225
name: Windows-${{ inputs.build_arch }}-stdlib
21922226
path: ${{ github.workspace }}/BinaryCache/Library
2193-
- uses: actions/download-artifact@v4
2194-
if: matrix.os == 'Windows'
2195-
with:
2196-
name: Windows-${{ matrix.arch }}-vfs-overlay
2197-
path: ${{ github.workspace }}/BinaryCache/swift/stdlib
21982227
- uses: actions/download-artifact@v4
21992228
if: matrix.os != 'Android' || inputs.build_android
22002229
with:
@@ -2309,6 +2338,52 @@ jobs:
23092338
with:
23102339
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
23112340

2341+
- name: Create vfs-overlay
2342+
if: matrix.os == 'Windows'
2343+
run: |
2344+
$VfsOverlay = "${{ github.workspace }}/BinaryCache/swift/stdlib/windows-vfs-overlay.yaml"
2345+
$ModuleMapDir = cygpath -m ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/share
2346+
$Win10SdkRoot = Get-ItemPropertyValue `
2347+
-Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots" `
2348+
-Name "KitsRoot10"
2349+
$Win10SdkRoot = cygpath -m ${Win10SdkRoot}
2350+
$InstallerLocation = Join-Path "${env:ProgramFiles(x86)}" "Microsoft Visual Studio" "Installer"
2351+
$VsWhere = Join-Path "${InstallerLocation}" "vswhere.exe"
2352+
$VsInstallPath = (& "$VsWhere" -latest -products * -format json | ConvertFrom-Json).installationPath
2353+
$VsInstallPath = cygpath -m ${VsInstallPath}
2354+
2355+
$ModuleMap = @"
2356+
version: 0
2357+
use-external-names: false
2358+
case-sensitive: false
2359+
roots:
2360+
- name: "${Win10SdkRoot}/Include/${env:WORKAROUND_WINDOWS_SDK_VERSION}/um"
2361+
type: directory
2362+
contents:
2363+
- name: module.modulemap
2364+
type: file
2365+
external-contents: "${ModuleMapDir}/winsdk.modulemap"
2366+
- name: "${Win10SdkRoot}/Include/${env:WORKAROUND_WINDOWS_SDK_VERSION}/ucrt"
2367+
type: directory
2368+
contents:
2369+
- name: module.modulemap
2370+
type: file
2371+
external-contents: "${ModuleMapDir}/ucrt.modulemap"
2372+
- name: "${VsInstallPath}/VC/Tools/MSVC/${env:WORKAROUND_WINDOWS_COMPILER_VERSION}/include"
2373+
type: directory
2374+
contents:
2375+
- name: module.modulemap
2376+
type: file
2377+
external-contents: "${ModuleMapDir}/vcruntime.modulemap"
2378+
- name: vcruntime.apinotes
2379+
type: file
2380+
external-contents: "${ModuleMapDir}/vcruntime.apinotes"
2381+
"@
2382+
2383+
$VfsOverlayDir = Split-Path -Parent $VfsOverlay
2384+
New-Item -ItemType Directory -Path $VfsOverlayDir
2385+
Write-Output $ModuleMap | Out-File -FilePath $VfsOverlay -Encoding utf8
2386+
23122387
- name: Configure libdispatch
23132388
if: matrix.os != 'Android' || inputs.build_android
23142389
run: |

0 commit comments

Comments
 (0)