Skip to content

Commit 53f8996

Browse files
author
Nie Zhihe
committed
chore: refine codes
1 parent 9a3c65b commit 53f8996

1 file changed

Lines changed: 75 additions & 36 deletions

File tree

.github/workflows/build_node_shared.yml

Lines changed: 75 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ jobs:
9696
shell: powershell
9797
run: |
9898
Write-Host "========== Applying V8 MSVC Compatibility Patch =========="
99-
Write-Host "Issue: MSVC C2352 error - 'a call of a non-static member function requires an object'"
99+
Write-Host "Issue: MSVC C2352 error - non-static member function requires an object"
100100
Write-Host "Affected file: deps\v8\src\heap\cppgc\marking-state.h"
101101
Write-Host "Reference: https://forum.qt.io/topic/162305"
102102
Write-Host ""
103103
104104
$file = "deps\v8\src\heap\cppgc\marking-state.h"
105105
106106
if (!(Test-Path $file)) {
107-
Write-Host "ERROR: $file not found!"
107+
Write-Host "ERROR: $file not found!"
108108
exit 1
109109
}
110110
@@ -121,15 +121,15 @@ jobs:
121121
# -> BasicMarkingState::MarkNoPush(header)
122122
if ($line -match 'MutatorMarkingState::BasicMarkingState::MarkNoPush\(') {
123123
$line = $line -replace 'MutatorMarkingState::BasicMarkingState::MarkNoPush\(', 'BasicMarkingState::MarkNoPush('
124-
Write-Host " Line ${lineNumber}: Fixed qualified scope call"
124+
Write-Host " Line $lineNumber : Fixed qualified scope call"
125125
$modified = $true
126126
}
127127
128128
# Fix: return MarkingStateBase::MarkNoPush(
129129
# -> return this->MarkNoPush(
130130
if ($line -match '\s+return\s+MarkingStateBase::MarkNoPush\(') {
131131
$line = $line -replace 'return\s+MarkingStateBase::MarkNoPush\(', 'return this->MarkNoPush('
132-
Write-Host " Line ${lineNumber}: Fixed base class call"
132+
Write-Host " Line $lineNumber : Fixed base class call"
133133
$modified = $true
134134
}
135135
@@ -139,10 +139,10 @@ jobs:
139139
if ($modified) {
140140
Set-Content $file -Value $newLines
141141
Write-Host ""
142-
Write-Host "Successfully patched $file"
142+
Write-Host "Successfully patched $file"
143143
} else {
144144
Write-Host ""
145-
Write-Host "No matching patterns found (file may already be patched or have different code)"
145+
Write-Host "No matching patterns found (file may already be patched or have different code)"
146146
Write-Host "Build will continue, but may still fail with C2352 error"
147147
}
148148
@@ -164,7 +164,7 @@ jobs:
164164
python-version: '3.11'
165165

166166
# Reference: https://github.com/nodejs/node/blob/v22.12.0/BUILDING.md#option-2-automated-install-with-winget
167-
# https://raw.githubusercontent.com/nodejs/node/main/.configurations/configuration.dsc.yaml
167+
# https://github.com/nodejs/node/blob/v22.12.0/.configurations/configuration.vsEnterprise.dsc.yaml
168168
# Using direct winget install commands instead of DSC configuration due to compatibility issues in CI environment
169169
- name: Setup Node.js prerequisites with WinGet (Windows)
170170
if: matrix.platform == 'win'
@@ -195,39 +195,45 @@ jobs:
195195
196196
# Find existing VS installation (GitHub Actions has VS 2022 Enterprise pre-installed)
197197
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
198-
$vsPath = & $vsWhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
199-
198+
$vsPath = & $vsWhere -latest -products Microsoft.VisualStudio.Product.Enterprise -property installationPath
199+
200200
Write-Host "Visual Studio installation found at: $vsPath"
201201
202-
# Get VS product ID (Enterprise, Professional, or Community)
203-
$productId = & $vsWhere -latest -products * -property productId
202+
# Get VS product ID
203+
$productId = & $vsWhere -path "$vsPath" -property productId
204204
Write-Host "Product ID: $productId"
205205
206-
# Use VS Installer to modify existing installation and add required components
206+
# Use VS Installer to add required components
207+
# Note: Using --passive instead of --quiet to see progress, and allow warnings
207208
$installerPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vs_installer.exe"
208209
209-
Write-Host "Adding C++ workload and Clang components..."
210-
$processArgs = @(
211-
"modify",
212-
"--installPath", "`"$vsPath`"",
213-
"--add", "Microsoft.VisualStudio.Workload.NativeDesktop",
214-
"--add", "Microsoft.VisualStudio.Component.VC.Llvm.Clang",
215-
"--add", "Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset",
216-
"--includeRecommended",
217-
"--quiet",
218-
"--norestart"
219-
)
210+
Write-Host "`nAdding required components (this may take 10-20 minutes)..."
211+
& $installerPath modify `
212+
--installPath "$vsPath" `
213+
--add Microsoft.VisualStudio.Workload.NativeDesktop `
214+
--add Microsoft.VisualStudio.Component.VC.Llvm.Clang `
215+
--add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset `
216+
--includeRecommended `
217+
--quiet `
218+
--norestart `
219+
--wait
220220
221-
$process = Start-Process -FilePath $installerPath -ArgumentList $processArgs -Wait -PassThru -NoNewWindow
221+
$exitCode = $LASTEXITCODE
222222
223-
if ($process.ExitCode -eq 0) {
224-
Write-Host "Visual Studio components installed successfully!"
225-
} elseif ($process.ExitCode -eq 3010) {
226-
Write-Host "Visual Studio components installed successfully! (Reboot required but skipped)"
223+
if ($exitCode -eq 0) {
224+
Write-Host "`n✓ Visual Studio components installed successfully!"
225+
} elseif ($exitCode -eq 3010) {
226+
Write-Host "`n✓ Visual Studio components installed successfully! (Reboot requested but skipped)"
227+
} elseif ($exitCode -eq 1641) {
228+
Write-Host "`n✓ Visual Studio components installed successfully! (Restart initiated)"
227229
} else {
228-
Write-Host "Warning: VS Installer returned exit code $($process.ExitCode)"
229-
Write-Host "This may indicate the components are already installed or partially installed."
230-
Write-Host "Continuing with build process..."
230+
Write-Host "`n⚠ VS Installer returned exit code: $exitCode"
231+
if ($exitCode -eq 87) {
232+
Write-Host "Exit code 87 usually means components are already installed or parameters are incorrect."
233+
Write-Host "Continuing with build process..."
234+
} else {
235+
Write-Host "Warning: Unexpected exit code. Continuing anyway..."
236+
}
231237
}
232238
233239
- name: Verify installations (Windows)
@@ -249,12 +255,45 @@ jobs:
249255
Write-Host "`nNASM:"
250256
nasm -v
251257
252-
Write-Host "`nVisual Studio:"
253-
vswhere -latest -property displayName
254-
vswhere -latest -property installationVersion
258+
Write-Host "`n--- Visual Studio Information ---"
259+
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
260+
261+
Write-Host "`nVisual Studio 2022 Enterprise:"
262+
$vsPath = & $vsWhere -latest -products Microsoft.VisualStudio.Product.Enterprise -property installationPath
263+
264+
if ([string]::IsNullOrEmpty($vsPath)) {
265+
Write-Host "WARNING: VS 2022 Enterprise not found! Looking for any VS installation..."
266+
$vsPath = & $vsWhere -latest -products * -property installationPath
267+
}
268+
269+
Write-Host "Installation path: $vsPath"
270+
271+
$displayName = & $vsWhere -path "$vsPath" -property displayName
272+
$version = & $vsWhere -path "$vsPath" -property installationVersion
273+
$productId = & $vsWhere -path "$vsPath" -property productId
274+
275+
Write-Host "Product: $displayName"
276+
Write-Host "Version: $version"
277+
Write-Host "Product ID: $productId"
278+
279+
Write-Host "`nSearching for MSVC and Clang compilers:"
280+
$clPath = & $vsWhere -path "$vsPath" -find "**/Hostx64/x64/cl.exe" | Select-Object -First 1
281+
$clangPath = & $vsWhere -path "$vsPath" -find "**/bin/Hostx64/clang.exe" | Select-Object -First 1
282+
283+
if ($clPath) {
284+
Write-Host " ✓ MSVC cl.exe: $clPath"
285+
} else {
286+
Write-Host " ✗ MSVC cl.exe: NOT FOUND"
287+
}
288+
289+
if ($clangPath) {
290+
Write-Host " ✓ Clang: $clangPath"
291+
} else {
292+
Write-Host " ✗ Clang: NOT FOUND (May need to install C++ workload)"
293+
}
255294
256-
Write-Host "`n=========================="
257-
Write-Host "All prerequisites verified!"
295+
Write-Host "`n=========================================="
296+
Write-Host "Prerequisites verification completed!"
258297
259298
- name: Setup MSVC (Windows)
260299
if: matrix.platform == 'win'

0 commit comments

Comments
 (0)