From 4fdf458d40a5ec44d7fb7c1e8a82afb96fa966c5 Mon Sep 17 00:00:00 2001 From: AnturK Date: Sun, 28 Jan 2024 23:46:10 +0100 Subject: [PATCH] Adds better buildtool errors when using byond 514 or older (#81129) Every time someone asks what -DCBT means i lose sleep so here's a slightly invasive solution. Build will now check if the dm version is at least 515.1597 (first version with -D switch), at the cost of having to run dry dm.exe run. --- tools/build/lib/byond.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tools/build/lib/byond.js b/tools/build/lib/byond.js index a8398ccf846..50b19ee8d64 100644 --- a/tools/build/lib/byond.js +++ b/tools/build/lib/byond.js @@ -145,10 +145,29 @@ export const DreamMaker = async (dmeFile, options = {}) => { throw err; } }; + + const testDmVersion = async (dmPath) => { + const execReturn = await Juke.exec(dmPath, [], { silent: true, throw: false }); + const version = execReturn.combined.match(`DM compiler version (\\d+)\\.(\\d+)`) + if(version == null){ + Juke.logger.error(`Unexpected DreamMaker return, ensure "${dmPath}" is correct DM path.`) + throw new Juke.ExitCode(1); + } + const requiredMajorVersion = 515; + const requiredMinorVersion = 1597 // First with -D switch functionality + const major = Number(version[1]); + const minor = Number(version[2]); + if(major < requiredMajorVersion || major == requiredMajorVersion && minor < requiredMinorVersion){ + Juke.logger.error(`${requiredMajorVersion}.${requiredMinorVersion} DM version required`) + throw new Juke.ExitCode(1); + } + } + + await testDmVersion(dmPath); testOutputFile(`${dmeBaseName}.dmb`); testOutputFile(`${dmeBaseName}.rsc`); - const runWithWarningChecks = async (dmeFile, args) => { - const execReturn = await Juke.exec(dmeFile, args); + const runWithWarningChecks = async (dmPath, args) => { + const execReturn = await Juke.exec(dmPath, args); const ignoredWarningCodes = options.ignoreWarningCodes ?? []; const reg = ignoredWarningCodes.length > 0 ? new RegExp(`\d+:warning: (?!(${ignoredWarningCodes.join('|')}))`) : /\d+:warning: /; if (options.warningsAsErrors && execReturn.combined.match(reg)) {