Added support for Streamdeck Pedal and updated UI to better fit the Packed UI style

This commit is contained in:
2026-02-27 22:47:08 +01:00
committed by erik
parent 5a70f775f1
commit 93faae5cc8
1463 changed files with 306917 additions and 0 deletions

58
node_modules/cmake-js/lib/appCMakeJSConfig.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
'use strict'
const path = require('path')
function getConfig(lookPath, log) {
const pjsonPath = path.join(lookPath, 'package.json')
log.silly('CFG', "Looking for package.json in: '" + pjsonPath + "'.")
try {
const json = require(pjsonPath)
log.silly('CFG', 'Loaded:\n' + JSON.stringify(json))
if (json && json['cmake-js'] && typeof json['cmake-js'] === 'object') {
log.silly('CFG', 'Config found.')
return json['cmake-js']
} else {
log.silly('CFG', 'Config not found.')
return null
}
} catch (e) {
log.silly('CFG', "'package.json' not found.")
return null
}
}
module.exports = function (projectPath, log) {
log.verbose('CFG', "Looking for application level CMake.js config in '" + projectPath + '.')
let currPath = projectPath
let lastConfig = null
let currConfig
for (;;) {
currConfig = getConfig(currPath, log)
if (currConfig) {
lastConfig = currConfig
}
try {
log.silly('CFG', 'Looking for parent path.')
const lastPath = currPath
currPath = path.normalize(path.join(currPath, '..'))
if (lastPath === currPath) {
currPath = null // root
}
if (currPath) {
log.silly('CFG', "Parent path: '" + currPath + "'.")
}
} catch (e) {
log.silly('CFG', 'Exception:\n' + e.stack)
break
}
if (currPath === null) {
log.silly('CFG', "Parent path with package.json file doesn't exists. Done.")
break
}
}
if (lastConfig) {
log.verbose('CFG', 'Application level CMake.js config found:\n' + JSON.stringify(lastConfig))
} else {
log.verbose('CFG', "Application level CMake.js config doesn't exists.")
}
return lastConfig
}

123
node_modules/cmake-js/lib/buildSystem.js generated vendored Normal file
View File

@@ -0,0 +1,123 @@
'use strict'
const CMake = require('./cMake')
const Dist = require('./dist')
const CMLog = require('./cmLog')
const appCMakeJSConfig = require('./appCMakeJSConfig')
const npmConfig = require('./npmConfig')
const path = require('path')
const Toolset = require('./toolset')
function isNodeApi(log, projectRoot) {
try {
const projectPkgJson = require(path.join(projectRoot, 'package.json'))
// Make sure the property exists
return !!projectPkgJson?.binary?.napi_versions
} catch (e) {
log.silly('CFG', "'package.json' not found.")
return false
}
}
class BuildSystem {
constructor(options) {
this.options = options || {}
this.options.directory = path.resolve(this.options.directory || process.cwd())
this.options.out = path.resolve(this.options.out || path.join(this.options.directory, 'build'))
this.log = new CMLog(this.options)
this.options.isNodeApi = isNodeApi(this.log, this.options.directory)
const appConfig = appCMakeJSConfig(this.options.directory, this.log)
const npmOptions = npmConfig(this.log)
if (npmOptions && typeof npmOptions === 'object' && Object.keys(npmOptions).length) {
this.options.runtimeDirectory = npmOptions['nodedir']
this.options.msvsVersion = npmOptions['msvs_version']
}
if (appConfig && typeof appConfig === 'object' && Object.keys(appConfig).length) {
this.log.verbose('CFG', 'Applying CMake.js config from root package.json:')
this.log.verbose('CFG', JSON.stringify(appConfig))
// Applying applications's config, if there is no explicit runtime related options specified
this.options.runtime = this.options.runtime || appConfig.runtime
this.options.runtimeVersion = this.options.runtimeVersion || appConfig.runtimeVersion
this.options.arch = this.options.arch || appConfig.arch
}
this.log.verbose('CFG', 'Build system options:')
this.log.verbose('CFG', JSON.stringify(this.options))
this.cmake = new CMake(this.options)
this.dist = new Dist(this.options)
this.toolset = new Toolset(this.options)
}
async _ensureInstalled() {
try {
await this.toolset.initialize(true)
if (!this.options.isNodeApi) {
await this.dist.ensureDownloaded()
}
} catch (e) {
this._showError(e)
throw e
}
}
_showError(e) {
if (this.log === undefined) {
// handle internal errors (init failed)
console.error('OMG', e.stack)
return
}
if (this.log.level === 'verbose' || this.log.level === 'silly') {
this.log.error('OMG', e.stack)
} else {
this.log.error('OMG', e.message)
}
}
install() {
return this._ensureInstalled()
}
async _invokeCMake(method) {
try {
await this._ensureInstalled()
return await this.cmake[method]()
} catch (e) {
this._showError(e)
throw e
}
}
getConfigureCommand() {
return this._invokeCMake('getConfigureCommand')
}
getCmakeJsLibString() {
return this._invokeCMake('getCmakeJsLibString')
}
getCmakeJsIncludeString() {
return this._invokeCMake('getCmakeJsIncludeString')
}
getCmakeJsSrcString() {
return this._invokeCMake('getCmakeJsSrcString')
}
configure() {
return this._invokeCMake('configure')
}
getBuildCommand() {
return this._invokeCMake('getBuildCommand')
}
build() {
return this._invokeCMake('build')
}
getCleanCommand() {
return this._invokeCMake('getCleanCommand')
}
clean() {
return this._invokeCMake('clean')
}
reconfigure() {
return this._invokeCMake('reconfigure')
}
rebuild() {
return this._invokeCMake('rebuild')
}
compile() {
return this._invokeCMake('compile')
}
}
module.exports = BuildSystem

362
node_modules/cmake-js/lib/cMake.js generated vendored Normal file
View File

@@ -0,0 +1,362 @@
'use strict'
const which = require('which')
const fs = require('fs-extra')
const path = require('path')
const environment = require('./environment')
const Dist = require('./dist')
const CMLog = require('./cmLog')
const TargetOptions = require('./targetOptions')
const processHelpers = require('./processHelpers')
const locateNAN = require('./locateNAN')
const locateNodeApi = require('./locateNodeApi')
const npmConfigData = require('rc')('npm')
const Toolset = require('./toolset')
const headers = require('node-api-headers')
class CMake {
get path() {
return this.options.cmakePath || 'cmake'
}
get isAvailable() {
if (this._isAvailable === null) {
this._isAvailable = CMake.isAvailable(this.options)
}
return this._isAvailable
}
constructor(options) {
this.options = options || {}
this.log = new CMLog(this.options)
this.dist = new Dist(this.options)
this.projectRoot = path.resolve(this.options.directory || process.cwd())
this.workDir = path.resolve(this.options.out || path.join(this.projectRoot, 'build'))
this.config = this.options.config || (this.options.debug ? 'Debug' : 'Release')
this.buildDir = path.join(this.workDir, this.config)
this._isAvailable = null
this.targetOptions = new TargetOptions(this.options)
this.toolset = new Toolset(this.options)
this.cMakeOptions = this.options.cMakeOptions || {}
this.extraCMakeArgs = this.options.extraCMakeArgs || []
this.silent = !!options.silent
}
static isAvailable(options) {
options = options || {}
try {
if (options.cmakePath) {
const stat = fs.lstatSync(options.cmakePath)
return !stat.isDirectory()
} else {
which.sync('cmake')
return true
}
} catch (e) {
// Ignore
}
return false
}
static async getGenerators(options, log) {
const arch = ' [arch]'
options = options || {}
const gens = []
if (CMake.isAvailable(options)) {
// try parsing machine-readable capabilities (available since CMake 3.7)
try {
const stdout = await processHelpers.execFile([options.cmakePath || 'cmake', '-E', 'capabilities'])
const capabilities = JSON.parse(stdout)
return capabilities.generators.map((x) => x.name)
} catch (error) {
if (log) {
log.verbose('TOOL', 'Failed to query CMake capabilities (CMake is probably older than 3.7)')
}
}
// fall back to parsing help text
const stdout = await processHelpers.execFile([options.cmakePath || 'cmake', '--help'])
const hasCr = stdout.includes('\r\n')
const output = hasCr ? stdout.split('\r\n') : stdout.split('\n')
let on = false
output.forEach(function (line, i) {
if (on) {
const parts = line.split('=')
if (
(parts.length === 2 && parts[0].trim()) ||
(parts.length === 1 && i !== output.length - 1 && output[i + 1].trim()[0] === '=')
) {
let gen = parts[0].trim()
if (gen.endsWith(arch)) {
gen = gen.substr(0, gen.length - arch.length)
}
gens.push(gen)
}
}
if (line.trim() === 'Generators') {
on = true
}
})
} else {
throw new Error('CMake is not installed. Install CMake.')
}
return gens
}
verifyIfAvailable() {
if (!this.isAvailable) {
throw new Error(
"CMake executable is not found. Please use your system's package manager to install it, or you can get installers from there: http://cmake.org.",
)
}
}
async getConfigureCommand() {
// Create command:
let command = [this.path, this.projectRoot, '--no-warn-unused-cli']
const D = []
// CMake.js watermark
D.push({ CMAKE_JS_VERSION: environment.cmakeJsVersion })
// Build configuration:
D.push({ CMAKE_BUILD_TYPE: this.config })
if (environment.isWin) {
D.push({ CMAKE_RUNTIME_OUTPUT_DIRECTORY: this.workDir })
} else if (this.workDir.endsWith(this.config)) {
D.push({ CMAKE_LIBRARY_OUTPUT_DIRECTORY: this.workDir })
} else {
D.push({ CMAKE_LIBRARY_OUTPUT_DIRECTORY: this.buildDir })
}
// In some configurations MD builds will crash upon attempting to free memory.
// This tries to encourage MT builds which are larger but less likely to have this crash.
D.push({ CMAKE_MSVC_RUNTIME_LIBRARY: 'MultiThreaded$<$<CONFIG:Debug>:Debug>' })
// Includes:
const includesString = await this.getCmakeJsIncludeString()
D.push({ CMAKE_JS_INC: includesString })
// Sources:
const srcsString = this.getCmakeJsSrcString()
D.push({ CMAKE_JS_SRC: srcsString })
// Runtime:
D.push({ NODE_RUNTIME: this.targetOptions.runtime })
D.push({ NODE_RUNTIMEVERSION: this.targetOptions.runtimeVersion })
D.push({ NODE_ARCH: this.targetOptions.arch })
if (environment.isOSX) {
if (this.targetOptions.arch) {
let xcodeArch = this.targetOptions.arch
if (xcodeArch === 'x64') xcodeArch = 'x86_64'
D.push({ CMAKE_OSX_ARCHITECTURES: xcodeArch })
}
}
// Custom options
for (const [key, value] of Object.entries(this.cMakeOptions)) {
D.push({ [key]: value })
}
// Toolset:
await this.toolset.initialize(false)
const libsString = this.getCmakeJsLibString()
D.push({ CMAKE_JS_LIB: libsString })
if (environment.isWin) {
const nodeLibDefPath = this.getNodeLibDefPath()
if (nodeLibDefPath) {
const nodeLibPath = path.join(this.workDir, 'node.lib')
D.push({ CMAKE_JS_NODELIB_DEF: nodeLibDefPath })
D.push({ CMAKE_JS_NODELIB_TARGET: nodeLibPath })
}
}
if (this.toolset.generator) {
command.push('-G', this.toolset.generator)
}
if (this.toolset.platform) {
command.push('-A', this.toolset.platform)
}
if (this.toolset.toolset) {
command.push('-T', this.toolset.toolset)
}
if (this.toolset.cppCompilerPath) {
D.push({ CMAKE_CXX_COMPILER: this.toolset.cppCompilerPath })
}
if (this.toolset.cCompilerPath) {
D.push({ CMAKE_C_COMPILER: this.toolset.cCompilerPath })
}
if (this.toolset.compilerFlags.length) {
D.push({ CMAKE_CXX_FLAGS: this.toolset.compilerFlags.join(' ') })
}
if (this.toolset.linkerFlags.length) {
D.push({ CMAKE_SHARED_LINKER_FLAGS: this.toolset.linkerFlags.join(' ') })
}
if (this.toolset.makePath) {
D.push({ CMAKE_MAKE_PROGRAM: this.toolset.makePath })
}
// Load NPM config
for (const [key, value] of Object.entries(npmConfigData)) {
if (key.startsWith('cmake_')) {
const sk = key.substr(6)
if (sk && value) {
D.push({ [sk]: value })
}
}
}
command = command.concat(
D.map(function (p) {
return '-D' + Object.keys(p)[0] + '=' + Object.values(p)[0]
}),
)
return command.concat(this.extraCMakeArgs)
}
getCmakeJsLibString() {
const libs = []
if (environment.isWin) {
const nodeLibDefPath = this.getNodeLibDefPath()
if (nodeLibDefPath) {
libs.push(path.join(this.workDir, 'node.lib'))
} else {
libs.push(...this.dist.winLibs)
}
}
return libs.join(';')
}
async getCmakeJsIncludeString() {
let incPaths = []
if (!this.options.isNodeApi) {
// Include and lib:
if (this.dist.headerOnly) {
incPaths = [path.join(this.dist.internalPath, '/include/node')]
} else {
const nodeH = path.join(this.dist.internalPath, '/src')
const v8H = path.join(this.dist.internalPath, '/deps/v8/include')
const uvH = path.join(this.dist.internalPath, '/deps/uv/include')
incPaths = [nodeH, v8H, uvH]
}
// NAN
const nanH = await locateNAN(this.projectRoot)
if (nanH) {
incPaths.push(nanH)
}
} else {
// Base headers
const apiHeaders = require('node-api-headers')
incPaths.push(apiHeaders.include_dir)
// Node-api
const napiH = await locateNodeApi(this.projectRoot)
if (napiH) {
incPaths.push(napiH)
}
}
return incPaths.join(';')
}
getCmakeJsSrcString() {
const srcPaths = []
if (environment.isWin) {
const delayHook = path.normalize(path.join(__dirname, 'cpp', 'win_delay_load_hook.cc'))
srcPaths.push(delayHook.replace(/\\/gm, '/'))
}
return srcPaths.join(';')
}
getNodeLibDefPath() {
return environment.isWin && this.options.isNodeApi ? headers.def_paths.node_api_def : undefined
}
async configure() {
this.verifyIfAvailable()
this.log.info('CMD', 'CONFIGURE')
const listPath = path.join(this.projectRoot, 'CMakeLists.txt')
const command = await this.getConfigureCommand()
try {
await fs.lstat(listPath)
} catch (e) {
throw new Error("'" + listPath + "' not found.")
}
try {
await fs.ensureDir(this.workDir)
} catch (e) {
// Ignore
}
const cwd = process.cwd()
process.chdir(this.workDir)
try {
await this._run(command)
} finally {
process.chdir(cwd)
}
}
async ensureConfigured() {
try {
await fs.lstat(path.join(this.workDir, 'CMakeCache.txt'))
} catch (e) {
await this.configure()
}
}
getBuildCommand() {
const command = [this.path, '--build', this.workDir, '--config', this.config]
if (this.options.target) {
command.push('--target', this.options.target)
}
if (this.options.parallel) {
command.push('--parallel', this.options.parallel)
}
return Promise.resolve(command.concat(this.extraCMakeArgs))
}
async build() {
this.verifyIfAvailable()
await this.ensureConfigured()
const buildCommand = await this.getBuildCommand()
this.log.info('CMD', 'BUILD')
await this._run(buildCommand)
}
getCleanCommand() {
return [this.path, '-E', 'remove_directory', this.workDir].concat(this.extraCMakeArgs)
}
clean() {
this.verifyIfAvailable()
this.log.info('CMD', 'CLEAN')
return this._run(this.getCleanCommand())
}
async reconfigure() {
this.extraCMakeArgs = []
await this.clean()
await this.configure()
}
async rebuild() {
this.extraCMakeArgs = []
await this.clean()
await this.build()
}
async compile() {
this.extraCMakeArgs = []
try {
await this.build()
} catch (e) {
this.log.info('REP', 'Build has been failed, trying to do a full rebuild.')
await this.rebuild()
}
}
_run(command) {
this.log.info('RUN', command)
return processHelpers.run(command, { silent: this.silent })
}
async getGenerators() {
return CMake.getGenerators(this.options, this.log)
}
}
module.exports = CMake

61
node_modules/cmake-js/lib/cmLog.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
'use strict'
const log = require('./logger')
class CMLog {
get level() {
if (this.options.noLog) {
return 'silly'
} else {
return log.level
}
}
constructor(options) {
this.options = options || {}
this.debug = require('debug')(this.options.logName || 'cmake-js')
}
silly(cat, msg) {
if (this.options.noLog) {
this.debug(cat + ': ' + msg)
} else {
log.silly(cat, msg)
}
}
verbose(cat, msg) {
if (this.options.noLog) {
this.debug(cat + ': ' + msg)
} else {
log.verbose(cat, msg)
}
}
info(cat, msg) {
if (this.options.noLog) {
this.debug(cat + ': ' + msg)
} else {
log.info(cat, msg)
}
}
warn(cat, msg) {
if (this.options.noLog) {
this.debug(cat + ': ' + msg)
} else {
log.warn(cat, msg)
}
}
http(cat, msg) {
if (this.options.noLog) {
this.debug(cat + ': ' + msg)
} else {
log.http(cat, msg)
}
}
error(cat, msg) {
if (this.options.noLog) {
this.debug(cat + ': ' + msg)
} else {
log.error(cat, msg)
}
}
}
module.exports = CMLog

52
node_modules/cmake-js/lib/cpp/win_delay_load_hook.cc generated vendored Normal file
View File

@@ -0,0 +1,52 @@
/*
* When this file is linked to a DLL, it sets up a delay-load hook that
* intervenes when the DLL is trying to load 'node.exe' or 'iojs.exe'
* dynamically. Instead of trying to locate the .exe file it'll just return
* a handle to the process image.
*
* This allows compiled addons to work when node.exe or iojs.exe is renamed.
*/
#ifdef _MSC_VER
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <delayimp.h>
#include <string.h>
static HMODULE node_dll = NULL;
static HMODULE nw_dll = NULL;
static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) {
if (event == dliNotePreGetProcAddress) {
FARPROC ret = NULL;
ret = GetProcAddress(node_dll, info->dlp.szProcName);
if (ret)
return ret;
ret = GetProcAddress(nw_dll, info->dlp.szProcName);
return ret;
}
if (event == dliStartProcessing) {
node_dll = GetModuleHandleA("node.dll");
nw_dll = GetModuleHandleA("nw.dll");
return NULL;
}
if (event != dliNotePreLoadLibrary)
return NULL;
if (_stricmp(info->szDll, "node.exe") != 0)
return NULL;
// Fall back to the current process
if(!node_dll) node_dll = GetModuleHandleA(NULL);
return (FARPROC) node_dll;
}
decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook;
#endif

176
node_modules/cmake-js/lib/dist.js generated vendored Normal file
View File

@@ -0,0 +1,176 @@
'use strict'
const environment = require('./environment')
const path = require('path')
const urljoin = require('url-join')
const fs = require('fs-extra')
const CMLog = require('./cmLog')
const TargetOptions = require('./targetOptions')
const runtimePaths = require('./runtimePaths')
const Downloader = require('./downloader')
const os = require('os')
function testSum(sums, sum, fPath) {
const serverSum = sums.find(function (s) {
return s.getPath === fPath
})
if (serverSum && serverSum.sum === sum) {
return
}
throw new Error("SHA sum of file '" + fPath + "' mismatch!")
}
class Dist {
get internalPath() {
const cacheDirectory = '.cmake-js'
const runtimeArchDirectory = this.targetOptions.runtime + '-' + this.targetOptions.arch
const runtimeVersionDirectory = 'v' + this.targetOptions.runtimeVersion
return (
this.options.runtimeDirectory ||
path.join(os.homedir(), cacheDirectory, runtimeArchDirectory, runtimeVersionDirectory)
)
}
get externalPath() {
return runtimePaths.get(this.targetOptions).externalPath
}
get downloaded() {
let headers = false
let libs = true
let stat = getStat(this.internalPath)
if (stat.isDirectory()) {
if (this.headerOnly) {
stat = getStat(path.join(this.internalPath, 'include/node/node.h'))
headers = stat.isFile()
} else {
stat = getStat(path.join(this.internalPath, 'src/node.h'))
if (stat.isFile()) {
stat = getStat(path.join(this.internalPath, 'deps/v8/include/v8.h'))
headers = stat.isFile()
}
}
if (environment.isWin) {
for (const libPath of this.winLibs) {
stat = getStat(libPath)
libs = libs && stat.isFile()
}
}
}
return headers && libs
function getStat(path) {
try {
return fs.statSync(path)
} catch (e) {
return {
isFile: () => false,
isDirectory: () => false,
}
}
}
}
get winLibs() {
const libs = runtimePaths.get(this.targetOptions).winLibs
const result = []
for (const lib of libs) {
result.push(path.join(this.internalPath, lib.dir, lib.name))
}
return result
}
get headerOnly() {
return runtimePaths.get(this.targetOptions).headerOnly
}
constructor(options) {
this.options = options || {}
this.log = new CMLog(this.options)
this.targetOptions = new TargetOptions(this.options)
this.downloader = new Downloader(this.options)
}
async ensureDownloaded() {
if (!this.downloaded) {
await this.download()
}
}
async download() {
const log = this.log
log.info('DIST', 'Downloading distribution files to: ' + this.internalPath)
await fs.ensureDir(this.internalPath)
const sums = await this._downloadShaSums()
await Promise.all([this._downloadLibs(sums), this._downloadTar(sums)])
}
async _downloadShaSums() {
if (this.targetOptions.runtime === 'node') {
const sumUrl = urljoin(this.externalPath, 'SHASUMS256.txt')
const log = this.log
log.http('DIST', '\t- ' + sumUrl)
return (await this.downloader.downloadString(sumUrl))
.split('\n')
.map(function (line) {
const parts = line.split(/\s+/)
return {
getPath: parts[1],
sum: parts[0],
}
})
.filter(function (i) {
return i.getPath && i.sum
})
} else {
return null
}
}
async _downloadTar(sums) {
const log = this.log
const self = this
const tarLocalPath = runtimePaths.get(self.targetOptions).tarPath
const tarUrl = urljoin(self.externalPath, tarLocalPath)
log.http('DIST', '\t- ' + tarUrl)
const sum = await this.downloader.downloadTgz(tarUrl, {
hash: sums ? 'sha256' : null,
cwd: self.internalPath,
strip: 1,
filter: function (entryPath) {
if (entryPath === self.internalPath) {
return true
}
const ext = path.extname(entryPath)
return ext && ext.toLowerCase() === '.h'
},
})
if (sums) {
testSum(sums, sum, tarLocalPath)
}
}
async _downloadLibs(sums) {
const log = this.log
const self = this
if (!environment.isWin) {
return
}
const paths = runtimePaths.get(self.targetOptions)
for (const dirs of paths.winLibs) {
const subDir = dirs.dir
const fn = dirs.name
const fPath = subDir ? urljoin(subDir, fn) : fn
const libUrl = urljoin(self.externalPath, fPath)
log.http('DIST', '\t- ' + libUrl)
await fs.ensureDir(path.join(self.internalPath, subDir))
const sum = await this.downloader.downloadFile(libUrl, {
path: path.join(self.internalPath, fPath),
hash: sums ? 'sha256' : null,
})
if (sums) {
testSum(sums, sum, fPath)
}
}
}
}
module.exports = Dist

99
node_modules/cmake-js/lib/downloader.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
'use strict'
const crypto = require('crypto')
const { Readable } = require('node:stream')
const zlib = require('zlib')
const tar = require('tar')
const fs = require('fs')
const CMLog = require('./cmLog')
class Downloader {
constructor(options) {
this.options = options || {}
this.log = new CMLog(this.options)
}
downloadToStream(url, stream, hash) {
const self = this
const shasum = hash ? crypto.createHash(hash) : null
return new Promise(function (resolve, reject) {
let length = 0
let done = 0
let lastPercent = 0
fetch(url)
.then(function (response) {
if (!response.ok) {
throw new Error(response.statusText || 'Request failed')
}
length = parseInt(response.headers.get('content-length'))
if (Number.isNaN(length)) {
length = 0
}
const readable = Readable.fromWeb(response.body)
readable.on('data', function (chunk) {
if (shasum) {
shasum.update(chunk)
}
if (length) {
done += chunk.length
let percent = (done / length) * 100
percent = Math.round(percent / 10) * 10 + 10
if (percent > lastPercent) {
self.log.verbose('DWNL', '\t' + lastPercent + '%')
lastPercent = percent
}
}
})
readable.pipe(stream)
readable.on('error', function (err) {
reject(err)
})
})
.catch(function (err) {
reject(err)
})
stream.once('error', function (err) {
reject(err)
})
stream.once('finish', function () {
resolve(shasum ? shasum.digest('hex') : undefined)
})
})
}
async downloadString(url) {
const response = await fetch(url)
if (!response.ok) {
throw new Error(response.statusText || 'Request failed')
}
return response.text()
}
async downloadFile(url, options) {
if (typeof options === 'string') {
options.path = options
}
const result = fs.createWriteStream(options.path)
const sum = await this.downloadToStream(url, result, options.hash)
this.testSum(url, sum, options)
return sum
}
async downloadTgz(url, options) {
if (typeof options === 'string') {
options.cwd = options
}
const gunzip = zlib.createGunzip()
const extractor = tar.extract(options)
gunzip.pipe(extractor)
const sum = await this.downloadToStream(url, gunzip, options.hash)
this.testSum(url, sum, options)
return sum
}
testSum(url, sum, options) {
if (options.hash && sum && options.sum && options.sum !== sum) {
throw new Error(options.hash.toUpperCase() + " sum of download '" + url + "' mismatch!")
}
}
}
module.exports = Downloader

97
node_modules/cmake-js/lib/environment.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
'use strict'
const os = require('os')
const which = require('which')
const environment = (module.exports = {
cmakeJsVersion: require('../package.json').version,
platform: os.platform(),
isWin: os.platform() === 'win32',
isLinux: os.platform() === 'linux',
isOSX: os.platform() === 'darwin',
arch: os.arch(),
isX86: os.arch() === 'ia32' || os.arch() === 'x86',
isX64: os.arch() === 'x64',
isArm: os.arch() === 'arm',
isArm64: os.arch() === 'arm64',
runtime: 'node',
runtimeVersion: process.versions.node,
})
Object.defineProperties(environment, {
_isNinjaAvailable: {
value: null,
writable: true,
},
isNinjaAvailable: {
get: function () {
if (this._isNinjaAvailable === null) {
this._isNinjaAvailable = false
try {
if (which.sync('ninja')) {
this._isNinjaAvailable = true
}
} catch (e) {
// Ignore
}
}
return this._isNinjaAvailable
},
},
_isMakeAvailable: {
value: null,
writable: true,
},
isMakeAvailable: {
get: function () {
if (this._isMakeAvailable === null) {
this._isMakeAvailable = false
try {
if (which.sync('make')) {
this._isMakeAvailable = true
}
} catch (e) {
// Ignore
}
}
return this._isMakeAvailable
},
},
_isGPPAvailable: {
value: null,
writable: true,
},
isGPPAvailable: {
get: function () {
if (this._isGPPAvailable === null) {
this._isGPPAvailable = false
try {
if (which.sync('g++')) {
this._isGPPAvailable = true
}
} catch (e) {
// Ignore
}
}
return this._isGPPAvailable
},
},
_isClangAvailable: {
value: null,
writable: true,
},
isClangAvailable: {
get: function () {
if (this._isClangAvailable === null) {
this._isClangAvailable = false
try {
if (which.sync('clang++')) {
this._isClangAvailable = true
}
} catch (e) {
// Ignore
}
}
return this._isClangAvailable
},
},
})

250
node_modules/cmake-js/lib/import/Find-VisualStudio.cs generated vendored Normal file
View File

@@ -0,0 +1,250 @@
// Copyright 2017 - Refael Ackermann
// Distributed under MIT style license
// See accompanying file LICENSE at https://github.com/node4good/windows-autoconf
// Usage:
// powershell -ExecutionPolicy Unrestricted -Command "Add-Type -Path Find-VisualStudio.cs; [VisualStudioConfiguration.Main]::PrintJson()"
// This script needs to be compatible with PowerShell v2 to run on Windows 2008R2 and Windows 7.
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Collections.Generic;
namespace VisualStudioConfiguration
{
[Flags]
public enum InstanceState : uint
{
None = 0,
Local = 1,
Registered = 2,
NoRebootRequired = 4,
NoErrors = 8,
Complete = 4294967295,
}
[Guid("6380BCFF-41D3-4B2E-8B2E-BF8A6810C848")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
public interface IEnumSetupInstances
{
void Next([MarshalAs(UnmanagedType.U4), In] int celt,
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface), Out] ISetupInstance[] rgelt,
[MarshalAs(UnmanagedType.U4)] out int pceltFetched);
void Skip([MarshalAs(UnmanagedType.U4), In] int celt);
void Reset();
[return: MarshalAs(UnmanagedType.Interface)]
IEnumSetupInstances Clone();
}
[Guid("42843719-DB4C-46C2-8E7C-64F1816EFD5B")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
public interface ISetupConfiguration
{
}
[Guid("26AAB78C-4A60-49D6-AF3B-3C35BC93365D")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
public interface ISetupConfiguration2 : ISetupConfiguration
{
[return: MarshalAs(UnmanagedType.Interface)]
IEnumSetupInstances EnumInstances();
[return: MarshalAs(UnmanagedType.Interface)]
ISetupInstance GetInstanceForCurrentProcess();
[return: MarshalAs(UnmanagedType.Interface)]
ISetupInstance GetInstanceForPath([MarshalAs(UnmanagedType.LPWStr), In] string path);
[return: MarshalAs(UnmanagedType.Interface)]
IEnumSetupInstances EnumAllInstances();
}
[Guid("B41463C3-8866-43B5-BC33-2B0676F7F42E")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
public interface ISetupInstance
{
}
[Guid("89143C9A-05AF-49B0-B717-72E218A2185C")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
public interface ISetupInstance2 : ISetupInstance
{
[return: MarshalAs(UnmanagedType.BStr)]
string GetInstanceId();
[return: MarshalAs(UnmanagedType.Struct)]
System.Runtime.InteropServices.ComTypes.FILETIME GetInstallDate();
[return: MarshalAs(UnmanagedType.BStr)]
string GetInstallationName();
[return: MarshalAs(UnmanagedType.BStr)]
string GetInstallationPath();
[return: MarshalAs(UnmanagedType.BStr)]
string GetInstallationVersion();
[return: MarshalAs(UnmanagedType.BStr)]
string GetDisplayName([MarshalAs(UnmanagedType.U4), In] int lcid);
[return: MarshalAs(UnmanagedType.BStr)]
string GetDescription([MarshalAs(UnmanagedType.U4), In] int lcid);
[return: MarshalAs(UnmanagedType.BStr)]
string ResolvePath([MarshalAs(UnmanagedType.LPWStr), In] string pwszRelativePath);
[return: MarshalAs(UnmanagedType.U4)]
InstanceState GetState();
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)]
ISetupPackageReference[] GetPackages();
ISetupPackageReference GetProduct();
[return: MarshalAs(UnmanagedType.BStr)]
string GetProductPath();
[return: MarshalAs(UnmanagedType.VariantBool)]
bool IsLaunchable();
[return: MarshalAs(UnmanagedType.VariantBool)]
bool IsComplete();
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_UNKNOWN)]
ISetupPropertyStore GetProperties();
[return: MarshalAs(UnmanagedType.BStr)]
string GetEnginePath();
}
[Guid("DA8D8A16-B2B6-4487-A2F1-594CCCCD6BF5")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
public interface ISetupPackageReference
{
[return: MarshalAs(UnmanagedType.BStr)]
string GetId();
[return: MarshalAs(UnmanagedType.BStr)]
string GetVersion();
[return: MarshalAs(UnmanagedType.BStr)]
string GetChip();
[return: MarshalAs(UnmanagedType.BStr)]
string GetLanguage();
[return: MarshalAs(UnmanagedType.BStr)]
string GetBranch();
[return: MarshalAs(UnmanagedType.BStr)]
string GetType();
[return: MarshalAs(UnmanagedType.BStr)]
string GetUniqueId();
[return: MarshalAs(UnmanagedType.VariantBool)]
bool GetIsExtension();
}
[Guid("c601c175-a3be-44bc-91f6-4568d230fc83")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
public interface ISetupPropertyStore
{
[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)]
string[] GetNames();
object GetValue([MarshalAs(UnmanagedType.LPWStr), In] string pwszName);
}
[Guid("42843719-DB4C-46C2-8E7C-64F1816EFD5B")]
[CoClass(typeof(SetupConfigurationClass))]
[ComImport]
public interface SetupConfiguration : ISetupConfiguration2, ISetupConfiguration
{
}
[Guid("177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D")]
[ClassInterface(ClassInterfaceType.None)]
[ComImport]
public class SetupConfigurationClass
{
}
public static class Main
{
public static void PrintJson()
{
ISetupConfiguration query = new SetupConfiguration();
ISetupConfiguration2 query2 = (ISetupConfiguration2)query;
IEnumSetupInstances e = query2.EnumAllInstances();
int pceltFetched;
ISetupInstance2[] rgelt = new ISetupInstance2[1];
List<string> instances = new List<string>();
while (true)
{
e.Next(1, rgelt, out pceltFetched);
if (pceltFetched <= 0)
{
Console.WriteLine(String.Format("[{0}]", string.Join(",", instances.ToArray())));
return;
}
try
{
instances.Add(InstanceJson(rgelt[0]));
}
catch (COMException)
{
// Ignore instances that can't be queried.
}
}
}
private static string JsonString(string s)
{
return "\"" + s.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
}
private static string InstanceJson(ISetupInstance2 setupInstance2)
{
// Visual Studio component directory:
// https://docs.microsoft.com/en-us/visualstudio/install/workload-and-component-ids
StringBuilder json = new StringBuilder();
json.Append("{");
string path = JsonString(setupInstance2.GetInstallationPath());
json.Append(String.Format("\"path\":{0},", path));
string version = JsonString(setupInstance2.GetInstallationVersion());
json.Append(String.Format("\"version\":{0},", version));
List<string> packages = new List<string>();
foreach (ISetupPackageReference package in setupInstance2.GetPackages())
{
string id = JsonString(package.GetId());
packages.Add(id);
}
json.Append(String.Format("\"packages\":[{0}]", string.Join(",", packages.ToArray())));
json.Append("}");
return json.ToString();
}
}
}

24
node_modules/cmake-js/lib/import/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,24 @@
(The MIT License)
Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

6
node_modules/cmake-js/lib/import/README generated vendored Normal file
View File

@@ -0,0 +1,6 @@
This is a copy of some files from node-gyp, with some minor modifications.
Currently based on v10.0.1
node-gyp has a decent strategy for finding Visual Studio, and has a lot more developer time behind them to make a good and robust solution.
We may as well benefit from their solution than reinvent it

598
node_modules/cmake-js/lib/import/find-visualstudio.js generated vendored Normal file
View File

@@ -0,0 +1,598 @@
'use strict'
const log = require('../logger')
const { existsSync } = require('fs')
const { win32: path } = require('path')
const { regSearchKeys, execFile, logWithPrefix } = require('./util')
const semver = require('semver')
class VisualStudioFinder {
static findVisualStudio = (...args) => new VisualStudioFinder(...args).findVisualStudio()
log = logWithPrefix(log, 'find VS')
regSearchKeys = regSearchKeys
constructor(nodeSemver, configMsvsVersion) {
this.nodeSemver = nodeSemver
this.configMsvsVersion = configMsvsVersion
this.errorLog = []
this.validVersions = []
}
// Logs a message at verbose level, but also saves it to be displayed later
// at error level if an error occurs. This should help diagnose the problem.
addLog(message) {
this.log.verbose(message)
this.errorLog.push(message)
}
async findVisualStudio() {
this.configVersionYear = null
this.configPath = null
if (this.configMsvsVersion) {
this.addLog('msvs_version was set from command line or npm config')
if (this.configMsvsVersion.match(/^\d{4}$/)) {
this.configVersionYear = parseInt(this.configMsvsVersion, 10)
this.addLog(`- looking for Visual Studio version ${this.configVersionYear}`)
} else {
this.configPath = path.resolve(this.configMsvsVersion)
this.addLog(`- looking for Visual Studio installed in "${this.configPath}"`)
}
} else {
this.addLog('msvs_version not set from command line or npm config')
}
if (process.env.VCINSTALLDIR) {
this.envVcInstallDir = path.resolve(process.env.VCINSTALLDIR, '..')
this.addLog(
'running in VS Command Prompt, installation path is:\n' +
`"${this.envVcInstallDir}"\n- will only use this version`,
)
} else {
this.addLog('VCINSTALLDIR not set, not running in VS Command Prompt')
}
const checks = [
() => this.findVisualStudio2019OrNewerFromSpecifiedLocation(),
() => this.findVisualStudio2019OrNewerUsingSetupModule(),
() => this.findVisualStudio2019OrNewer(),
() => this.findVisualStudio2017FromSpecifiedLocation(),
() => this.findVisualStudio2017UsingSetupModule(),
() => this.findVisualStudio2017(),
() => this.findVisualStudio2015(),
() => this.findVisualStudio2013(),
]
for (const check of checks) {
const info = await check()
if (info) {
return this.succeed(info)
}
}
return this.fail()
}
succeed(info) {
this.log.info(
`using VS${info.versionYear} (${info.version}) found at:` +
`\n"${info.path}"` +
'\nrun with --verbose for detailed information',
)
return info
}
fail() {
if (this.configMsvsVersion && this.envVcInstallDir) {
this.errorLog.push('msvs_version does not match this VS Command Prompt or the', 'installation cannot be used.')
} else if (this.configMsvsVersion) {
// If msvs_version was specified but finding VS failed, print what would
// have been accepted
this.errorLog.push('')
if (this.validVersions) {
this.errorLog.push('valid versions for msvs_version:')
this.validVersions.forEach((version) => {
this.errorLog.push(`- "${version}"`)
})
} else {
this.errorLog.push('no valid versions for msvs_version were found')
}
}
const errorLog = this.errorLog.join('\n')
// For Windows 80 col console, use up to the column before the one marked
// with X (total 79 chars including logger prefix, 62 chars usable here):
// X
const infoLog = [
'**************************************************************',
'You need to install the latest version of Visual Studio',
'including the "Desktop development with C++" workload.',
'For more information consult the documentation at:',
'https://github.com/nodejs/node-gyp#on-windows',
'**************************************************************',
].join('\n')
this.log.error(`\n${errorLog}\n\n${infoLog}\n`)
throw new Error('Could not find any Visual Studio installation to use')
}
async findVisualStudio2019OrNewerFromSpecifiedLocation() {
return this.findVSFromSpecifiedLocation([2019, 2022, 2026])
}
async findVisualStudio2017FromSpecifiedLocation() {
if (semver.gte(this.nodeSemver, '22.0.0')) {
this.addLog('not looking for VS2017 as it is only supported up to Node.js 21')
return null
}
return this.findVSFromSpecifiedLocation([2017])
}
async findVSFromSpecifiedLocation(supportedYears) {
if (!this.envVcInstallDir) {
return null
}
const info = {
path: path.resolve(this.envVcInstallDir),
// Assume the version specified by the user is correct.
// Since Visual Studio 2015, the Developer Command Prompt sets the
// VSCMD_VER environment variable which contains the version information
// for Visual Studio.
// https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022
version: process.env.VSCMD_VER,
packages: [
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
'Microsoft.VisualStudio.Component.VC.Tools.ARM64',
// Assume MSBuild exists. It will be checked in processing.
'Microsoft.VisualStudio.VC.MSBuild.Base',
],
}
// Is there a better way to get SDK information?
const envWindowsSDKVersion = process.env.WindowsSDKVersion
const sdkVersionMatched = envWindowsSDKVersion?.match(/^(\d+)\.(\d+)\.(\d+)\..*/)
if (sdkVersionMatched) {
info.packages.push(`Microsoft.VisualStudio.Component.Windows10SDK.${sdkVersionMatched[3]}.Desktop`)
}
// pass for further processing
return this.processData([info], supportedYears)
}
async findVisualStudio2019OrNewerUsingSetupModule() {
return this.findNewVSUsingSetupModule([2019, 2022, 2026])
}
async findVisualStudio2017UsingSetupModule() {
if (semver.gte(this.nodeSemver, '22.0.0')) {
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, 2026])
}
// Invoke the PowerShell script to get information about Visual Studio 2017
async findVisualStudio2017() {
if (semver.gte(this.nodeSemver, '22.0.0')) {
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 findNewVS(supportedYears) {
const ps = path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')
const csFile = path.join(__dirname, 'Find-VisualStudio.cs')
const psArgs = [
'-ExecutionPolicy',
'Unrestricted',
'-NoProfile',
'-Command',
"&{Add-Type -Path '" + csFile + "';" + '[VisualStudioConfiguration.Main]::PrintJson()}',
]
this.log.silly('Running', ps, psArgs)
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, 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 = (failureDetails) => {
this.addLog(
`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(`${err}`.substring(0, 40))
}
let vsInfo
try {
vsInfo = JSON.parse(stdout)
} catch (e) {
this.log.silly('PS stdout = %j', stdout)
this.log.silly(e)
return failPowershell()
}
if (sanityOptions.checkIsArray && !Array.isArray(vsInfo)) {
this.log.silly('PS stdout = %j', stdout)
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)
const ret = this.getVersionInfo(info)
ret.path = info.path
ret.msBuild = this.getMSBuild(info, ret.versionYear)
ret.toolset = this.getToolset(info, ret.versionYear)
ret.sdk = this.getSDK(info)
return ret
})
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 && supportedYears.indexOf(info.versionYear) !== -1) {
return true
}
this.addLog(`${info.versionYear ? 'unsupported' : 'unknown'} version "${info.version}" found at "${info.path}"`)
return false
})
// Sort to place newer versions first
vsInfo.sort((a, b) => b.versionYear - a.versionYear)
for (let i = 0; i < vsInfo.length; ++i) {
const info = vsInfo[i]
this.addLog(`checking VS${info.versionYear} (${info.version}) found ` + `at:\n"${info.path}"`)
if (info.msBuild) {
this.addLog('- found "Visual Studio C++ core features"')
} else {
this.addLog('- "Visual Studio C++ core features" missing')
continue
}
if (info.toolset) {
this.addLog(`- found VC++ toolset: ${info.toolset}`)
} else {
this.addLog('- missing any VC++ toolset')
continue
}
if (info.sdk) {
this.addLog(`- found Windows SDK: ${info.sdk}`)
} else {
this.addLog('- missing any Windows SDK')
continue
}
if (!this.checkConfigVersion(info.versionYear, info.path)) {
continue
}
return info
}
this.addLog('could not find a version of Visual Studio 2017 or newer to use')
return null
}
// Helper - process version information
getVersionInfo(info) {
const match = /^(\d+)\.(\d+)(?:\..*)?/.exec(info.version)
if (!match) {
this.log.silly('- failed to parse version:', info.version)
return {}
}
this.log.silly('- version match = %j', match)
const ret = {
version: info.version,
versionMajor: parseInt(match[1], 10),
versionMinor: parseInt(match[2], 10),
}
if (ret.versionMajor === 15) {
ret.versionYear = 2017
return ret
}
if (ret.versionMajor === 16) {
ret.versionYear = 2019
return ret
}
if (ret.versionMajor === 17) {
ret.versionYear = 2022
return ret
}
if (ret.versionMajor === 18) {
ret.versionYear = 2026
return ret
}
this.log.silly('- unsupported version:', ret.versionMajor)
return {}
}
msBuildPathExists(path) {
return existsSync(path)
}
// Helper - process MSBuild information
getMSBuild(info, versionYear) {
const pkg = 'Microsoft.VisualStudio.VC.MSBuild.Base'
const msbuildPath = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
const msbuildPathArm64 = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'arm64', 'MSBuild.exe')
if (info.packages.indexOf(pkg) !== -1) {
this.log.silly('- found VC.MSBuild.Base')
if (versionYear === 2017) {
return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe')
}
if (versionYear === 2019) {
if (process.arch === 'arm64' && this.msBuildPathExists(msbuildPathArm64)) {
return msbuildPathArm64
} else {
return msbuildPath
}
}
}
/**
* Visual Studio 2022 doesn't have the MSBuild package.
* Support for compiling _on_ ARM64 was added in MSVC 14.32.31326,
* so let's leverage it if the user has an ARM64 device.
*/
if (process.arch === 'arm64' && this.msBuildPathExists(msbuildPathArm64)) {
return msbuildPathArm64
} else if (this.msBuildPathExists(msbuildPath)) {
return msbuildPath
}
return null
}
// Helper - process toolset information
getToolset(info, versionYear) {
const vcToolsArm64 = 'VC.Tools.ARM64'
const pkgArm64 = `Microsoft.VisualStudio.Component.${vcToolsArm64}`
const vcToolsX64 = 'VC.Tools.x86.x64'
const pkgX64 = `Microsoft.VisualStudio.Component.${vcToolsX64}`
const express = 'Microsoft.VisualStudio.WDExpress'
if (process.arch === 'arm64' && info.packages.includes(pkgArm64)) {
this.log.silly(`- found ${vcToolsArm64}`)
} else if (info.packages.includes(pkgX64)) {
if (process.arch === 'arm64') {
this.addLog(
`- found ${vcToolsX64} on ARM64 platform. Expect less performance and/or link failure with ARM64 binary.`,
)
} else {
this.log.silly(`- found ${vcToolsX64}`)
}
} else if (info.packages.includes(express)) {
this.log.silly('- found Visual Studio Express (looking for toolset)')
} else {
return null
}
if (versionYear === 2017) {
return 'v141'
} else if (versionYear === 2019) {
return 'v142'
} else if (versionYear === 2022) {
return 'v143'
} else if (versionYear === 2026) {
return 'v145'
}
this.log.silly('- invalid versionYear:', versionYear)
return null
}
// Helper - process Windows SDK information
getSDK(info) {
const win8SDK = 'Microsoft.VisualStudio.Component.Windows81SDK'
const win10SDKPrefix = 'Microsoft.VisualStudio.Component.Windows10SDK.'
const win11SDKPrefix = 'Microsoft.VisualStudio.Component.Windows11SDK.'
let Win10or11SDKVer = 0
info.packages.forEach((pkg) => {
if (!pkg.startsWith(win10SDKPrefix) && !pkg.startsWith(win11SDKPrefix)) {
return
}
const parts = pkg.split('.')
if (parts.length > 5 && parts[5] !== 'Desktop') {
this.log.silly('- ignoring non-Desktop Win10/11SDK:', pkg)
return
}
const foundSdkVer = parseInt(parts[4], 10)
if (isNaN(foundSdkVer)) {
// Microsoft.VisualStudio.Component.Windows10SDK.IpOverUsb
this.log.silly('- failed to parse Win10/11SDK number:', pkg)
return
}
this.log.silly('- found Win10/11SDK:', foundSdkVer)
Win10or11SDKVer = Math.max(Win10or11SDKVer, foundSdkVer)
})
if (Win10or11SDKVer !== 0) {
return `10.0.${Win10or11SDKVer}.0`
} else if (info.packages.indexOf(win8SDK) !== -1) {
this.log.silly('- found Win8SDK')
return '8.1'
}
return null
}
// Find an installation of Visual Studio 2015 to use
async findVisualStudio2015() {
if (semver.gte(this.nodeSemver, '19.0.0')) {
this.addLog('not looking for VS2015 as it is only supported up to Node.js 18')
return null
}
return this.findOldVS({
version: '14.0',
versionMajor: 14,
versionMinor: 0,
versionYear: 2015,
toolset: 'v140',
})
}
// Find an installation of Visual Studio 2013 to use
async findVisualStudio2013() {
if (semver.gte(this.nodeSemver, '9.0.0')) {
this.addLog('not looking for VS2013 as it is only supported up to Node.js 8')
return null
}
return this.findOldVS({
version: '12.0',
versionMajor: 12,
versionMinor: 0,
versionYear: 2013,
toolset: 'v120',
})
}
// Helper - common code for VS2013 and VS2015
async findOldVS(info) {
const regVC7 = [
'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7',
'HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7',
]
const regMSBuild = 'HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions'
this.addLog(`looking for Visual Studio ${info.versionYear}`)
try {
let res = await this.regSearchKeys(regVC7, info.version, [])
const vsPath = path.resolve(res, '..')
this.addLog(`- found in "${vsPath}"`)
const msBuildRegOpts = process.arch === 'ia32' ? [] : ['/reg:32']
try {
res = await this.regSearchKeys([`${regMSBuild}\\${info.version}`], 'MSBuildToolsPath', msBuildRegOpts)
} catch (err) {
this.addLog('- could not find MSBuild in registry for this version')
return null
}
const msBuild = path.join(res, 'MSBuild.exe')
this.addLog(`- MSBuild in "${msBuild}"`)
if (!this.checkConfigVersion(info.versionYear, vsPath)) {
return null
}
info.path = vsPath
info.msBuild = msBuild
info.sdk = null
return info
} catch (err) {
this.addLog('- not found')
return null
}
}
// After finding a usable version of Visual Studio:
// - add it to validVersions to be displayed at the end if a specific
// version was requested and not found;
// - check if this is the version that was requested.
// - check if this matches the Visual Studio Command Prompt
checkConfigVersion(versionYear, vsPath) {
this.validVersions.push(versionYear)
this.validVersions.push(vsPath)
if (this.configVersionYear && this.configVersionYear !== versionYear) {
this.addLog('- msvs_version does not match this version')
return false
}
if (this.configPath && path.relative(this.configPath, vsPath) !== '') {
this.addLog('- msvs_version does not point to this installation')
return false
}
if (this.envVcInstallDir && path.relative(this.envVcInstallDir, vsPath) !== '') {
this.addLog('- does not match this Visual Studio Command Prompt')
return false
}
return true
}
async execFile(exec, args) {
return await execFile(exec, args, { encoding: 'utf8' })
}
}
module.exports = VisualStudioFinder

70
node_modules/cmake-js/lib/import/util.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
'use strict'
const log = require('../logger')
const cp = require('child_process')
const path = require('path')
const execFile = async (...args) =>
new Promise((resolve) => {
const child = cp.execFile(...args, (...a) => resolve(a))
child.stdin.end()
})
function logWithPrefix(log, prefix) {
function setPrefix(logFunction) {
return (...args) => logFunction.apply(null, [prefix, ...args]) // eslint-disable-line
}
return {
silly: setPrefix(log.silly),
verbose: setPrefix(log.verbose),
info: setPrefix(log.info),
warn: setPrefix(log.warn),
error: setPrefix(log.error),
}
}
async function regGetValue(key, value, addOpts) {
const outReValue = value.replace(/\W/g, '.')
const outRe = new RegExp(`^\\s+${outReValue}\\s+REG_\\w+\\s+(\\S.*)$`, 'im')
const reg = path.join(process.env.SystemRoot, 'System32', 'reg.exe')
const regArgs = ['query', key, '/v', value].concat(addOpts)
log.silly('reg', 'running', reg, regArgs)
const [err, stdout, stderr] = await execFile(reg, regArgs, { encoding: 'utf8' })
log.silly('reg', 'reg.exe stdout = %j', stdout)
if (err || stderr.trim() !== '') {
log.silly('reg', 'reg.exe err = %j', err && (err.stack || err))
log.silly('reg', 'reg.exe stderr = %j', stderr)
if (err) {
throw err
}
throw new Error(stderr)
}
const result = outRe.exec(stdout)
if (!result) {
log.silly('reg', 'error parsing stdout')
throw new Error('Could not parse output of reg.exe')
}
log.silly('reg', 'found: %j', result[1])
return result[1]
}
async function regSearchKeys(keys, value, addOpts) {
for (const key of keys) {
try {
return await regGetValue(key, value, addOpts)
} catch {
continue
}
}
}
module.exports = {
logWithPrefix: logWithPrefix,
regGetValue: regGetValue,
regSearchKeys: regSearchKeys,
execFile: execFile,
}

12
node_modules/cmake-js/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
'use strict'
module.exports = {
BuildSystem: require('./buildSystem'),
CMLog: require('./cmLog'),
environment: require('./environment'),
TargetOptions: require('./targetOptions'),
Dist: require('./dist'),
CMake: require('./cMake'),
downloader: require('./downloader'),
Toolset: require('./toolset'),
}

63
node_modules/cmake-js/lib/locateNAN.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
'use strict'
const fs = require('fs-extra')
const path = require('path')
const isNANModule = async function (dir) {
const h = path.join(dir, 'nan.h')
try {
const stat = await fs.stat(h)
return stat.isFile()
} catch (e) {
return false
}
}
async function isNodeJSProject(dir) {
const pjson = path.join(dir, 'package.json')
const node_modules = path.join(dir, 'node_modules')
try {
let stat = await fs.stat(pjson)
if (stat.isFile()) {
return true
}
stat = await fs.stat(node_modules)
if (stat.isDirectory()) {
return true
}
} catch (e) {
// Ignore
}
return false
}
const locateNAN = (module.exports = async function (projectRoot) {
if (locateNAN.__projectRoot) {
// Override for unit tests
projectRoot = locateNAN.__projectRoot
}
let result = await isNodeJSProject(projectRoot)
if (!result) {
return null
}
const nanModulePath = path.join(projectRoot, 'node_modules', 'nan')
result = await isNANModule(nanModulePath)
if (result) {
return nanModulePath
}
// Goto upper level:
return await locateNAN(goUp(projectRoot))
})
function goUp(dir) {
const items = dir.split(path.sep)
const scopeItem = items[items.length - 2]
if (scopeItem && scopeItem[0] === '@') {
// skip scope
dir = path.join(dir, '..')
}
dir = path.join(dir, '..', '..')
return path.normalize(dir)
}

18
node_modules/cmake-js/lib/locateNodeApi.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict'
const path = require('path')
const locateNodeApi = (module.exports = async function (projectRoot) {
if (locateNodeApi.__projectRoot) {
// Override for unit tests
projectRoot = locateNodeApi.__projectRoot
}
try {
const tmpRequire = require('module').createRequire(path.join(projectRoot, 'package.json'))
const inc = tmpRequire('node-addon-api')
return inc.include.replace(/"/g, '')
} catch (e) {
// It most likely wasn't found
return null
}
})

59
node_modules/cmake-js/lib/logger.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
const util = require('util')
const levels = {
silly: -Infinity,
verbose: 1000,
info: 2000,
http: 3000,
warn: 4000,
error: 5000,
silent: Infinity,
}
const colors = {
silly: 'inverse',
verbose: 'blue',
info: 'green',
http: 'green',
warn: 'yellow',
error: 'red',
}
let currentLevel = levels.info
function log(level, prefix, message, ...args) {
if (currentLevel <= levels[level]) {
const stream = level === 'error' ? process.stderr : process.stdout
const color = colors[level]
let levelStr = level.toUpperCase()
if (process.stdout.isTTY && util.styleText) {
// util.styleText is available in Node.js >= 20.12.0
levelStr = util.styleText(color, levelStr)
if (prefix) prefix = util.styleText('magenta', prefix)
}
const formattedMessage = util.format(message, ...args)
const line = prefix
? util.format('%s %s %s', levelStr, prefix, formattedMessage)
: util.format('%s %s', levelStr, formattedMessage)
stream.write(line + '\n')
}
}
const logger = {
get level() {
return Object.keys(levels).find((key) => levels[key] === currentLevel)
},
set level(newLevel) {
if (levels[newLevel] !== undefined) {
currentLevel = levels[newLevel]
}
},
}
for (const level of Object.keys(colors)) {
logger[level] = (prefix, message, ...args) => log(level, prefix, message, ...args)
}
module.exports = logger

31
node_modules/cmake-js/lib/npmConfig.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
'use strict'
function getNpmConfig() {
const npmOptions = {}
const npmConfigPrefix = 'npm_config_'
Object.keys(process.env).forEach(function (name) {
if (name.indexOf(npmConfigPrefix) !== 0) {
return
}
const value = process.env[name]
name = name.substring(npmConfigPrefix.length)
if (name) {
npmOptions[name] = value
}
}, this)
return npmOptions
}
module.exports = function (log) {
log.verbose('CFG', 'Looking for NPM config.')
const options = getNpmConfig()
if (options) {
log.silly('CFG', 'NPM options:', options)
} else {
log.verbose('CFG', 'There are no NPM options available.')
}
return options
}

53
node_modules/cmake-js/lib/processHelpers.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
'use strict'
const spawn = require('child_process').spawn
const execFile = require('child_process').execFile
const processHelpers = {
run: function (command, options) {
if (!options) options = {}
return new Promise(function (resolve, reject) {
const env = Object.assign({}, process.env)
if (env.Path && env.PATH) {
if (env.Path !== env.PATH) {
env.PATH = env.Path + ';' + env.PATH
}
delete env.Path
}
const child = spawn(command[0], command.slice(1), {
stdio: options.silent ? 'ignore' : 'inherit',
env,
})
let ended = false
child.on('error', function (e) {
if (!ended) {
reject(e)
ended = true
}
})
child.on('exit', function (code, signal) {
if (!ended) {
if (code === 0) {
resolve()
} else {
reject(new Error('Process terminated: ' + code || signal))
}
ended = true
}
})
})
},
execFile: function (command) {
return new Promise(function (resolve, reject) {
execFile(command[0], command.slice(1), function (err, stdout, stderr) {
if (err) {
reject(new Error(err.message + '\n' + (stdout || stderr)))
} else {
resolve(stdout)
}
})
})
},
}
module.exports = processHelpers

95
node_modules/cmake-js/lib/runtimePaths.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
'use strict'
const assert = require('assert')
const semver = require('semver')
const NODE_MIRROR = process.env.NVM_NODEJS_ORG_MIRROR || 'https://nodejs.org/dist'
const ELECTRON_MIRROR = process.env.ELECTRON_MIRROR || 'https://artifacts.electronjs.org/headers/dist'
const runtimePaths = {
node: function (targetOptions) {
if (semver.lt(targetOptions.runtimeVersion, '4.0.0')) {
return {
externalPath: NODE_MIRROR + '/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isX64 ? 'x64' : '',
name: targetOptions.runtime + '.lib',
},
],
tarPath: targetOptions.runtime + '-v' + targetOptions.runtimeVersion + '.tar.gz',
headerOnly: false,
}
} else {
return {
externalPath: NODE_MIRROR + '/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isArm64 ? 'win-arm64' : targetOptions.isX64 ? 'win-x64' : 'win-x86',
name: targetOptions.runtime + '.lib',
},
],
tarPath: targetOptions.runtime + '-v' + targetOptions.runtimeVersion + '-headers.tar.gz',
headerOnly: true,
}
}
},
nw: function (targetOptions) {
if (semver.gte(targetOptions.runtimeVersion, '0.13.0')) {
return {
externalPath: 'https://node-webkit.s3.amazonaws.com/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isX64 ? 'x64' : '',
name: targetOptions.runtime + '.lib',
},
{
dir: targetOptions.isX64 ? 'x64' : '',
name: 'node.lib',
},
],
tarPath: 'nw-headers-v' + targetOptions.runtimeVersion + '.tar.gz',
headerOnly: false,
}
}
return {
externalPath: 'https://node-webkit.s3.amazonaws.com/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isX64 ? 'x64' : '',
name: targetOptions.runtime + '.lib',
},
],
tarPath: 'nw-headers-v' + targetOptions.runtimeVersion + '.tar.gz',
headerOnly: false,
}
},
electron: function (targetOptions) {
return {
externalPath: ELECTRON_MIRROR + '/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isArm64 ? 'arm64' : targetOptions.isX64 ? 'x64' : '',
name: 'node.lib',
},
],
tarPath: 'node' + '-v' + targetOptions.runtimeVersion + '.tar.gz',
headerOnly: semver.gte(targetOptions.runtimeVersion, '4.0.0-alpha'),
}
},
get: function (targetOptions) {
assert(targetOptions && typeof targetOptions === 'object')
const runtime = targetOptions.runtime
const func = runtimePaths[runtime]
let paths
if (typeof func === 'function') {
paths = func(targetOptions)
if (paths && typeof paths === 'object') {
return paths
}
}
throw new Error('Unknown runtime: ' + runtime)
},
}
module.exports = runtimePaths

33
node_modules/cmake-js/lib/targetOptions.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict'
const environment = require('./environment')
class TargetOptions {
get arch() {
return this.options.arch || environment.arch
}
get isX86() {
return this.arch === 'ia32' || this.arch === 'x86'
}
get isX64() {
return this.arch === 'x64'
}
get isArm() {
return this.arch === 'arm'
}
get isArm64() {
return this.arch === 'arm64'
}
get runtime() {
return this.options.runtime || environment.runtime
}
get runtimeVersion() {
return this.options.runtimeVersion || environment.runtimeVersion
}
constructor(options) {
this.options = options || {}
}
}
module.exports = TargetOptions

224
node_modules/cmake-js/lib/toolset.js generated vendored Normal file
View File

@@ -0,0 +1,224 @@
'use strict'
const TargetOptions = require('./targetOptions')
const environment = require('./environment')
const assert = require('assert')
const CMLog = require('./cmLog')
const { findVisualStudio } = environment.isWin ? require('./import/find-visualstudio') : {}
class Toolset {
constructor(options) {
this.options = options || {}
this.targetOptions = new TargetOptions(this.options)
this.generator = options.generator
this.toolset = options.toolset
this.platform = options.platform
this.target = options.target
this.cCompilerPath = options.cCompilerPath
this.cppCompilerPath = options.cppCompilerPath
this.compilerFlags = []
this.linkerFlags = []
this.makePath = null
this.log = new CMLog(this.options)
this._initialized = false
}
async initialize(install) {
if (!this._initialized) {
if (environment.isWin) {
await this.initializeWin(install)
} else {
this.initializePosix(install)
}
this._initialized = true
}
}
initializePosix(install) {
if (!this.cCompilerPath || !this.cppCompilerPath) {
// 1: Compiler
if (!environment.isGPPAvailable && !environment.isClangAvailable) {
if (environment.isOSX) {
throw new Error(
"C++ Compiler toolset is not available. Install Xcode Commandline Tools from Apple Dev Center, or install Clang with homebrew by invoking: 'brew install llvm --with-clang --with-asan'.",
)
} else {
throw new Error(
"C++ Compiler toolset is not available. Install proper compiler toolset with your package manager, eg. 'sudo apt-get install g++'.",
)
}
}
if (this.options.preferClang && environment.isClangAvailable) {
if (install) {
this.log.info('TOOL', 'Using clang++ compiler, because preferClang option is set, and clang++ is available.')
}
this.cppCompilerPath = this.cppCompilerPath || 'clang++'
this.cCompilerPath = this.cCompilerPath || 'clang'
} else if (this.options.preferGnu && environment.isGPPAvailable) {
if (install) {
this.log.info('TOOL', 'Using g++ compiler, because preferGnu option is set, and g++ is available.')
}
this.cppCompilerPath = this.cppCompilerPath || 'g++'
this.cCompilerPath = this.cCompilerPath || 'gcc'
}
}
// if it's already set because of options...
if (this.generator) {
if (install) {
this.log.info('TOOL', 'Using ' + this.generator + ' generator, as specified from commandline.')
}
}
// 2: Generator
else if (environment.isOSX) {
if (this.options.preferXcode) {
if (install) {
this.log.info('TOOL', 'Using Xcode generator, because preferXcode option is set.')
}
this.generator = 'Xcode'
} else if (this.options.preferMake && environment.isMakeAvailable) {
if (install) {
this.log.info(
'TOOL',
'Using Unix Makefiles generator, because preferMake option is set, and make is available.',
)
}
this.generator = 'Unix Makefiles'
} else if (environment.isNinjaAvailable) {
if (install) {
this.log.info('TOOL', 'Using Ninja generator, because ninja is available.')
}
this.generator = 'Ninja'
} else {
if (install) {
this.log.info('TOOL', 'Using Unix Makefiles generator.')
}
this.generator = 'Unix Makefiles'
}
} else {
if (this.options.preferMake && environment.isMakeAvailable) {
if (install) {
this.log.info(
'TOOL',
'Using Unix Makefiles generator, because preferMake option is set, and make is available.',
)
}
this.generator = 'Unix Makefiles'
} else if (environment.isNinjaAvailable) {
if (install) {
this.log.info('TOOL', 'Using Ninja generator, because ninja is available.')
}
this.generator = 'Ninja'
} else {
if (install) {
this.log.info('TOOL', 'Using Unix Makefiles generator.')
}
this.generator = 'Unix Makefiles'
}
}
// 3: Flags
if (environment.isOSX) {
if (install) {
this.log.verbose('TOOL', 'Setting default OSX compiler flags.')
}
this.compilerFlags.push('-D_DARWIN_USE_64_BIT_INODE=1')
this.compilerFlags.push('-D_LARGEFILE_SOURCE')
this.compilerFlags.push('-D_FILE_OFFSET_BITS=64')
this.linkerFlags.push('-undefined dynamic_lookup')
}
this.compilerFlags.push('-DBUILDING_NODE_EXTENSION')
// 4: Build target
if (this.options.target) {
this.log.info('TOOL', 'Building only the ' + this.options.target + ' target, as specified from the command line.')
}
}
async initializeWin(install) {
if (!this.generator) {
const foundVsInfo = await this._getTopSupportedVisualStudioGenerator()
if (foundVsInfo) {
if (install) {
this.log.info('TOOL', `Using ${foundVsInfo.generator} generator.`)
}
this.generator = foundVsInfo.generator
const isAboveVS16 = foundVsInfo.versionMajor >= 16
// The CMake Visual Studio Generator does not support the Win64 or ARM suffix on
// the generator name. Instead the generator platform must be set explicitly via
// the platform parameter
if (!this.platform && isAboveVS16) {
switch (this.targetOptions.arch) {
case 'ia32':
case 'x86':
this.platform = 'Win32'
break
case 'x64':
this.platform = 'x64'
break
case 'arm':
this.platform = 'ARM'
break
case 'arm64':
this.platform = 'ARM64'
break
default:
this.log.warn('TOOL', 'Unknown NodeJS architecture: ' + this.targetOptions.arch)
break
}
}
} else {
throw new Error('There is no Visual C++ compiler installed. Install Visual C++ Build Toolset or Visual Studio.')
}
} else {
// if it's already set because of options...
if (install) {
this.log.info('TOOL', 'Using ' + this.options.generator + ' generator, as specified from commandline.')
}
}
this.linkerFlags.push('/DELAYLOAD:NODE.EXE')
if (this.targetOptions.isX86) {
if (install) {
this.log.verbose('TOOL', 'Setting SAFESEH:NO linker flag.')
}
this.linkerFlags.push('/SAFESEH:NO')
}
}
async _getTopSupportedVisualStudioGenerator() {
const CMake = require('./cMake')
assert(environment.isWin)
const selectedVs = await findVisualStudio(environment.runtimeVersion, this.options.msvsVersion)
if (!selectedVs) return null
const list = await CMake.getGenerators(this.options, this.log)
for (const gen of list) {
const found = gen.startsWith(`Visual Studio ${selectedVs.versionMajor}`)
if (!found) {
continue
}
// unlike previous versions "Visual Studio 16 2019" and onwards don't end with arch name
const isAboveVS16 = selectedVs.versionMajor >= 16
if (!isAboveVS16) {
const is64Bit = gen.endsWith('Win64')
if ((this.targetOptions.isX86 && is64Bit) || (this.targetOptions.isX64 && !is64Bit)) {
continue
}
}
return {
...selectedVs,
generator: gen,
}
}
// Nothing matched
return null
}
}
module.exports = Toolset