Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 61 additions & 30 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ const notarizeOnMac = require('./lib/notarize-on-mac')
const packageApplication = require('./lib/package-application')
const prebuildLessCache = require('./lib/prebuild-less-cache')
const testSignOnMac = require('./lib/test-sign-on-mac')
const transpileBabelPaths = require('./lib/transpile-babel-paths')
const transpileCoffeeScriptPaths = require('./lib/transpile-coffee-script-paths')
const transpileCsonPaths = require('./lib/transpile-cson-paths')
const transpilePegJsPaths = require('./lib/transpile-peg-js-paths')
const transpilePackagesWithCustomTranspilerPaths = require('./lib/transpile-packages-with-custom-transpiler-paths.js')

process.on('unhandledRejection', function (e) {
console.error(e.stack || e)
Expand All @@ -69,31 +64,41 @@ process.on('unhandledRejection', function (e) {

process.env.ELECTRON_VERSION = CONFIG.appMetadata.electronVersion

let binariesPromise = Promise.resolve()

if (!argv.existingBinaries) {
checkChromedriverVersion()
cleanOutputDirectory()
copyAssets()
transpilePackagesWithCustomTranspilerPaths()
transpileBabelPaths()
transpileCoffeeScriptPaths()
transpileCsonPaths()
transpilePegJsPaths()
generateModuleCache()
prebuildLessCache()
generateMetadata()
generateAPIDocs()
if (!argv.generateApiDocs) {
binariesPromise = dumpSymbols()
}
async function transpile() {
const { spawn, Thread, Worker } = require(`${CONFIG.scriptRunnerModulesPath}/threads`)

const transpilePackagesWithCustomTranspilerPaths = await spawn(new Worker('./lib/transpile-packages-with-custom-transpiler-paths'))
const transpilePackagesWithCustomTranspilerPathsPromise = transpilePackagesWithCustomTranspilerPaths()

const transpileBabelPaths = await spawn(new Worker('./lib/transpile-babel-paths'))
const transpileBabelPathsPromise = transpileBabelPaths()

const transpileCoffeeScriptPaths = await spawn(new Worker('./lib/transpile-coffee-script-paths'))
const transpileCoffeeScriptPathsPromise = transpileCoffeeScriptPaths()

const transpileCsonPaths = await spawn(new Worker('./lib/transpile-cson-paths'))
const transpileCsonPathsPromise = transpileCsonPaths()

const transpilePegJsPaths = await spawn(new Worker('./lib/transpile-peg-js-paths'))
const transpilePegJsPathsPromise = transpilePegJsPaths()

await transpilePackagesWithCustomTranspilerPathsPromise;
await Thread.terminate(transpilePackagesWithCustomTranspilerPaths)

await transpileBabelPathsPromise;
await Thread.terminate(transpileBabelPaths)

await transpileCoffeeScriptPathsPromise;
await Thread.terminate(transpileCoffeeScriptPaths)

await transpileCsonPathsPromise;
await Thread.terminate(transpileCsonPaths)

await transpilePegJsPathsPromise;
await Thread.terminate(transpilePegJsPaths)
}

if (!argv.generateApiDocs) {
binariesPromise
.then(packageApplication)
.then(packagedAppPath => generateStartupSnapshot(packagedAppPath).then(() => packagedAppPath))
.then(async packagedAppPath => {
async function singAndCreateInstaller(packagedAppPath) {
switch (process.platform) {
case 'darwin': {
if (argv.codeSign) {
Expand Down Expand Up @@ -148,7 +153,29 @@ if (!argv.generateApiDocs) {
}

return Promise.resolve(packagedAppPath)
}).then(packagedAppPath => {
}


async function build() {

if (!argv.existingBinaries) {
checkChromedriverVersion()
cleanOutputDirectory()
copyAssets()
await transpile()
generateModuleCache()
prebuildLessCache()
generateMetadata()
generateAPIDocs()
if (!argv.generateApiDocs) {
await dumpSymbols()
}
}

if (!argv.generateApiDocs) {
const packagedAppPath = await packageApplication()
await generateStartupSnapshot(packagedAppPath)
await singAndCreateInstaller(packagedAppPath)
if (argv.compressArtifacts) {
compressArtifacts(packagedAppPath)
} else {
Expand All @@ -160,5 +187,9 @@ if (!argv.generateApiDocs) {
} else {
console.log('Skipping installation. Specify the --install option to install Atom'.gray)
}
})
}

}


build().then(() => {process.exit(0)}).catch((e) => {throw e;})
5 changes: 4 additions & 1 deletion script/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,7 @@ function getNpmBinPath(external = false) {
: npmBinName;
}

process.env.JOBS = 'max'; // parallel build in node-gyp
// parallel build in node-gyp
if (!process.env.JOBS) {
process.env.JOBS = 'max';
}
10 changes: 6 additions & 4 deletions script/lib/install-apm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ const childProcess = require('child_process');

const CONFIG = require('../config');

function installApm(ci) {
function installApm(ci = false, showVersion = true) {
console.log('Installing apm');
// npm ci leaves apm with a bunch of unmet dependencies
childProcess.execFileSync(
CONFIG.getNpmBinPath(),
['--global-style', '--loglevel=error', 'install'],
{ env: process.env, cwd: CONFIG.apmRootPath }
);
childProcess.execFileSync(CONFIG.getApmBinPath(), ['--version'], {
stdio: 'inherit'
});
if (showVersion) {
childProcess.execFileSync(CONFIG.getApmBinPath(), ['--version'], {
stdio: 'inherit'
});
}
}

const { expose } = require(`${CONFIG.scriptRunnerModulesPath}/threads/worker`);
Expand Down
2 changes: 0 additions & 2 deletions script/lib/install-script-runner-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const childProcess = require('child_process');

const CONFIG = require('../config');

process.env.ELECTRON_CUSTOM_VERSION = CONFIG.appMetadata.electronVersion;

function installScriptRunnerDependencies(ci) {
console.log('Installing script runner dependencies');
childProcess.execFileSync(
Expand Down
8 changes: 6 additions & 2 deletions script/lib/transpile-babel-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const path = require('path');

const CONFIG = require('../config');

module.exports = function() {
function transpileBabelPaths() {
console.log(`Transpiling Babel paths in ${CONFIG.intermediateAppPath}`);
for (let path of getPathsToTranspile()) {
transpileBabelPath(path);
}
};
}

function getPathsToTranspile() {
let paths = [];
Expand Down Expand Up @@ -49,3 +49,7 @@ function transpileBabelPath(path) {
CompileCache.addPathToCache(path, CONFIG.atomHomeDirPath)
);
}

const { expose } = require(`${CONFIG.scriptRunnerModulesPath}/threads/worker`);
expose(transpileBabelPaths);
module.exports = transpileBabelPaths;
8 changes: 6 additions & 2 deletions script/lib/transpile-coffee-script-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ const path = require('path');

const CONFIG = require('../config');

module.exports = function() {
function transpileCoffeeScriptPaths() {
console.log(
`Transpiling CoffeeScript paths in ${CONFIG.intermediateAppPath}`
);
for (let path of getPathsToTranspile()) {
transpileCoffeeScriptPath(path);
}
};
}

function getPathsToTranspile() {
let paths = [];
Expand Down Expand Up @@ -63,3 +63,7 @@ function transpileCoffeeScriptPath(coffeePath) {
);
fs.unlinkSync(coffeePath);
}

const { expose } = require(`${CONFIG.scriptRunnerModulesPath}/threads/worker`);
expose(transpileCoffeeScriptPaths);
module.exports = transpileCoffeeScriptPaths;
8 changes: 6 additions & 2 deletions script/lib/transpile-cson-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const path = require('path');

const CONFIG = require('../config');

module.exports = function() {
function transpileCsonPaths() {
console.log(`Transpiling CSON paths in ${CONFIG.intermediateAppPath}`);
for (let path of getPathsToTranspile()) {
transpileCsonPath(path);
}
};
}

function getPathsToTranspile() {
let paths = [];
Expand Down Expand Up @@ -53,3 +53,7 @@ function transpileCsonPath(csonPath) {
);
fs.unlinkSync(csonPath);
}

const { expose } = require(`${CONFIG.scriptRunnerModulesPath}/threads/worker`);
expose(transpileCsonPaths);
module.exports = transpileCsonPaths;
8 changes: 6 additions & 2 deletions script/lib/transpile-packages-with-custom-transpiler-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const runApmInstall = require('./run-apm-install');

require('colors');

module.exports = function() {
function transpilePackagesWithCustomTranspilerPaths() {
console.log(
`Transpiling packages with custom transpiler configurations in ${
CONFIG.intermediateAppPath
Expand Down Expand Up @@ -78,11 +78,15 @@ module.exports = function() {
intermediatePackageBackup.restore();
}
}
};
}

function transpilePath(path) {
fs.writeFileSync(
path,
CompileCache.addPathToCache(path, CONFIG.atomHomeDirPath)
);
}

const { expose } = require(`${CONFIG.scriptRunnerModulesPath}/threads/worker`);
expose(transpilePackagesWithCustomTranspilerPaths);
module.exports = transpilePackagesWithCustomTranspilerPaths;
8 changes: 6 additions & 2 deletions script/lib/transpile-peg-js-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const path = require('path');

const CONFIG = require('../config');

module.exports = function() {
function transpilePegJsPaths() {
console.log(`Transpiling PEG.js paths in ${CONFIG.intermediateAppPath}`);
for (let path of getPathsToTranspile()) {
transpilePegJsPath(path);
}
};
}

function getPathsToTranspile() {
let paths = [];
Expand Down Expand Up @@ -41,3 +41,7 @@ function transpilePegJsPath(pegJsPath) {
fs.writeFileSync(jsPath, outputCode);
fs.unlinkSync(pegJsPath);
}

const { expose } = require(`${CONFIG.scriptRunnerModulesPath}/threads/worker`);
expose(transpilePegJsPaths);
module.exports = transpilePegJsPaths;