|
85 | 85 | - name: Setup MSBuild |
86 | 86 | uses: microsoft/setup-msbuild@v2 |
87 | 87 |
|
88 | | - # The native C++ projects include ATL headers (<atlstr.h>, <atlcoll.h> in |
89 | | - # FlyNativeLib). The windows-latest runner image no longer ships the C++ ATL |
90 | | - # component by default, so install it into the runner's VS before building. |
91 | | - - name: Install C++ ATL |
92 | | - if: ${{ inputs.native == 'Build fresh' }} |
93 | | - shell: pwsh |
94 | | - run: | |
95 | | - $vsInstaller = "C:\Program Files (x86)\Microsoft Visual Studio\Installer" |
96 | | - $vsPath = & "$vsInstaller\vswhere.exe" -latest -property installationPath |
97 | | - if (-not $vsPath) { Write-Error "Could not locate Visual Studio via vswhere."; exit 1 } |
98 | | -
|
99 | | - # Base ATL provides the headers (atlstr.h etc.) FlyNativeLib needs. The |
100 | | - # ARM64 variant (ATL link libs for ARM64 targets) is added ONLY on the |
101 | | - # ARM64 runner -- requesting it on the x64 runner can make the whole |
102 | | - # modify fail, leaving even base ATL uninstalled. |
103 | | - $components = @("Microsoft.VisualStudio.Component.VC.ATL") |
104 | | - if ("${{ matrix.platform }}" -eq "ARM64") { |
105 | | - $components += "Microsoft.VisualStudio.Component.VC.ATL.ARM64" |
106 | | - } |
107 | | -
|
108 | | - # Build a single argument string so the install path (which contains |
109 | | - # spaces, e.g. "C:\Program Files\Microsoft Visual Studio\18\Enterprise") |
110 | | - # is passed quoted. Start-Process with an -ArgumentList ARRAY does not |
111 | | - # quote elements that contain spaces, which truncated --installPath to |
112 | | - # "C:\Program" and made the modify fail with "product cannot be found". |
113 | | - $addArgs = ($components | ForEach-Object { "--add $_" }) -join " " |
114 | | - $argString = "modify --installPath `"$vsPath`" --quiet --norestart --force --nocache $addArgs" |
115 | | -
|
116 | | - Write-Host "Installing ATL components: $($components -join ', ')" |
117 | | - $proc = Start-Process -FilePath "$vsInstaller\setup.exe" -ArgumentList $argString -Wait -PassThru -NoNewWindow |
118 | | - Write-Host "VS Installer exit code: $($proc.ExitCode)" |
119 | | - if ($proc.ExitCode -ne 0 -and $proc.ExitCode -ne 3010) { |
120 | | - Write-Error "VS Installer modify failed with exit code $($proc.ExitCode)." |
121 | | - exit $proc.ExitCode |
122 | | - } |
123 | | -
|
124 | | - # Verify the header is actually present -- fail here with a clear message |
125 | | - # rather than letting the later C++ compile fail on a missing include. |
126 | | - # The VS Installer can land files slightly after setup.exe returns, so |
127 | | - # poll for up to ~60s before giving up. |
128 | | - $vcRoot = Join-Path $vsPath "VC\Tools\MSVC" |
129 | | - $atl = $null |
130 | | - foreach ($i in 1..12) { |
131 | | - $atl = Get-ChildItem -Path $vcRoot -Recurse -Filter "atlstr.h" -ErrorAction SilentlyContinue | Select-Object -First 1 |
132 | | - if ($atl) { break } |
133 | | - Start-Sleep -Seconds 5 |
134 | | - } |
135 | | - if (-not $atl) { Write-Error "atlstr.h still not found under $vcRoot after install."; exit 1 } |
136 | | - Write-Host "Found ATL header: $($atl.FullName)" |
137 | | -
|
138 | 88 | # Install the stable Rust toolchain and pre-add the cross-compilation |
139 | 89 | # target for this platform. On windows-latest the host IS x86_64 so |
140 | 90 | # the target is native; on windows-11-arm the host IS aarch64 so same. |
|
0 commit comments