build: dynamically calculate out dir (#19857)
This commit is contained in:
parent
3bd829aee0
commit
991a56135d
3 changed files with 18 additions and 4 deletions
|
@ -4,13 +4,13 @@ const path = require('path')
|
||||||
|
|
||||||
const ELECTRON_DIR = path.resolve(__dirname, '..', '..')
|
const ELECTRON_DIR = path.resolve(__dirname, '..', '..')
|
||||||
const SRC_DIR = path.resolve(ELECTRON_DIR, '..')
|
const SRC_DIR = path.resolve(ELECTRON_DIR, '..')
|
||||||
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'
|
|
||||||
|
|
||||||
require('colors')
|
require('colors')
|
||||||
const pass = '\u2713'.green
|
const pass = '\u2713'.green
|
||||||
const fail = '\u2717'.red
|
const fail = '\u2717'.red
|
||||||
|
|
||||||
function getElectronExec () {
|
function getElectronExec () {
|
||||||
|
const OUT_DIR = getOutDir()
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return `out/${OUT_DIR}/Electron.app/Contents/MacOS/Electron`
|
return `out/${OUT_DIR}/Electron.app/Contents/MacOS/Electron`
|
||||||
|
@ -23,6 +23,20 @@ function getElectronExec () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getOutDir (shouldLog) {
|
||||||
|
if (process.env.ELECTRON_OUT_DIR) {
|
||||||
|
return process.env.ELECTRON_OUT_DIR
|
||||||
|
} else {
|
||||||
|
for (const buildType of ['Debug', 'Testing', 'Release']) {
|
||||||
|
const outPath = path.resolve(SRC_DIR, 'out', buildType)
|
||||||
|
if (fs.existsSync(outPath)) {
|
||||||
|
if (shouldLog) console.log(`OUT_DIR is: ${buildType}`)
|
||||||
|
return buildType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getAbsoluteElectronExec () {
|
function getAbsoluteElectronExec () {
|
||||||
return path.resolve(SRC_DIR, getElectronExec())
|
return path.resolve(SRC_DIR, getElectronExec())
|
||||||
}
|
}
|
||||||
|
@ -62,8 +76,8 @@ async function getCurrentBranch (gitDir) {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getCurrentBranch,
|
getCurrentBranch,
|
||||||
getElectronExec,
|
getElectronExec,
|
||||||
|
getOutDir,
|
||||||
getAbsoluteElectronExec,
|
getAbsoluteElectronExec,
|
||||||
ELECTRON_DIR,
|
ELECTRON_DIR,
|
||||||
OUT_DIR,
|
|
||||||
SRC_DIR
|
SRC_DIR
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ if (!process.mainModule) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
const nodeDir = path.resolve(BASE, `out/${utils.OUT_DIR}/gen/node_headers`)
|
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir(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: '2017',
|
npm_config_msvs_version: '2017',
|
||||||
|
|
|
@ -142,7 +142,7 @@ async function runMainProcessElectronTests () {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installSpecModules () {
|
async function installSpecModules () {
|
||||||
const nodeDir = path.resolve(BASE, `out/${utils.OUT_DIR}/gen/node_headers`)
|
const nodeDir = path.resolve(BASE, `out/${utils.getOutDir(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: '2017'
|
npm_config_msvs_version: '2017'
|
||||||
|
|
Loading…
Add table
Reference in a new issue