зеркало из https://github.com/electron/electron.git
build: dynamically calculate out dir (#19857)
This commit is contained in:
Родитель
3bd829aee0
Коммит
991a56135d
|
@ -4,13 +4,13 @@ const path = require('path')
|
|||
|
||||
const ELECTRON_DIR = path.resolve(__dirname, '..', '..')
|
||||
const SRC_DIR = path.resolve(ELECTRON_DIR, '..')
|
||||
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'
|
||||
|
||||
require('colors')
|
||||
const pass = '\u2713'.green
|
||||
const fail = '\u2717'.red
|
||||
|
||||
function getElectronExec () {
|
||||
const OUT_DIR = getOutDir()
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
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 () {
|
||||
return path.resolve(SRC_DIR, getElectronExec())
|
||||
}
|
||||
|
@ -62,8 +76,8 @@ async function getCurrentBranch (gitDir) {
|
|||
module.exports = {
|
||||
getCurrentBranch,
|
||||
getElectronExec,
|
||||
getOutDir,
|
||||
getAbsoluteElectronExec,
|
||||
ELECTRON_DIR,
|
||||
OUT_DIR,
|
||||
SRC_DIR
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ if (!process.mainModule) {
|
|||
}
|
||||
|
||||
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, {
|
||||
npm_config_nodedir: nodeDir,
|
||||
npm_config_msvs_version: '2017',
|
||||
|
|
|
@ -142,7 +142,7 @@ async function runMainProcessElectronTests () {
|
|||
}
|
||||
|
||||
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, {
|
||||
npm_config_nodedir: nodeDir,
|
||||
npm_config_msvs_version: '2017'
|
||||
|
|
Загрузка…
Ссылка в новой задаче