Skip to content

Commit

Permalink
deps: node-gyp@10.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Apr 2, 2024
1 parent 6fd94f2 commit 7201a00
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 57 deletions.
3 changes: 3 additions & 0 deletions node_modules/node-gyp/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "10.1.0"
}
6 changes: 3 additions & 3 deletions node_modules/node-gyp/gyp/pylib/gyp/generator/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,9 @@ def ComputeOutput(self, spec):
% (self.android_class, self.android_module)
)
else:
path = "$(call intermediates-dir-for,{},{},,,$(GYP_VAR_PREFIX))".format(
self.android_class,
self.android_module,
path = (
"$(call intermediates-dir-for,"
f"{self.android_class},{self.android_module},,,$(GYP_VAR_PREFIX))"
)

assert spec.get("product_dir") is None # TODO: not supported?
Expand Down
7 changes: 3 additions & 4 deletions node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ def GenerateOutput(target_list, target_dicts, data, params):
# Use a banner that looks like the stock Python one and like what
# code.interact uses by default, but tack on something to indicate what
# locals are available, and identify gypsh.
banner = "Python {} on {}\nlocals.keys() = {}\ngypsh".format(
sys.version,
sys.platform,
repr(sorted(locals.keys())),
banner = (
f"Python {sys.version} on {sys.platform}\nlocals.keys() = "
f"{repr(sorted(locals.keys()))}\ngypsh"
)

code.interact(banner, local=locals)
20 changes: 8 additions & 12 deletions node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,11 +1778,9 @@ def _GetCopies(spec):
outer_dir = posixpath.split(src_bare)[1]
fixed_dst = _FixPath(dst)
full_dst = f'"{fixed_dst}\\{outer_dir}\\"'
cmd = 'mkdir {} 2>nul & cd "{}" && xcopy /e /f /y "{}" {}'.format(
full_dst,
_FixPath(base_dir),
outer_dir,
full_dst,
cmd = (
f'mkdir {full_dst} 2>nul & cd "{_FixPath(base_dir)}" && '
f'xcopy /e /f /y "{outer_dir}" {full_dst}'
)
copies.append(
(
Expand All @@ -1794,10 +1792,9 @@ def _GetCopies(spec):
)
else:
fix_dst = _FixPath(cpy["destination"])
cmd = 'mkdir "{}" 2>nul & set ERRORLEVEL=0 & copy /Y "{}" "{}"'.format(
fix_dst,
_FixPath(src),
_FixPath(dst),
cmd = (
f'mkdir "{fix_dst}" 2>nul & set ERRORLEVEL=0 & '
f'copy /Y "{_FixPath(src)}" "{_FixPath(dst)}"'
)
copies.append(([src], [dst], cmd, f"Copying {src} to {fix_dst}"))
return copies
Expand Down Expand Up @@ -1899,9 +1896,8 @@ def _GetPlatformOverridesOfProject(spec):
for config_name, c in spec["configurations"].items():
config_fullname = _ConfigFullName(config_name, c)
platform = c.get("msvs_target_platform", _ConfigPlatform(c))
fixed_config_fullname = "{}|{}".format(
_ConfigBaseName(config_name, _ConfigPlatform(c)),
platform,
fixed_config_fullname = (
f"{_ConfigBaseName(config_name, _ConfigPlatform(c))}|{platform}"
)
if spec["toolset"] == "host" and generator_supports_multiple_toolsets:
fixed_config_fullname = f"{config_name}|x64"
Expand Down
10 changes: 4 additions & 6 deletions node_modules/node-gyp/gyp/pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,18 +1135,16 @@ def EvalCondition(condition, conditions_key, phase, variables, build_file):
true_dict = condition[i + 1]
if type(true_dict) is not dict:
raise GypError(
"{} {} must be followed by a dictionary, not {}".format(
conditions_key, cond_expr, type(true_dict)
)
f"{conditions_key} {cond_expr} must be followed by a dictionary, not "
f"{type(true_dict)}"
)
if len(condition) > i + 2 and type(condition[i + 2]) is dict:
false_dict = condition[i + 2]
i = i + 3
if i != len(condition):
raise GypError(
"{} {} has {} unexpected trailing items".format(
conditions_key, cond_expr, len(condition) - i
)
f"{conditions_key} {cond_expr} has {len(condition) - i} "
"unexpected trailing items"
)
else:
false_dict = None
Expand Down
9 changes: 3 additions & 6 deletions node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,17 +830,14 @@ def _GetLdManifestFlags(
("VCLinkerTool", "UACUIAccess"), config, default="false"
)

inner = """
inner = f"""
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='{}' uiAccess='{}' />
<requestedExecutionLevel level='{execution_level_map[execution_level]}' uiAccess='{ui_access}' />
</requestedPrivileges>
</security>
</trustInfo>""".format(
execution_level_map[execution_level],
ui_access,
)
</trustInfo>""" # noqa: E501
else:
inner = ""

Expand Down
8 changes: 4 additions & 4 deletions node_modules/node-gyp/gyp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ gyp = "gyp:script_main"
"Homepage" = "https://github.com/nodejs/gyp-next"

[tool.ruff]
select = [
lint.select = [
"C4", # flake8-comprehensions
"C90", # McCabe cyclomatic complexity
"DTZ", # flake8-datetimez
Expand Down Expand Up @@ -87,7 +87,7 @@ select = [
# "T20", # flake8-print
# "TRY", # tryceratops
]
ignore = [
lint.ignore = [
"E721",
"PLC1901",
"PLR0402",
Expand All @@ -105,10 +105,10 @@ extend-exclude = ["pylib/packaging"]
line-length = 88
target-version = "py37"

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 101

[tool.ruff.pylint]
[tool.ruff.lint.pylint]
max-args = 11
max-branches = 108
max-returns = 10
Expand Down
28 changes: 27 additions & 1 deletion node_modules/node-gyp/lib/configure.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { promises: fs } = require('graceful-fs')
const { promises: fs, readFileSync } = require('graceful-fs')
const path = require('path')
const log = require('./log')
const os = require('os')
Expand All @@ -13,6 +13,10 @@ const { findAccessibleSync } = require('./util')
const { findPython } = require('./find-python')
const { findVisualStudio } = win ? require('./find-visualstudio') : {}

const majorRe = /^#define NODE_MAJOR_VERSION (\d+)/m
const minorRe = /^#define NODE_MINOR_VERSION (\d+)/m
const patchRe = /^#define NODE_PATCH_VERSION (\d+)/m

async function configure (gyp, argv) {
const buildDir = path.resolve('build')
const configNames = ['config.gypi', 'common.gypi']
Expand All @@ -27,6 +31,28 @@ async function configure (gyp, argv) {
// 'python' should be set by now
process.env.PYTHON = python

if (!gyp.opts.nodedir &&
process.config.variables.use_prefix_to_find_headers) {
// check if the headers can be found using the prefix specified
// at build time. Use them if they match the version expected
const prefix = process.config.variables.node_prefix
let availVersion
try {
const nodeVersionH = readFileSync(path.join(prefix,
'include', 'node', 'node_version.h'), { encoding: 'utf8' })
const major = nodeVersionH.match(majorRe)[1]
const minor = nodeVersionH.match(minorRe)[1]
const patch = nodeVersionH.match(patchRe)[1]
availVersion = major + '.' + minor + '.' + patch
} catch {}
if (availVersion === release.version) {
// ok version matches, use the headers
gyp.opts.nodedir = prefix
log.verbose('using local node headers based on prefix',
'setting nodedir to ' + gyp.opts.nodedir)
}
}

if (gyp.opts.nodedir) {
// --nodedir was specified. use that for the dev files
nodeDir = gyp.opts.nodedir.replace(/^~/, os.homedir())
Expand Down
2 changes: 1 addition & 1 deletion node_modules/node-gyp/lib/find-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PythonFinder {
static findPython = (...args) => new PythonFinder(...args).findPython()

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

Expand Down
127 changes: 113 additions & 14 deletions node_modules/node-gyp/lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class VisualStudioFinder {
}

const checks = [
() => this.findVisualStudio2017OrNewer(),
() => this.findVisualStudio2019OrNewerUsingSetupModule(),
() => this.findVisualStudio2019OrNewer(),
() => this.findVisualStudio2017UsingSetupModule(),
() => this.findVisualStudio2017(),
() => this.findVisualStudio2015(),
() => this.findVisualStudio2013()
]
Expand Down Expand Up @@ -113,9 +116,84 @@ class VisualStudioFinder {
throw new Error('Could not find any Visual Studio installation to use')
}

async findVisualStudio2019OrNewerUsingSetupModule () {
return this.findNewVSUsingSetupModule([2019, 2022])
}

async findVisualStudio2017UsingSetupModule () {
if (this.nodeSemver.major >= 22) {
this.addLog(
'not looking for VS2017 as it is only supported up to Node.js 21')
return null
}
return this.findNewVSUsingSetupModule([2017])
}

async findNewVSUsingSetupModule (supportedYears) {
const ps = path.join(process.env.SystemRoot, 'System32',
'WindowsPowerShell', 'v1.0', 'powershell.exe')
const vcInstallDir = this.envVcInstallDir

const checkModuleArgs = [
'-NoProfile',
'-Command',
'&{@(Get-Module -ListAvailable -Name VSSetup).Version.ToString()}'
]
this.log.silly('Running', ps, checkModuleArgs)
const [cErr] = await this.execFile(ps, checkModuleArgs)
if (cErr) {
this.addLog('VSSetup module doesn\'t seem to exist. You can install it via: "Install-Module VSSetup -Scope CurrentUser"')
this.log.silly('VSSetup error = %j', cErr && (cErr.stack || cErr))
return null
}
const filterArg = vcInstallDir !== undefined ? `| where {$_.InstallationPath -eq '${vcInstallDir}' }` : ''
const psArgs = [
'-NoProfile',
'-Command',
`&{Get-VSSetupInstance ${filterArg} | ConvertTo-Json -Depth 3}`
]

this.log.silly('Running', ps, psArgs)
const [err, stdout, stderr] = await this.execFile(ps, psArgs)
let parsedData = this.parseData(err, stdout, stderr)
if (parsedData === null) {
return null
}
this.log.silly('Parsed data', parsedData)
if (!Array.isArray(parsedData)) {
// if there are only 1 result, then Powershell will output non-array
parsedData = [parsedData]
}
// normalize output
parsedData = parsedData.map((info) => {
info.path = info.InstallationPath
info.version = `${info.InstallationVersion.Major}.${info.InstallationVersion.Minor}.${info.InstallationVersion.Build}.${info.InstallationVersion.Revision}`
info.packages = info.Packages.map((p) => p.Id)
return info
})
// pass for further processing
return this.processData(parsedData, supportedYears)
}

// Invoke the PowerShell script to get information about Visual Studio 2019
// or newer installations
async findVisualStudio2019OrNewer () {
return this.findNewVS([2019, 2022])
}

// Invoke the PowerShell script to get information about Visual Studio 2017
async findVisualStudio2017 () {
if (this.nodeSemver.major >= 22) {
this.addLog(
'not looking for VS2017 as it is only supported up to Node.js 21')
return null
}
return this.findNewVS([2017])
}

// Invoke the PowerShell script to get information about Visual Studio 2017
// or newer installations
async findVisualStudio2017OrNewer () {
async findNewVS (supportedYears) {
const ps = path.join(process.env.SystemRoot, 'System32',
'WindowsPowerShell', 'v1.0', 'powershell.exe')
const csFile = path.join(__dirname, 'Find-VisualStudio.cs')
Expand All @@ -128,24 +206,35 @@ class VisualStudioFinder {
]

this.log.silly('Running', ps, psArgs)
const [err, stdout, stderr] = await execFile(ps, psArgs, { encoding: 'utf8' })
return this.parseData(err, stdout, stderr)
const [err, stdout, stderr] = await this.execFile(ps, psArgs)
const parsedData = this.parseData(err, stdout, stderr, { checkIsArray: true })
if (parsedData === null) {
return null
}
return this.processData(parsedData, supportedYears)
}

// Parse the output of the PowerShell script and look for an installation
// of Visual Studio 2017 or newer to use
parseData (err, stdout, stderr) {
// Parse the output of the PowerShell script, make sanity checks
parseData (err, stdout, stderr, sanityCheckOptions) {
const defaultOptions = {
checkIsArray: false
}

// Merging provided options with the default options
const sanityOptions = { ...defaultOptions, ...sanityCheckOptions }

this.log.silly('PS stderr = %j', stderr)

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

if (err) {
this.log.silly('PS err = %j', err && (err.stack || err))
return failPowershell()
return failPowershell(`${err}`.substring(0, 40))
}

let vsInfo
Expand All @@ -157,11 +246,16 @@ class VisualStudioFinder {
return failPowershell()
}

if (!Array.isArray(vsInfo)) {
if (sanityOptions.checkIsArray && !Array.isArray(vsInfo)) {
this.log.silly('PS stdout = %j', stdout)
return failPowershell()
return failPowershell('Expected array as output of the PS script')
}
return vsInfo
}

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

// Remove future versions or errors parsing version number
// Also remove any unsupported versions
vsInfo = vsInfo.filter((info) => {
if (info.versionYear) {
if (info.versionYear && supportedYears.indexOf(info.versionYear) !== -1) {
return true
}
this.addLog(`unknown version "${info.version}" found at "${info.path}"`)
this.addLog(`${info.versionYear ? 'unsupported' : 'unknown'} version "${info.version}" found at "${info.path}"`)
return false
})

Expand Down Expand Up @@ -438,6 +533,10 @@ class VisualStudioFinder {

return true
}

async execFile (exec, args) {
return await execFile(exec, args, { encoding: 'utf8' })
}
}

module.exports = VisualStudioFinder
2 changes: 1 addition & 1 deletion node_modules/node-gyp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bindings",
"gyp"
],
"version": "10.0.1",
"version": "10.1.0",
"installVersion": 11,
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",
"repository": {
Expand Down
Loading

0 comments on commit 7201a00

Please sign in to comment.