[MIRROR] Create explicit warning if not building with CBT (#4395)

* Create explicit warning if not building with CBT (#57931)

Adds a new CBT define which is automatically created when building. If this define is absent, the build will fail.

This is what Cyberboss tried to do with USE_BUILD_BAT_INSTEAD_OF_DREAM_MAKER.dm, but couldn't.

The reasoning behind this is CBT is already a requirement to build a fresh project, otherwise the tgui bundle files won't exist. This gives a readable error to go along with that. However, you can currently build once then just use Dream Maker. This is a footgun - not only are we already adding new things to CBT like tgfont which will fail later on, but also it will create weird scenarios when we add tasks to CBT that don't immediately fail if not ran, or otherwise create out of sync builds.

Also replaces rmSync with unlinkSync, which works on older Node versions.

Co-authored-by: Kyle Spier-Swenson <kyleshome@ gmail.com>
Co-authored-by: Aleksej Komarov <stylemistake@ gmail.com>

* Create explicit warning if not building with CBT

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: Kyle Spier-Swenson <kyleshome@ gmail.com>
Co-authored-by: Aleksej Komarov <stylemistake@ gmail.com>
This commit is contained in:
SkyratBot
2021-03-25 18:00:00 +01:00
committed by GitHub
parent 03f9397588
commit be581f0ed1
2 changed files with 27 additions and 5 deletions

View File

@@ -93,6 +93,16 @@ const taskTgui = new Task('tgui')
await yarn(['run', 'webpack-cli', '--mode=production']);
});
/// Prepends the defines to the .dme.
/// Does not clean them up, as this is intended for TGS which
/// clones new copies anyway.
const taskPrependDefines = (...defines) => new Task('prepend-defines')
.build(async () => {
const dmeContents = fs.readFileSync(`${DME_NAME}.dme`);
const textToWrite = defines.map(define => `#define ${define}\n`);
fs.writeFileSync(`${DME_NAME}.dme`, `${textToWrite}\n${dmeContents}`);
});
const taskDm = (...injectedDefines) => new Task('dm')
.depends('_maps/map_files/generic/**')
.depends('code/**')
@@ -166,7 +176,7 @@ const taskDm = (...injectedDefines) => new Task('dm')
// Rename rsc
fs.renameSync(`${DME_NAME}.mdme.rsc`, `${DME_NAME}.rsc`)
// Remove mdme
fs.rmSync(`${DME_NAME}.mdme`)
fs.unlinkSync(`${DME_NAME}.mdme`)
}
else {
await exec(dmPath, [`${DME_NAME}.dme`]);
@@ -181,14 +191,15 @@ switch (BUILD_MODE) {
taskYarn,
taskTgfont,
taskTgui,
taskDm(),
taskDm('CBT'),
]
break;
case TGS_BUILD:
tasksToRun = [
taskYarn,
taskTgfont,
taskTgui
taskTgui,
taskPrependDefines('TGS'),
]
break;
case ALL_MAPS_BUILD:
@@ -196,7 +207,7 @@ switch (BUILD_MODE) {
taskYarn,
taskTgfont,
taskTgui,
taskDm('CIBUILDING','CITESTING','ALL_MAPS')
taskDm('CBT','CIBUILDING','CITESTING','ALL_MAPS')
];
break;
case TEST_RUN_BUILD:
@@ -204,7 +215,7 @@ switch (BUILD_MODE) {
taskYarn,
taskTgfont,
taskTgui,
taskDm('CIBUILDING')
taskDm('CBT','CIBUILDING')
];
break;
default: