update electron to v43

This commit is contained in:
olcxja 2026-07-09 22:38:33 +02:00
commit fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions

View file

@ -1,14 +1,15 @@
'use strict'
const fs = require('graceful-fs')
const gracefulFs = require('graceful-fs')
const fs = gracefulFs.promises
const path = require('path')
const glob = require('glob')
const log = require('npmlog')
const { glob } = require('tinyglobby')
const log = require('./log')
const which = require('which')
const win = process.platform === 'win32'
function build (gyp, argv, callback) {
var platformMake = 'make'
async function build (gyp, argv) {
let platformMake = 'make'
if (process.platform === 'aix') {
platformMake = 'gmake'
} else if (process.platform === 'os400') {
@ -21,143 +22,148 @@ function build (gyp, argv, callback) {
})
}
var makeCommand = gyp.opts.make || process.env.MAKE || platformMake
var command = win ? 'msbuild' : makeCommand
var jobs = gyp.opts.jobs || process.env.JOBS
var buildType
var config
var arch
var nodeDir
var guessedSolution
const makeCommand = gyp.opts.make || process.env.MAKE || platformMake
let command = win ? 'msbuild' : makeCommand
const jobs = gyp.opts.jobs || process.env.JOBS
let buildType
let config
let arch
let nodeDir
let guessedSolution
let python
let buildBinsDir
loadConfigGypi()
await loadConfigGypi()
/**
* Load the "config.gypi" file that was generated during "configure".
*/
function loadConfigGypi () {
var configPath = path.resolve('build', 'config.gypi')
fs.readFile(configPath, 'utf8', function (err, data) {
if (err) {
if (err.code === 'ENOENT') {
callback(new Error('You must run `node-gyp configure` first!'))
} else {
callback(err)
}
return
}
config = JSON.parse(data.replace(/#.+\n/, ''))
// get the 'arch', 'buildType', and 'nodeDir' vars from the config
buildType = config.target_defaults.default_configuration
arch = config.variables.target_arch
nodeDir = config.variables.nodedir
if ('debug' in gyp.opts) {
buildType = gyp.opts.debug ? 'Debug' : 'Release'
}
if (!buildType) {
buildType = 'Release'
}
log.verbose('build type', buildType)
log.verbose('architecture', arch)
log.verbose('node dev dir', nodeDir)
if (win) {
findSolutionFile()
async function loadConfigGypi () {
let data
try {
const configPath = path.resolve('build', 'config.gypi')
data = await fs.readFile(configPath, 'utf8')
} catch (err) {
if (err.code === 'ENOENT') {
throw new Error('You must run `node-gyp configure` first!')
} else {
doWhich()
throw err
}
})
}
config = JSON.parse(data.replace(/#.+\n/, ''))
// get the 'arch', 'buildType', and 'nodeDir' vars from the config
buildType = config.target_defaults.default_configuration
arch = config.variables.target_arch
nodeDir = config.variables.nodedir
python = config.variables.python
if ('debug' in gyp.opts) {
buildType = gyp.opts.debug ? 'Debug' : 'Release'
}
if (!buildType) {
buildType = 'Release'
}
log.verbose('build type', buildType)
log.verbose('architecture', arch)
log.verbose('node dev dir', nodeDir)
log.verbose('python', python)
if (win) {
await findSolutionFile()
} else {
await doWhich()
}
}
/**
* On Windows, find the first build/*.sln file.
*/
function findSolutionFile () {
glob('build/*.sln', function (err, files) {
if (err) {
return callback(err)
async function findSolutionFile () {
const files = await glob('build/*.sln', { expandDirectories: false })
if (files.length === 0) {
if (gracefulFs.existsSync('build/Makefile') ||
(await glob('build/*.mk', { expandDirectories: false })).length !== 0) {
command = makeCommand
await doWhich(false)
return
} else {
throw new Error('Could not find *.sln file or Makefile. Did you run "configure"?')
}
if (files.length === 0) {
return callback(new Error('Could not find *.sln file. Did you run "configure"?'))
}
guessedSolution = files[0]
log.verbose('found first Solution file', guessedSolution)
doWhich()
})
}
guessedSolution = files[0]
log.verbose('found first Solution file', guessedSolution)
await doWhich(true)
}
/**
* Uses node-which to locate the msbuild / make executable.
*/
function doWhich () {
async function doWhich (msvs) {
// On Windows use msbuild provided by node-gyp configure
if (win) {
if (msvs) {
if (!config.variables.msbuild_path) {
return callback(new Error(
'MSBuild is not set, please run `node-gyp configure`.'))
throw new Error('MSBuild is not set, please run `node-gyp configure`.')
}
command = config.variables.msbuild_path
log.verbose('using MSBuild:', command)
doBuild()
await doBuild(msvs)
return
}
// First make sure we have the build command in the PATH
which(command, function (err, execPath) {
if (err) {
// Some other error or 'make' not found on Unix, report that to the user
callback(err)
return
}
log.verbose('`which` succeeded for `' + command + '`', execPath)
doBuild()
})
const execPath = await which(command)
log.verbose('`which` succeeded for `' + command + '`', execPath)
await doBuild(msvs)
}
/**
* Actually spawn the process and compile the module.
*/
function doBuild () {
async function doBuild (msvs) {
// Enable Verbose build
var verbose = log.levels[log.level] <= log.levels.verbose
var j
const verbose = log.logger.isVisible('verbose')
let j
if (!win && verbose) {
if (!msvs && verbose) {
argv.push('V=1')
}
if (win && !verbose) {
if (msvs && !verbose) {
argv.push('/clp:Verbosity=minimal')
}
if (win) {
if (msvs) {
// Turn off the Microsoft logo on Windows
argv.push('/nologo')
// No lingering msbuild processes and open file handles
argv.push('/nodeReuse:false')
}
// Specify the build type, Release by default
if (win) {
if (msvs) {
// Convert .gypi config target_arch to MSBuild /Platform
// Since there are many ways to state '32-bit Intel', default to it.
// N.B. msbuild's Condition string equality tests are case-insensitive.
var archLower = arch.toLowerCase()
var p = archLower === 'x64' ? 'x64'
: (archLower === 'arm' ? 'ARM'
: (archLower === 'arm64' ? 'ARM64' : 'Win32'))
const archLower = arch.toLowerCase()
const p = archLower === 'x64'
? 'x64'
: (archLower === 'arm'
? 'ARM'
: (archLower === 'arm64' ? 'ARM64' : 'Win32'))
argv.push('/p:Configuration=' + buildType + ';Platform=' + p)
if (jobs) {
j = parseInt(jobs, 10)
if (!isNaN(j) && j > 0) {
argv.push('/m:' + j)
} else if (jobs.toUpperCase() === 'MAX') {
argv.push('/m:' + require('os').cpus().length)
argv.push('/m:' + require('os').availableParallelism())
}
}
} else {
@ -172,14 +178,14 @@ function build (gyp, argv, callback) {
argv.push(j)
} else if (jobs.toUpperCase() === 'MAX') {
argv.push('--jobs')
argv.push(require('os').cpus().length)
argv.push(require('os').availableParallelism())
}
}
}
if (win) {
if (msvs) {
// did the user specify their own .sln file?
var hasSln = argv.some(function (arg) {
const hasSln = argv.some(function (arg) {
return path.extname(arg) === '.sln'
})
if (!hasSln) {
@ -189,23 +195,34 @@ function build (gyp, argv, callback) {
if (!win) {
// Add build-time dependency symlinks (such as Python) to PATH
const buildBinsDir = path.resolve('build', 'node_gyp_bins')
buildBinsDir = path.resolve('build', 'node_gyp_bins')
process.env.PATH = `${buildBinsDir}:${process.env.PATH}`
log.verbose('bin symlinks', `adding symlinks (such as Python), at "${buildBinsDir}", to PATH`)
await fs.mkdir(buildBinsDir, { recursive: true })
const symlinkDestination = path.join(buildBinsDir, 'python3')
try {
await fs.unlink(symlinkDestination)
} catch (err) {
if (err.code !== 'ENOENT') throw err
}
await fs.symlink(python, symlinkDestination)
log.verbose('bin symlinks', `created symlink to "${python}" in "${buildBinsDir}" and added to PATH`)
}
var proc = gyp.spawn(command, argv)
proc.on('exit', onExit)
}
const proc = gyp.spawn(command, argv)
await new Promise((resolve, reject) => proc.on('exit', async (code, signal) => {
if (buildBinsDir) {
// Clean up the build-time dependency symlinks:
await fs.rm(buildBinsDir, { recursive: true, maxRetries: 3 })
}
function onExit (code, signal) {
if (code !== 0) {
return callback(new Error('`' + command + '` failed with exit code: ' + code))
}
if (signal) {
return callback(new Error('`' + command + '` got signal: ' + signal))
}
callback()
if (code !== 0) {
return reject(new Error('`' + command + '` failed with exit code: ' + code))
}
if (signal) {
return reject(new Error('`' + command + '` got signal: ' + signal))
}
resolve()
}))
}
}