Skip to content

Commit 7201a00

Browse files
committed
deps: node-gyp@10.1.0
1 parent 6fd94f2 commit 7201a00

14 files changed

+215
-57
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "10.1.0"
3+
}

node_modules/node-gyp/gyp/pylib/gyp/generator/android.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,9 @@ def ComputeOutput(self, spec):
739739
% (self.android_class, self.android_module)
740740
)
741741
else:
742-
path = "$(call intermediates-dir-for,{},{},,,$(GYP_VAR_PREFIX))".format(
743-
self.android_class,
744-
self.android_module,
742+
path = (
743+
"$(call intermediates-dir-for,"
744+
f"{self.android_class},{self.android_module},,,$(GYP_VAR_PREFIX))"
745745
)
746746

747747
assert spec.get("product_dir") is None # TODO: not supported?

node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
4949
# Use a banner that looks like the stock Python one and like what
5050
# code.interact uses by default, but tack on something to indicate what
5151
# locals are available, and identify gypsh.
52-
banner = "Python {} on {}\nlocals.keys() = {}\ngypsh".format(
53-
sys.version,
54-
sys.platform,
55-
repr(sorted(locals.keys())),
52+
banner = (
53+
f"Python {sys.version} on {sys.platform}\nlocals.keys() = "
54+
f"{repr(sorted(locals.keys()))}\ngypsh"
5655
)
5756

5857
code.interact(banner, local=locals)

node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -1778,11 +1778,9 @@ def _GetCopies(spec):
17781778
outer_dir = posixpath.split(src_bare)[1]
17791779
fixed_dst = _FixPath(dst)
17801780
full_dst = f'"{fixed_dst}\\{outer_dir}\\"'
1781-
cmd = 'mkdir {} 2>nul & cd "{}" && xcopy /e /f /y "{}" {}'.format(
1782-
full_dst,
1783-
_FixPath(base_dir),
1784-
outer_dir,
1785-
full_dst,
1781+
cmd = (
1782+
f'mkdir {full_dst} 2>nul & cd "{_FixPath(base_dir)}" && '
1783+
f'xcopy /e /f /y "{outer_dir}" {full_dst}'
17861784
)
17871785
copies.append(
17881786
(
@@ -1794,10 +1792,9 @@ def _GetCopies(spec):
17941792
)
17951793
else:
17961794
fix_dst = _FixPath(cpy["destination"])
1797-
cmd = 'mkdir "{}" 2>nul & set ERRORLEVEL=0 & copy /Y "{}" "{}"'.format(
1798-
fix_dst,
1799-
_FixPath(src),
1800-
_FixPath(dst),
1795+
cmd = (
1796+
f'mkdir "{fix_dst}" 2>nul & set ERRORLEVEL=0 & '
1797+
f'copy /Y "{_FixPath(src)}" "{_FixPath(dst)}"'
18011798
)
18021799
copies.append(([src], [dst], cmd, f"Copying {src} to {fix_dst}"))
18031800
return copies
@@ -1899,9 +1896,8 @@ def _GetPlatformOverridesOfProject(spec):
18991896
for config_name, c in spec["configurations"].items():
19001897
config_fullname = _ConfigFullName(config_name, c)
19011898
platform = c.get("msvs_target_platform", _ConfigPlatform(c))
1902-
fixed_config_fullname = "{}|{}".format(
1903-
_ConfigBaseName(config_name, _ConfigPlatform(c)),
1904-
platform,
1899+
fixed_config_fullname = (
1900+
f"{_ConfigBaseName(config_name, _ConfigPlatform(c))}|{platform}"
19051901
)
19061902
if spec["toolset"] == "host" and generator_supports_multiple_toolsets:
19071903
fixed_config_fullname = f"{config_name}|x64"

node_modules/node-gyp/gyp/pylib/gyp/input.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1135,18 +1135,16 @@ def EvalCondition(condition, conditions_key, phase, variables, build_file):
11351135
true_dict = condition[i + 1]
11361136
if type(true_dict) is not dict:
11371137
raise GypError(
1138-
"{} {} must be followed by a dictionary, not {}".format(
1139-
conditions_key, cond_expr, type(true_dict)
1140-
)
1138+
f"{conditions_key} {cond_expr} must be followed by a dictionary, not "
1139+
f"{type(true_dict)}"
11411140
)
11421141
if len(condition) > i + 2 and type(condition[i + 2]) is dict:
11431142
false_dict = condition[i + 2]
11441143
i = i + 3
11451144
if i != len(condition):
11461145
raise GypError(
1147-
"{} {} has {} unexpected trailing items".format(
1148-
conditions_key, cond_expr, len(condition) - i
1149-
)
1146+
f"{conditions_key} {cond_expr} has {len(condition) - i} "
1147+
"unexpected trailing items"
11501148
)
11511149
else:
11521150
false_dict = None

node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -830,17 +830,14 @@ def _GetLdManifestFlags(
830830
("VCLinkerTool", "UACUIAccess"), config, default="false"
831831
)
832832

833-
inner = """
833+
inner = f"""
834834
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
835835
<security>
836836
<requestedPrivileges>
837-
<requestedExecutionLevel level='{}' uiAccess='{}' />
837+
<requestedExecutionLevel level='{execution_level_map[execution_level]}' uiAccess='{ui_access}' />
838838
</requestedPrivileges>
839839
</security>
840-
</trustInfo>""".format(
841-
execution_level_map[execution_level],
842-
ui_access,
843-
)
840+
</trustInfo>""" # noqa: E501
844841
else:
845842
inner = ""
846843

node_modules/node-gyp/gyp/pyproject.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ gyp = "gyp:script_main"
3838
"Homepage" = "https://github.com/nodejs/gyp-next"
3939

4040
[tool.ruff]
41-
select = [
41+
lint.select = [
4242
"C4", # flake8-comprehensions
4343
"C90", # McCabe cyclomatic complexity
4444
"DTZ", # flake8-datetimez
@@ -87,7 +87,7 @@ select = [
8787
# "T20", # flake8-print
8888
# "TRY", # tryceratops
8989
]
90-
ignore = [
90+
lint.ignore = [
9191
"E721",
9292
"PLC1901",
9393
"PLR0402",
@@ -105,10 +105,10 @@ extend-exclude = ["pylib/packaging"]
105105
line-length = 88
106106
target-version = "py37"
107107

108-
[tool.ruff.mccabe]
108+
[tool.ruff.lint.mccabe]
109109
max-complexity = 101
110110

111-
[tool.ruff.pylint]
111+
[tool.ruff.lint.pylint]
112112
max-args = 11
113113
max-branches = 108
114114
max-returns = 10

node_modules/node-gyp/lib/configure.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const { promises: fs } = require('graceful-fs')
3+
const { promises: fs, readFileSync } = require('graceful-fs')
44
const path = require('path')
55
const log = require('./log')
66
const os = require('os')
@@ -13,6 +13,10 @@ const { findAccessibleSync } = require('./util')
1313
const { findPython } = require('./find-python')
1414
const { findVisualStudio } = win ? require('./find-visualstudio') : {}
1515

16+
const majorRe = /^#define NODE_MAJOR_VERSION (\d+)/m
17+
const minorRe = /^#define NODE_MINOR_VERSION (\d+)/m
18+
const patchRe = /^#define NODE_PATCH_VERSION (\d+)/m
19+
1620
async function configure (gyp, argv) {
1721
const buildDir = path.resolve('build')
1822
const configNames = ['config.gypi', 'common.gypi']
@@ -27,6 +31,28 @@ async function configure (gyp, argv) {
2731
// 'python' should be set by now
2832
process.env.PYTHON = python
2933

34+
if (!gyp.opts.nodedir &&
35+
process.config.variables.use_prefix_to_find_headers) {
36+
// check if the headers can be found using the prefix specified
37+
// at build time. Use them if they match the version expected
38+
const prefix = process.config.variables.node_prefix
39+
let availVersion
40+
try {
41+
const nodeVersionH = readFileSync(path.join(prefix,
42+
'include', 'node', 'node_version.h'), { encoding: 'utf8' })
43+
const major = nodeVersionH.match(majorRe)[1]
44+
const minor = nodeVersionH.match(minorRe)[1]
45+
const patch = nodeVersionH.match(patchRe)[1]
46+
availVersion = major + '.' + minor + '.' + patch
47+
} catch {}
48+
if (availVersion === release.version) {
49+
// ok version matches, use the headers
50+
gyp.opts.nodedir = prefix
51+
log.verbose('using local node headers based on prefix',
52+
'setting nodedir to ' + gyp.opts.nodedir)
53+
}
54+
}
55+
3056
if (gyp.opts.nodedir) {
3157
// --nodedir was specified. use that for the dev files
3258
nodeDir = gyp.opts.nodedir.replace(/^~/, os.homedir())

node_modules/node-gyp/lib/find-python.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class PythonFinder {
4141
static findPython = (...args) => new PythonFinder(...args).findPython()
4242

4343
log = log.withPrefix('find Python')
44-
argsExecutable = ['-c', 'import sys; print(sys.executable);']
44+
argsExecutable = ['-c', 'import sys; sys.stdout.buffer.write(sys.executable.encode(\'utf-8\'));']
4545
argsVersion = ['-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);']
4646
semverRange = '>=3.6.0'
4747

node_modules/node-gyp/lib/find-visualstudio.js

+113-14
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ class VisualStudioFinder {
5454
}
5555

5656
const checks = [
57-
() => this.findVisualStudio2017OrNewer(),
57+
() => this.findVisualStudio2019OrNewerUsingSetupModule(),
58+
() => this.findVisualStudio2019OrNewer(),
59+
() => this.findVisualStudio2017UsingSetupModule(),
60+
() => this.findVisualStudio2017(),
5861
() => this.findVisualStudio2015(),
5962
() => this.findVisualStudio2013()
6063
]
@@ -113,9 +116,84 @@ class VisualStudioFinder {
113116
throw new Error('Could not find any Visual Studio installation to use')
114117
}
115118

119+
async findVisualStudio2019OrNewerUsingSetupModule () {
120+
return this.findNewVSUsingSetupModule([2019, 2022])
121+
}
122+
123+
async findVisualStudio2017UsingSetupModule () {
124+
if (this.nodeSemver.major >= 22) {
125+
this.addLog(
126+
'not looking for VS2017 as it is only supported up to Node.js 21')
127+
return null
128+
}
129+
return this.findNewVSUsingSetupModule([2017])
130+
}
131+
132+
async findNewVSUsingSetupModule (supportedYears) {
133+
const ps = path.join(process.env.SystemRoot, 'System32',
134+
'WindowsPowerShell', 'v1.0', 'powershell.exe')
135+
const vcInstallDir = this.envVcInstallDir
136+
137+
const checkModuleArgs = [
138+
'-NoProfile',
139+
'-Command',
140+
'&{@(Get-Module -ListAvailable -Name VSSetup).Version.ToString()}'
141+
]
142+
this.log.silly('Running', ps, checkModuleArgs)
143+
const [cErr] = await this.execFile(ps, checkModuleArgs)
144+
if (cErr) {
145+
this.addLog('VSSetup module doesn\'t seem to exist. You can install it via: "Install-Module VSSetup -Scope CurrentUser"')
146+
this.log.silly('VSSetup error = %j', cErr && (cErr.stack || cErr))
147+
return null
148+
}
149+
const filterArg = vcInstallDir !== undefined ? `| where {$_.InstallationPath -eq '${vcInstallDir}' }` : ''
150+
const psArgs = [
151+
'-NoProfile',
152+
'-Command',
153+
`&{Get-VSSetupInstance ${filterArg} | ConvertTo-Json -Depth 3}`
154+
]
155+
156+
this.log.silly('Running', ps, psArgs)
157+
const [err, stdout, stderr] = await this.execFile(ps, psArgs)
158+
let parsedData = this.parseData(err, stdout, stderr)
159+
if (parsedData === null) {
160+
return null
161+
}
162+
this.log.silly('Parsed data', parsedData)
163+
if (!Array.isArray(parsedData)) {
164+
// if there are only 1 result, then Powershell will output non-array
165+
parsedData = [parsedData]
166+
}
167+
// normalize output
168+
parsedData = parsedData.map((info) => {
169+
info.path = info.InstallationPath
170+
info.version = `${info.InstallationVersion.Major}.${info.InstallationVersion.Minor}.${info.InstallationVersion.Build}.${info.InstallationVersion.Revision}`
171+
info.packages = info.Packages.map((p) => p.Id)
172+
return info
173+
})
174+
// pass for further processing
175+
return this.processData(parsedData, supportedYears)
176+
}
177+
178+
// Invoke the PowerShell script to get information about Visual Studio 2019
179+
// or newer installations
180+
async findVisualStudio2019OrNewer () {
181+
return this.findNewVS([2019, 2022])
182+
}
183+
184+
// Invoke the PowerShell script to get information about Visual Studio 2017
185+
async findVisualStudio2017 () {
186+
if (this.nodeSemver.major >= 22) {
187+
this.addLog(
188+
'not looking for VS2017 as it is only supported up to Node.js 21')
189+
return null
190+
}
191+
return this.findNewVS([2017])
192+
}
193+
116194
// Invoke the PowerShell script to get information about Visual Studio 2017
117195
// or newer installations
118-
async findVisualStudio2017OrNewer () {
196+
async findNewVS (supportedYears) {
119197
const ps = path.join(process.env.SystemRoot, 'System32',
120198
'WindowsPowerShell', 'v1.0', 'powershell.exe')
121199
const csFile = path.join(__dirname, 'Find-VisualStudio.cs')
@@ -128,24 +206,35 @@ class VisualStudioFinder {
128206
]
129207

130208
this.log.silly('Running', ps, psArgs)
131-
const [err, stdout, stderr] = await execFile(ps, psArgs, { encoding: 'utf8' })
132-
return this.parseData(err, stdout, stderr)
209+
const [err, stdout, stderr] = await this.execFile(ps, psArgs)
210+
const parsedData = this.parseData(err, stdout, stderr, { checkIsArray: true })
211+
if (parsedData === null) {
212+
return null
213+
}
214+
return this.processData(parsedData, supportedYears)
133215
}
134216

135-
// Parse the output of the PowerShell script and look for an installation
136-
// of Visual Studio 2017 or newer to use
137-
parseData (err, stdout, stderr) {
217+
// Parse the output of the PowerShell script, make sanity checks
218+
parseData (err, stdout, stderr, sanityCheckOptions) {
219+
const defaultOptions = {
220+
checkIsArray: false
221+
}
222+
223+
// Merging provided options with the default options
224+
const sanityOptions = { ...defaultOptions, ...sanityCheckOptions }
225+
138226
this.log.silly('PS stderr = %j', stderr)
139227

140-
const failPowershell = () => {
228+
const failPowershell = (failureDetails) => {
141229
this.addLog(
142-
'could not use PowerShell to find Visual Studio 2017 or newer, try re-running with \'--loglevel silly\' for more details')
230+
`could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details. \n
231+
Failure details: ${failureDetails}`)
143232
return null
144233
}
145234

146235
if (err) {
147236
this.log.silly('PS err = %j', err && (err.stack || err))
148-
return failPowershell()
237+
return failPowershell(`${err}`.substring(0, 40))
149238
}
150239

151240
let vsInfo
@@ -157,11 +246,16 @@ class VisualStudioFinder {
157246
return failPowershell()
158247
}
159248

160-
if (!Array.isArray(vsInfo)) {
249+
if (sanityOptions.checkIsArray && !Array.isArray(vsInfo)) {
161250
this.log.silly('PS stdout = %j', stdout)
162-
return failPowershell()
251+
return failPowershell('Expected array as output of the PS script')
163252
}
253+
return vsInfo
254+
}
164255

256+
// Process parsed data containing information about VS installations
257+
// Look for the required parts, extract and output them back
258+
processData (vsInfo, supportedYears) {
165259
vsInfo = vsInfo.map((info) => {
166260
this.log.silly(`processing installation: "${info.path}"`)
167261
info.path = path.resolve(info.path)
@@ -175,11 +269,12 @@ class VisualStudioFinder {
175269
this.log.silly('vsInfo:', vsInfo)
176270

177271
// Remove future versions or errors parsing version number
272+
// Also remove any unsupported versions
178273
vsInfo = vsInfo.filter((info) => {
179-
if (info.versionYear) {
274+
if (info.versionYear && supportedYears.indexOf(info.versionYear) !== -1) {
180275
return true
181276
}
182-
this.addLog(`unknown version "${info.version}" found at "${info.path}"`)
277+
this.addLog(`${info.versionYear ? 'unsupported' : 'unknown'} version "${info.version}" found at "${info.path}"`)
183278
return false
184279
})
185280

@@ -438,6 +533,10 @@ class VisualStudioFinder {
438533

439534
return true
440535
}
536+
537+
async execFile (exec, args) {
538+
return await execFile(exec, args, { encoding: 'utf8' })
539+
}
441540
}
442541

443542
module.exports = VisualStudioFinder

node_modules/node-gyp/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"bindings",
1212
"gyp"
1313
],
14-
"version": "10.0.1",
14+
"version": "10.1.0",
1515
"installVersion": 11,
1616
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",
1717
"repository": {

0 commit comments

Comments
 (0)