Skip to content

Commit 135facb

Browse files
committed
fix(smol): pass msvs_version as gyp generator flag
Use -G msvs_version=2022 instead of GYP_MSVS_VERSION env var. Gyp checks generator_flags dict, not environment variables.
1 parent bfc8fae commit 135facb

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/node-smol-builder/scripts/build.mjs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,13 @@ async function main() {
14241424
configureFlags.unshift('--dest-cpu=x64')
14251425
}
14261426

1427+
// On Windows, tell gyp to use VS 2022 via generator flag (bypasses auto-detection).
1428+
// https://github.com/nodejs/node/blob/main/BUILDING.md#windows
1429+
// https://github.com/nodejs/node/blob/main/tools/gyp/pylib/gyp/MSVSVersion.py
1430+
if (WIN32) {
1431+
configureFlags.push('-G', 'msvs_version=2022')
1432+
}
1433+
14271434
// Windows uses configure.py directly, Unix uses ./configure wrapper script.
14281435
// Use whichBinSync to resolve full path to python.exe since we use shell: false.
14291436
const configureCommand = WIN32 ? whichBinSync('python') : './configure'
@@ -1452,20 +1459,11 @@ async function main() {
14521459
// propagate environment variables to subprocesses.
14531460
const execOptions = {
14541461
cwd: NODE_DIR,
1455-
env: WIN32
1456-
? {
1457-
...process.env,
1458-
// Tell gyp to use VS 2022, bypassing auto-detection.
1459-
// https://github.com/nodejs/node/blob/main/BUILDING.md#windows
1460-
// https://github.com/nodejs/node/blob/main/tools/gyp/pylib/gyp/MSVSVersion.py
1461-
GYP_MSVS_VERSION: '2022',
1462-
}
1463-
: process.env,
1462+
env: process.env,
14641463
shell: false,
14651464
}
14661465
if (WIN32) {
14671466
logger.log(`DEBUG: Passing env with ${Object.keys(execOptions.env).length} variables (shell: false)`)
1468-
logger.log(`DEBUG: GYP_MSVS_VERSION = ${execOptions.env.GYP_MSVS_VERSION}`)
14691467
}
14701468

14711469
await exec(configureCommand, configureArgs, execOptions)

0 commit comments

Comments
 (0)