build: allow getOutDir cli argument (#21545)
This commit is contained in:
parent
54b4756a29
commit
f0d52eaf0c
4 changed files with 27 additions and 8 deletions
|
@ -1,12 +1,19 @@
|
||||||
|
/*
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
$ node ./script/gn-check.js [--outDir=dirName]
|
||||||
|
*/
|
||||||
|
|
||||||
const cp = require('child_process')
|
const cp = require('child_process')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const args = require('minimist')(process.argv.slice(2), { string: ['outDir'] })
|
||||||
|
|
||||||
const { getOutDir } = require('./lib/utils')
|
const { getOutDir } = require('./lib/utils')
|
||||||
|
|
||||||
const SOURCE_ROOT = path.normalize(path.dirname(__dirname))
|
const SOURCE_ROOT = path.normalize(path.dirname(__dirname))
|
||||||
const DEPOT_TOOLS = path.resolve(SOURCE_ROOT, '..', 'third_party', 'depot_tools')
|
const DEPOT_TOOLS = path.resolve(SOURCE_ROOT, '..', 'third_party', 'depot_tools')
|
||||||
const OUT_DIR = getOutDir()
|
|
||||||
|
|
||||||
|
const OUT_DIR = getOutDir({ outDir: args.outDir })
|
||||||
if (!OUT_DIR) {
|
if (!OUT_DIR) {
|
||||||
throw new Error(`No viable out dir: one of Debug, Testing, or Release must exist.`)
|
throw new Error(`No viable out dir: one of Debug, Testing, or Release must exist.`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,23 @@ function getElectronExec () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOutDir (shouldLog) {
|
function getOutDir (options = {}) {
|
||||||
if (process.env.ELECTRON_OUT_DIR) {
|
const shouldLog = options.shouldLog || false
|
||||||
return process.env.ELECTRON_OUT_DIR
|
|
||||||
|
if (options.outDir || process.env.ELECTRON_OUT_DIR) {
|
||||||
|
const outDir = options.outDir || process.env.ELECTRON_OUT_DIR
|
||||||
|
const outPath = path.resolve(SRC_DIR, 'out', outDir)
|
||||||
|
|
||||||
|
// Check that user-set variable is a valid/existing directory
|
||||||
|
if (fs.existsSync(outPath)) {
|
||||||
|
if (shouldLog) console.log(`OUT_DIR is: ${outDir}`)
|
||||||
|
return outDir
|
||||||
|
}
|
||||||
|
|
||||||
|
// Throw error if user passed/set nonexistent directory.
|
||||||
|
throw new Error(`${outDir} directory not configured on your machine.`)
|
||||||
} else {
|
} else {
|
||||||
for (const buildType of ['Testing', 'Release', 'Default']) {
|
for (const buildType of ['Testing', 'Release', 'Default', 'Debug']) {
|
||||||
const outPath = path.resolve(SRC_DIR, 'out', buildType)
|
const outPath = path.resolve(SRC_DIR, 'out', buildType)
|
||||||
if (fs.existsSync(outPath)) {
|
if (fs.existsSync(outPath)) {
|
||||||
if (shouldLog) console.log(`OUT_DIR is: ${buildType}`)
|
if (shouldLog) console.log(`OUT_DIR is: ${buildType}`)
|
||||||
|
|
|
@ -14,7 +14,7 @@ if (!process.mainModule) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir(true)}/gen/node_headers`)
|
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`)
|
||||||
const env = Object.assign({}, process.env, {
|
const env = Object.assign({}, process.env, {
|
||||||
npm_config_nodedir: nodeDir,
|
npm_config_nodedir: nodeDir,
|
||||||
npm_config_msvs_version: '2019',
|
npm_config_msvs_version: '2019',
|
||||||
|
|
|
@ -146,7 +146,7 @@ async function runRemoteBasedElectronTests () {
|
||||||
|
|
||||||
async function runNativeElectronTests () {
|
async function runNativeElectronTests () {
|
||||||
let testTargets = require('./native-test-targets.json')
|
let testTargets = require('./native-test-targets.json')
|
||||||
const outDir = `out/${utils.getOutDir(false)}`
|
const outDir = `out/${utils.getOutDir()}`
|
||||||
|
|
||||||
// If native tests are being run, only one arg would be relevant
|
// If native tests are being run, only one arg would be relevant
|
||||||
if (args.target && !testTargets.includes(args.target)) {
|
if (args.target && !testTargets.includes(args.target)) {
|
||||||
|
@ -216,7 +216,7 @@ async function runMainProcessElectronTests () {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installSpecModules (dir) {
|
async function installSpecModules (dir) {
|
||||||
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir(true)}/gen/node_headers`)
|
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`)
|
||||||
const env = Object.assign({}, process.env, {
|
const env = Object.assign({}, process.env, {
|
||||||
npm_config_nodedir: nodeDir,
|
npm_config_nodedir: nodeDir,
|
||||||
npm_config_msvs_version: '2019'
|
npm_config_msvs_version: '2019'
|
||||||
|
|
Loading…
Reference in a new issue