mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
Sync deps and engines with npm (#2770)
* feat!: update `engines.node` to `^14.17.0 || ^16.13.0 || >=18.0.0` * deps: nopt@^7.0.0 * feat: replace npmlog with proc-log * deps: standard@17.0.0 and fix linting errors * deps: which@3.0.0 - this also promiisifies the build command * deps: glob@8.0.3 * feat: drop rimraf dependency * fix: use fs/promises in favor of fs.promises
This commit is contained in:
parent
33391db3a0
commit
192eec2aca
27 changed files with 536 additions and 418 deletions
|
@ -2,26 +2,27 @@
|
|||
|
||||
const fs = require('graceful-fs')
|
||||
const path = require('path')
|
||||
const log = require('npmlog')
|
||||
const log = require('./log')
|
||||
const os = require('os')
|
||||
const processRelease = require('./process-release')
|
||||
const win = process.platform === 'win32'
|
||||
const findNodeDirectory = require('./find-node-directory')
|
||||
const createConfigGypi = require('./create-config-gypi')
|
||||
const msgFormat = require('util').format
|
||||
var findPython = require('./find-python')
|
||||
const findPython = require('./find-python')
|
||||
let findVisualStudio
|
||||
if (win) {
|
||||
var findVisualStudio = require('./find-visualstudio')
|
||||
findVisualStudio = require('./find-visualstudio')
|
||||
}
|
||||
|
||||
function configure (gyp, argv, callback) {
|
||||
var python
|
||||
var buildDir = path.resolve('build')
|
||||
var buildBinsDir = path.join(buildDir, 'node_gyp_bins')
|
||||
var configNames = ['config.gypi', 'common.gypi']
|
||||
var configs = []
|
||||
var nodeDir
|
||||
var release = processRelease(argv, gyp, process.version, process.release)
|
||||
let python
|
||||
const buildDir = path.resolve('build')
|
||||
const buildBinsDir = path.join(buildDir, 'node_gyp_bins')
|
||||
const configNames = ['config.gypi', 'common.gypi']
|
||||
const configs = []
|
||||
let nodeDir
|
||||
const release = processRelease(argv, gyp, process.version, process.release)
|
||||
|
||||
findPython(gyp.opts.python, function (err, found) {
|
||||
if (err) {
|
||||
|
@ -129,11 +130,11 @@ function configure (gyp, argv, callback) {
|
|||
}
|
||||
|
||||
function findConfigs () {
|
||||
var name = configNames.shift()
|
||||
const name = configNames.shift()
|
||||
if (!name) {
|
||||
return runGyp()
|
||||
}
|
||||
var fullPath = path.resolve(name)
|
||||
const fullPath = path.resolve(name)
|
||||
|
||||
log.verbose(name, 'checking for gypi file: %s', fullPath)
|
||||
fs.stat(fullPath, function (err) {
|
||||
|
@ -175,11 +176,13 @@ function configure (gyp, argv, callback) {
|
|||
|
||||
// For AIX and z/OS we need to set up the path to the exports file
|
||||
// which contains the symbols needed for linking.
|
||||
var nodeExpFile
|
||||
let nodeExpFile
|
||||
let nodeRootDir
|
||||
let candidates
|
||||
let logprefix = 'find exports file'
|
||||
if (process.platform === 'aix' || process.platform === 'os390' || process.platform === 'os400') {
|
||||
var ext = process.platform === 'os390' ? 'x' : 'exp'
|
||||
var nodeRootDir = findNodeDirectory()
|
||||
var candidates
|
||||
const ext = process.platform === 'os390' ? 'x' : 'exp'
|
||||
nodeRootDir = findNodeDirectory()
|
||||
|
||||
if (process.platform === 'aix' || process.platform === 'os400') {
|
||||
candidates = [
|
||||
|
@ -202,12 +205,11 @@ function configure (gyp, argv, callback) {
|
|||
})
|
||||
}
|
||||
|
||||
var logprefix = 'find exports file'
|
||||
nodeExpFile = findAccessibleSync(logprefix, nodeRootDir, candidates)
|
||||
if (nodeExpFile !== undefined) {
|
||||
log.verbose(logprefix, 'Found exports file: %s', nodeExpFile)
|
||||
} else {
|
||||
var msg = msgFormat('Could not find node.%s file in %s', ext, nodeRootDir)
|
||||
const msg = msgFormat('Could not find node.%s file in %s', ext, nodeRootDir)
|
||||
log.error(logprefix, 'Could not find exports file')
|
||||
return callback(new Error(msg))
|
||||
}
|
||||
|
@ -215,11 +217,11 @@ function configure (gyp, argv, callback) {
|
|||
|
||||
// For z/OS we need to set up the path to zoslib include directory,
|
||||
// which contains headers included in v8config.h.
|
||||
var zoslibIncDir
|
||||
let zoslibIncDir
|
||||
if (process.platform === 'os390') {
|
||||
logprefix = "find zoslib's zos-base.h:"
|
||||
let msg
|
||||
var zoslibIncPath = process.env.ZOSLIB_INCLUDES
|
||||
let zoslibIncPath = process.env.ZOSLIB_INCLUDES
|
||||
if (zoslibIncPath) {
|
||||
zoslibIncPath = findAccessibleSync(logprefix, zoslibIncPath, ['zos-base.h'])
|
||||
if (zoslibIncPath === undefined) {
|
||||
|
@ -252,22 +254,22 @@ function configure (gyp, argv, callback) {
|
|||
}
|
||||
|
||||
// this logic ported from the old `gyp_addon` python file
|
||||
var gypScript = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py')
|
||||
var addonGypi = path.resolve(__dirname, '..', 'addon.gypi')
|
||||
var commonGypi = path.resolve(nodeDir, 'include/node/common.gypi')
|
||||
const gypScript = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py')
|
||||
const addonGypi = path.resolve(__dirname, '..', 'addon.gypi')
|
||||
let commonGypi = path.resolve(nodeDir, 'include/node/common.gypi')
|
||||
fs.stat(commonGypi, function (err) {
|
||||
if (err) {
|
||||
commonGypi = path.resolve(nodeDir, 'common.gypi')
|
||||
}
|
||||
|
||||
var outputDir = 'build'
|
||||
let outputDir = 'build'
|
||||
if (win) {
|
||||
// Windows expects an absolute path
|
||||
outputDir = buildDir
|
||||
}
|
||||
var nodeGypDir = path.resolve(__dirname, '..')
|
||||
const nodeGypDir = path.resolve(__dirname, '..')
|
||||
|
||||
var nodeLibFile = path.join(nodeDir,
|
||||
let nodeLibFile = path.join(nodeDir,
|
||||
!gyp.opts.nodedir ? '<(target_arch)' : '$(Configuration)',
|
||||
release.name + '.lib')
|
||||
|
||||
|
@ -309,13 +311,13 @@ function configure (gyp, argv, callback) {
|
|||
argv.unshift(gypScript)
|
||||
|
||||
// make sure python uses files that came with this particular node package
|
||||
var pypath = [path.join(__dirname, '..', 'gyp', 'pylib')]
|
||||
const pypath = [path.join(__dirname, '..', 'gyp', 'pylib')]
|
||||
if (process.env.PYTHONPATH) {
|
||||
pypath.push(process.env.PYTHONPATH)
|
||||
}
|
||||
process.env.PYTHONPATH = pypath.join(win ? ';' : ':')
|
||||
|
||||
var cp = gyp.spawn(python, argv)
|
||||
const cp = gyp.spawn(python, argv)
|
||||
cp.on('exit', onCpExit)
|
||||
})
|
||||
}
|
||||
|
@ -336,10 +338,11 @@ function configure (gyp, argv, callback) {
|
|||
* readable.
|
||||
*/
|
||||
function findAccessibleSync (logprefix, dir, candidates) {
|
||||
for (var next = 0; next < candidates.length; next++) {
|
||||
var candidate = path.resolve(dir, candidates[next])
|
||||
for (let next = 0; next < candidates.length; next++) {
|
||||
const candidate = path.resolve(dir, candidates[next])
|
||||
let fd
|
||||
try {
|
||||
var fd = fs.openSync(candidate, 'r')
|
||||
fd = fs.openSync(candidate, 'r')
|
||||
} catch (e) {
|
||||
// this candidate was not found or not readable, do nothing
|
||||
log.silly(logprefix, 'Could not open %s: %s', candidate, e.message)
|
||||
|
@ -355,6 +358,6 @@ function findAccessibleSync (logprefix, dir, candidates) {
|
|||
|
||||
module.exports = configure
|
||||
module.exports.test = {
|
||||
findAccessibleSync: findAccessibleSync
|
||||
findAccessibleSync
|
||||
}
|
||||
module.exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue