* Mirror of tgstation's Common Build Tooling (#55373)

* tgui 4.3 (#56080)

Co-authored-by: Aleksej Komarov <stylemistake@gmail.com>
This commit is contained in:
Useroth
2021-01-18 07:42:54 +01:00
committed by GitHub
parent 2999fb4f90
commit ef6481e253
185 changed files with 8554 additions and 7403 deletions

80
tools/build/build.js Executable file
View File

@@ -0,0 +1,80 @@
#!/usr/bin/env node
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
const { resolve: resolvePath } = require('path');
const { resolveGlob } = require('./cbt/fs');
const { exec } = require('./cbt/process');
const { Task, runTasks } = require('./cbt/task');
const { regQuery } = require('./cbt/winreg');
// Change working directory to project root
process.chdir(resolvePath(__dirname, '../../'));
const taskTgui = new Task('tgui')
.depends('tgui/.yarn/releases/*')
.depends('tgui/yarn.lock')
.depends('tgui/webpack.config.js')
.depends('tgui/**/package.json')
.depends('tgui/packages/**/*.js')
.depends('tgui/packages/**/*.jsx')
.provides('tgui/public/*.bundle.*')
.provides('tgui/public/*.chunk.*')
.build(async () => {
// Instead of calling `tgui/bin/tgui`, we reproduce the whole pipeline
// here for maximum compilation speed.
const yarnRelease = resolveGlob('./tgui/.yarn/releases/yarn-*.cjs')[0]
.replace('/tgui/', '/');
const yarn = args => exec('node', [yarnRelease, ...args], {
cwd: './tgui',
});
await yarn(['install']);
await yarn(['run', 'webpack-cli', '--mode=production']);
});
const taskDm = new Task('dm')
.depends('code/**')
.depends('goon/**')
.depends('html/**')
.depends('interface/**')
.depends('tgui/public/tgui.html')
.depends('tgui/public/*.bundle.*')
.depends('tgui/public/*.chunk.*')
.depends('tgstation.dme')
.provides('tgstation.dmb')
.provides('tgstation.rsc')
.build(async () => {
let compiler = 'dm';
// Let's do some registry queries on Windows, because dm is not in PATH.
if (process.platform === 'win32') {
const installPath = (
await regQuery(
'HKLM\\Software\\Dantom\\BYOND',
'installpath')
|| await regQuery(
'HKLM\\SOFTWARE\\WOW6432Node\\Dantom\\BYOND',
'installpath')
);
if (installPath) {
compiler = resolvePath(installPath, 'bin/dm.exe');
}
} else {
compiler = 'DreamMaker';
}
await exec(compiler, ['tgstation.dme']);
});
// Frontend
const tasksToRun = [
taskTgui,
taskDm,
];
if (process.env['TG_BUILD_TGS_MODE']) {
tasksToRun.pop();
}
runTasks(tasksToRun);