From 4f8dc10e0957d3a3191ed2c0785ab43b4d92c947 Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 13 Apr 2024 08:21:06 +0100 Subject: [PATCH] minimum compile version bump to 515.1627 (#6095) it's really time now :cl: code: 515.1627 is now required for development - this is not enforced to play on the server, yet /:cl: --------- Co-authored-by: Fira --- .github/alternate_byond_versions.txt | 2 - .tgs.yml | 2 +- code/__DEFINES/__spacemandmm.dm | 2 +- code/__DEFINES/_macros.dm | 9 --- code/__HELPERS/nameof.dm | 4 -- code/_byond_version_compat.dm | 59 ++-------------- code/_experiments.dm | 24 +------ code/controllers/subsystem/garbage.dm | 44 +++--------- code/datums/datum.dm | 7 -- code/game/machinery/autolathe.dm | 2 +- .../devices/personal_data_transmitter.dm | 1 + .../items/reagent_containers/food/snacks.dm | 4 ++ code/game/objects/structures/pipes/pipes.dm | 2 + code/game/world.dm | 4 +- .../view_variables/reference_tracking.dm | 2 - code/modules/cm_phone/phone.dm | 2 +- code/modules/projectiles/gun.dm | 6 +- .../guns/specialist/launcher/launcher.dm | 4 ++ .../chemistry_machinery/reagent_grinder.dm | 5 +- code/modules/vehicles/van/van.dm | 2 + dependencies.sh | 8 +-- tools/build/build.js | 33 +++++---- tools/build/lib/byond.js | 68 ++++++++++++------- 23 files changed, 105 insertions(+), 191 deletions(-) diff --git a/.github/alternate_byond_versions.txt b/.github/alternate_byond_versions.txt index c96908590dac..7b50af46885e 100644 --- a/.github/alternate_byond_versions.txt +++ b/.github/alternate_byond_versions.txt @@ -5,5 +5,3 @@ # Format is version: map # Example: # 500.1337: runtimestation - -515.1630: lv624 diff --git a/.tgs.yml b/.tgs.yml index ba3fc6b26c66..ed84385e3c36 100644 --- a/.tgs.yml +++ b/.tgs.yml @@ -1,5 +1,5 @@ version: 1 -byond: "514.1588" +byond: "515.1627" static_files: - name: config - name: data diff --git a/code/__DEFINES/__spacemandmm.dm b/code/__DEFINES/__spacemandmm.dm index b62bbee4259a..9a044949db3e 100644 --- a/code/__DEFINES/__spacemandmm.dm +++ b/code/__DEFINES/__spacemandmm.dm @@ -40,5 +40,5 @@ /world/Del() var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") if (debug_server) - LIBCALL(debug_server, "auxtools_shutdown")() + call_ext(debug_server, "auxtools_shutdown")() . = ..() diff --git a/code/__DEFINES/_macros.dm b/code/__DEFINES/_macros.dm index 31f4b2aca084..07c3eb664e61 100644 --- a/code/__DEFINES/_macros.dm +++ b/code/__DEFINES/_macros.dm @@ -8,17 +8,8 @@ #define subtypesof(A) (typesof(A) - A) -#ifdef EXPERIMENT_515_DONT_CACHE_REF /// Takes a datum as input, returns its ref string #define text_ref(datum) ref(datum) -#else -/// Takes a datum as input, returns its ref string, or a cached version of it -/// This allows us to cache \ref creation, which ensures it'll only ever happen once per datum, saving string tree time -/// It is slightly less optimal then a []'d datum, but the cost is massively outweighed by the potential savings -/// It will only work for datums mind, for datum reasons -/// : because of the embedded typecheck -#define text_ref(datum) (isdatum(datum) ? (datum:cached_ref ||= "\ref[datum]") : ("\ref[datum]")) -#endif #define addToListNoDupe(L, index) if(L) L[index] = null; else L = list(index) diff --git a/code/__HELPERS/nameof.dm b/code/__HELPERS/nameof.dm index 7cd5777f4652..5a2fd60e7100 100644 --- a/code/__HELPERS/nameof.dm +++ b/code/__HELPERS/nameof.dm @@ -8,8 +8,4 @@ /** * NAMEOF that actually works in static definitions because src::type requires src to be defined */ -#if DM_VERSION >= 515 #define NAMEOF_STATIC(datum, X) (nameof(type::##X)) -#else -#define NAMEOF_STATIC(datum, X) (#X || ##datum.##X) -#endif diff --git a/code/_byond_version_compat.dm b/code/_byond_version_compat.dm index 26968f0f837c..c41fdc830e6e 100644 --- a/code/_byond_version_compat.dm +++ b/code/_byond_version_compat.dm @@ -1,56 +1,17 @@ // This file contains defines allowing targeting byond versions newer than the supported //Update this whenever you need to take advantage of more recent byond features -#define MIN_COMPILER_VERSION 514 -#define MIN_COMPILER_BUILD 1588 +#define MIN_COMPILER_VERSION 515 +#define MIN_COMPILER_BUILD 1627 #if (DM_VERSION < MIN_COMPILER_VERSION || DM_BUILD < MIN_COMPILER_BUILD) && !defined(SPACEMAN_DMM) && !defined(OPENDREAM) //Don't forget to update this part -#error Your version of BYOND is too out-of-date to compile this project. Go to https://secure.byond.com/download and update. -#error You need version 514.1588 or higher -#endif - -/* -#if (DM_VERSION == 514 && DM_BUILD > 1575 && DM_BUILD <= 1577) -#error Your version of BYOND currently has a crashing issue that will prevent you from running Dream Daemon test servers. -#error We require developers to test their content, so an inability to test means we cannot allow the compile. -#error Please consider downgrading to 514.1575 or lower. -#endif -*/ - -/* -// Keep savefile compatibilty at minimum supported level -#if DM_VERSION >= 515 -/savefile/byond_version = MIN_COMPILER_VERSION -#endif -*/ - -// 515 split call for external libraries into call_ext -#if DM_VERSION < 515 -#define LIBCALL call -#else -#define LIBCALL call_ext +#error Your version of BYOND is too out-of-date to compile this project. Go to https://www.byond.com/download and update. +#error You need version 515.1627 or higher #endif // So we want to have compile time guarantees these methods exist on local type, unfortunately 515 killed the .proc/procname and .verb/verbname syntax so we have to use nameof() // For the record: GLOBAL_VERB_REF would be useless as verbs can't be global. -#if DM_VERSION < 515 - -/// Call by name proc references, checks if the proc exists on either this type or as a global proc. -#define PROC_REF(X) (.proc/##X) -/// Call by name verb references, checks if the verb exists on either this type or as a global verb. -#define VERB_REF(X) (.verb/##X) - -/// Call by name proc reference, checks if the proc exists on either the given type or as a global proc -#define TYPE_PROC_REF(TYPE, X) (##TYPE.proc/##X) -/// Call by name verb reference, checks if the verb exists on either the given type or as a global verb -#define TYPE_VERB_REF(TYPE, X) (##TYPE.verb/##X) - -/// Call by name proc reference, checks if the proc is an existing global proc -#define GLOBAL_PROC_REF(X) (/proc/##X) - -#else - /// Call by name proc references, checks if the proc exists on either this type or as a global proc. #define PROC_REF(X) (nameof(.proc/##X)) /// Call by name verb references, checks if the verb exists on either this type or as a global verb. @@ -64,16 +25,4 @@ /// Call by name proc reference, checks if the proc is an existing global proc #define GLOBAL_PROC_REF(X) (/proc/##X) -#endif - -#if (DM_VERSION == 515) -/// fcopy will crash on 515 linux if given a non-existant file, instead of returning 0 like on 514 linux or 515 windows -/// var case matches documentation for fcopy. -/world/proc/__fcopy(Src, Dst) - if (istext(Src) && !fexists(Src)) - return 0 - return fcopy(Src, Dst) -#define fcopy(Src, Dst) world.__fcopy(Src, Dst) - -#endif diff --git a/code/_experiments.dm b/code/_experiments.dm index 6e5addb5f992..39c4c45e7eda 100644 --- a/code/_experiments.dm +++ b/code/_experiments.dm @@ -3,29 +3,7 @@ // Any flag you see here can be flipped with the `-D` CLI argument. // For example, if you want to enable EXPERIMENT_MY_COOL_FEATURE, compile with -DEXPERIMENT_MY_COOL_FEATURE -// EXPERIMENT_515_QDEL_HARD_REFERENCE -// - Hold a hard reference for qdeleted items, and check ref_count, rather than using refs. Requires 515+. - -// EXPERIMENT_515_DONT_CACHE_REF -// - Avoids `text_ref` caching, aided by improvements to ref() speed in 515. - -#if DM_VERSION < 515 - -// You can't X-macro custom names :( -#ifdef EXPERIMENT_515_QDEL_HARD_REFERENCE -#warn EXPERIMENT_515_QDEL_HARD_REFERENCE is only available on 515+ -#undef EXPERIMENT_515_QDEL_HARD_REFERENCE -#endif - -#ifdef EXPERIMENT_515_DONT_CACHE_REF -#warn EXPERIMENT_515_DONT_CACHE_REF is only available on 515+ -#undef EXPERIMENT_515_DONT_CACHE_REF -#endif - -#elif defined(UNIT_TESTS) - -//#define EXPERIMENT_515_QDEL_HARD_REFERENCE -#define EXPERIMENT_515_DONT_CACHE_REF +#if defined(UNIT_TESTS) #endif diff --git a/code/controllers/subsystem/garbage.dm b/code/controllers/subsystem/garbage.dm index e94d6b1aff1d..37c305d59cde 100644 --- a/code/controllers/subsystem/garbage.dm +++ b/code/controllers/subsystem/garbage.dm @@ -139,13 +139,6 @@ SUBSYSTEM_DEF(garbage) pass_counts[i] = 0 fail_counts[i] = 0 -#ifdef EXPERIMENT_515_QDEL_HARD_REFERENCE -// 1 from the hard reference in the queue, and 1 from the variable used before this -#define IS_DELETED(datum, _) (refcount(##datum) == 2) -#else -#define IS_DELETED(datum, gcd_at_time) (isnull(##datum) || ##datum.gc_destroyed != gcd_at_time) -#endif - /datum/controller/subsystem/garbage/proc/HandleQueue(level = GC_QUEUE_FILTER) if (level == GC_QUEUE_FILTER) delslasttick = 0 @@ -162,7 +155,7 @@ SUBSYSTEM_DEF(garbage) lastlevel = level - //We do this rather then for(var/refID in queue) because that sort of for loop copies the whole list. + //We do this rather then for(var/list/ref_info in queue) because that sort of for loop copies the whole list. //Normally this isn't expensive, but the gc queue can grow to 40k items, and that gets costly/causes overrun. for (var/i in 1 to length(queue)) var/list/L = queue[i] @@ -173,21 +166,15 @@ SUBSYSTEM_DEF(garbage) continue var/queued_at_time = L[GC_QUEUE_ITEM_QUEUE_TIME] - if(queued_at_time > cut_off_time) break // Everything else is newer, skip them count++ -#ifdef EXPERIMENT_515_QDEL_HARD_REFERENCE var/datum/D = L[GC_QUEUE_ITEM_REF] -#else - var/GCd_at_time = L[GC_QUEUE_ITEM_GCD_DESTROYED] - var/refID = L[GC_QUEUE_ITEM_REF] - var/datum/D - D = locate(refID) -#endif - - if (IS_DELETED(D, GCd_at_time)) // So if something else coincidently gets the same ref, it's not deleted by mistake + + // 1 from the hard reference in the queue, and 1 from the variable used before this + // If that's all we've got, send er off + if (refcount(D) == 2) ++gcedlasttick ++totalgcs pass_counts[level]++ @@ -221,11 +208,7 @@ SUBSYSTEM_DEF(garbage) var/type = D.type var/datum/qdel_item/I = items[type] - var/message = "## TESTING: GC: -- [text_ref(D)] | [type] was unable to be GC'd --" -#if DM_VERSION >= 515 - message = "[message] (ref count of [refcount(D)])" -#endif - log_world(message) + log_world("## TESTING: GC: -- [text_ref(D)] | [type] was unable to be GC'd -- (ref count of [refcount(D)])") #ifdef TESTING for(var/c in GLOB.admins) //Using testing() here would fill the logs with ADMIN_VV garbage @@ -261,8 +244,6 @@ SUBSYSTEM_DEF(garbage) queue.Cut(1,count+1) count = 0 -#undef IS_DELETED - /datum/controller/subsystem/garbage/proc/Queue(datum/D, level = GC_QUEUE_FILTER) if (isnull(D)) return @@ -271,20 +252,11 @@ SUBSYSTEM_DEF(garbage) return var/queue_time = world.time -#ifdef EXPERIMENT_515_QDEL_HARD_REFERENCE - var/refid = D -#else - var/refid = text_ref(D) -#endif - - var/static/uid = 0 - uid = WRAP(uid+1, 1, SHORT_REAL_LIMIT - 1) if (D.gc_destroyed <= 0) - D.gc_destroyed = uid + D.gc_destroyed = queue_time var/list/queue = queues[level] - - queue[++queue.len] = list(queue_time, refid, D.gc_destroyed) // not += for byond reasons + queue[++queue.len] = list(queue_time, D, D.gc_destroyed) // not += for byond reasons //this is mainly to separate things profile wise. /datum/controller/subsystem/garbage/proc/HardDelete(datum/D, force) diff --git a/code/datums/datum.dm b/code/datums/datum.dm index 7d497785a72a..3e317ffd601e 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -54,13 +54,6 @@ */ var/list/cooldowns -#ifndef EXPERIMENT_515_DONT_CACHE_REF - /// A cached version of our \ref - /// The brunt of \ref costs are in creating entries in the string tree (a tree of immutable strings) - /// This avoids doing that more then once per datum by ensuring ref strings always have a reference to them after they're first pulled - var/cached_ref -#endif - /// A weak reference to another datum var/datum/weakref/weak_reference diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index cf7a0a6bc1a8..97a25bf7d20a 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -79,7 +79,7 @@ recipe.resources[material] = I.matter[material] //Doesn't take more if it's just a sheet or something. Get what you put in. else recipe.resources[material] = round(I.matter[material]*1.25) // More expensive to produce than they are to recycle. - qdel(I) + QDEL_NULL(I) //Create parts for lathe. for(var/component in components) diff --git a/code/game/objects/items/devices/personal_data_transmitter.dm b/code/game/objects/items/devices/personal_data_transmitter.dm index 98f8c60452ea..b967aa9273ca 100644 --- a/code/game/objects/items/devices/personal_data_transmitter.dm +++ b/code/game/objects/items/devices/personal_data_transmitter.dm @@ -139,6 +139,7 @@ /obj/item/device/pdt_locator_tube/Destroy() linked_bracelet = null + QDEL_NULL(battery) return ..() /obj/item/clothing/accessory/pdt_bracelet diff --git a/code/game/objects/items/reagent_containers/food/snacks.dm b/code/game/objects/items/reagent_containers/food/snacks.dm index 79a108d24bf1..293a71ca7c5d 100644 --- a/code/game/objects/items/reagent_containers/food/snacks.dm +++ b/code/game/objects/items/reagent_containers/food/snacks.dm @@ -2744,6 +2744,10 @@ var/list/boxes = list() // If the boxes are stacked, they come here var/boxtag = "" +/obj/item/pizzabox/Destroy(force) + QDEL_NULL(pizza) + return ..() + /obj/item/pizzabox/update_icon() overlays = list() diff --git a/code/game/objects/structures/pipes/pipes.dm b/code/game/objects/structures/pipes/pipes.dm index 9f2b70c70661..fb51a605ee93 100644 --- a/code/game/objects/structures/pipes/pipes.dm +++ b/code/game/objects/structures/pipes/pipes.dm @@ -52,6 +52,7 @@ for(var/obj/structure/pipes/P in connected_to) P.remove_connection(src) + connected_to.Cut() GLOB.mainship_pipes -= src @@ -96,6 +97,7 @@ /obj/structure/pipes/proc/remove_connection(obj/structure/pipes/P) connected_to -= P + P.connected_to -= src /obj/structure/pipes/proc/get_connection(direction) var/obj/structure/pipes/best_connected_pipe = null diff --git a/code/game/world.dm b/code/game/world.dm index e55741ca71e5..5aecfe851051 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -14,7 +14,7 @@ GLOBAL_LIST_INIT(reboot_sfx, file2list("config/reboot_sfx.txt")) /world/New() var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") if (debug_server) - LIBCALL(debug_server, "auxtools_init")() + call_ext(debug_server, "auxtools_init")() enable_debugging() hub_password = "kMZy3U5jJHSiBQjr" @@ -367,7 +367,7 @@ GLOBAL_LIST_INIT(reboot_sfx, file2list("config/reboot_sfx.txt")) else CRASH("unsupported platform") - var/init = LIBCALL(lib, "init")() + var/init = call_ext(lib, "init")() if("0" != init) CRASH("[lib] init error: [init]") diff --git a/code/modules/admin/view_variables/reference_tracking.dm b/code/modules/admin/view_variables/reference_tracking.dm index f6f2b86f31d7..35f464354c72 100644 --- a/code/modules/admin/view_variables/reference_tracking.dm +++ b/code/modules/admin/view_variables/reference_tracking.dm @@ -28,9 +28,7 @@ var/starting_time = world.time -#if DM_VERSION >= 515 log_reftracker("Refcount for [type]: [refcount(src)]") -#endif //Time to search the whole game for our ref DoSearchVar(GLOB, "GLOB", search_time = starting_time) //globals diff --git a/code/modules/cm_phone/phone.dm b/code/modules/cm_phone/phone.dm index b4f13044bc20..231bf54475d3 100644 --- a/code/modules/cm_phone/phone.dm +++ b/code/modules/cm_phone/phone.dm @@ -362,7 +362,7 @@ GLOBAL_LIST_EMPTY_TYPED(transmitters, /obj/structure/transmitter) qdel(attached_to) else attached_to.attached_to = null - attached_to = null + attached_to = null GLOB.transmitters -= src SStgui.close_uis(src) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index a9000eec5c28..a678ceda165c 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -503,13 +503,13 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w if(slot in list(WEAR_L_HAND, WEAR_R_HAND)) set_gun_user(user) - if(HAS_TRAIT_FROM_ONLY(src, TRAIT_GUN_LIGHT_DEACTIVATED, user)) + if(HAS_TRAIT_FROM_ONLY(src, TRAIT_GUN_LIGHT_DEACTIVATED, WEAKREF(user))) force_light(on = TRUE) - REMOVE_TRAIT(src, TRAIT_GUN_LIGHT_DEACTIVATED, user) + REMOVE_TRAIT(src, TRAIT_GUN_LIGHT_DEACTIVATED, WEAKREF(user)) else set_gun_user(null) force_light(on = FALSE) - ADD_TRAIT(src, TRAIT_GUN_LIGHT_DEACTIVATED, user) + ADD_TRAIT(src, TRAIT_GUN_LIGHT_DEACTIVATED, WEAKREF(user)) return ..() diff --git a/code/modules/projectiles/guns/specialist/launcher/launcher.dm b/code/modules/projectiles/guns/specialist/launcher/launcher.dm index 70f00aa83c35..d0731b2d43bc 100644 --- a/code/modules/projectiles/guns/specialist/launcher/launcher.dm +++ b/code/modules/projectiles/guns/specialist/launcher/launcher.dm @@ -38,6 +38,10 @@ new preload(cylinder) update_icon() +/obj/item/weapon/gun/launcher/Destroy(force) + QDEL_NULL(cylinder) + return ..() + /obj/item/weapon/gun/launcher/verb/toggle_draw_mode() set name = "Switch Storage Drawing Method" set category = "Object" diff --git a/code/modules/reagents/chemistry_machinery/reagent_grinder.dm b/code/modules/reagents/chemistry_machinery/reagent_grinder.dm index 1de4a84451e1..3c596b6a79a2 100644 --- a/code/modules/reagents/chemistry_machinery/reagent_grinder.dm +++ b/code/modules/reagents/chemistry_machinery/reagent_grinder.dm @@ -68,7 +68,10 @@ /obj/structure/machinery/reagentgrinder/Destroy() cleanup() - . = ..() + + QDEL_NULL(beaker) + + return ..() /obj/structure/machinery/reagentgrinder/update_icon() icon_state = "juicer"+num2text(!isnull(beaker)) diff --git a/code/modules/vehicles/van/van.dm b/code/modules/vehicles/van/van.dm index 8bf114d6b4a8..a2e7d68bf9de 100644 --- a/code/modules/vehicles/van/van.dm +++ b/code/modules/vehicles/van/van.dm @@ -167,6 +167,8 @@ var/mob/M = I M.client.images -= normal_image + QDEL_NULL(lighting_holder) + return ..() diff --git a/dependencies.sh b/dependencies.sh index 69f16156b9d7..01d0ca5c976c 100644 --- a/dependencies.sh +++ b/dependencies.sh @@ -4,8 +4,8 @@ #Final authority on what's required to fully build the project # byond version -export BYOND_MAJOR=514 -export BYOND_MINOR=1588 +export BYOND_MAJOR=515 +export BYOND_MINOR=1627 #rust_g git tag export RUST_G_VERSION=2.1.0 @@ -15,9 +15,7 @@ export NODE_VERSION=14 export NODE_VERSION_PRECISE=14.16.1 # SpacemanDMM git tag -export SPACEMAN_DMM_VERSION=suite-1.7.2 +export SPACEMAN_DMM_VERSION=suite-1.8 # Python version for mapmerge and other tools export PYTHON_VERSION=3.7.9 - -export OPENDREAM_VERSION=tgs-min-compat diff --git a/tools/build/build.js b/tools/build/build.js index 2126cfd77d4c..9efee60ebd31 100644 --- a/tools/build/build.js +++ b/tools/build/build.js @@ -173,21 +173,30 @@ export const YarnTarget = new Juke.Target({ export const TgFontTarget = new Juke.Target({ dependsOn: [YarnTarget], inputs: [ - 'tgui/.yarn/install-target', - 'tgui/packages/tgfont/**/*.+(js|cjs|svg)', - 'tgui/packages/tgfont/package.json', + "tgui/.yarn/install-target", + "tgui/packages/tgfont/**/*.+(js|cjs|svg)", + "tgui/packages/tgfont/package.json", ], outputs: [ - 'tgui/packages/tgfont/dist/tgfont.css', - 'tgui/packages/tgfont/dist/tgfont.eot', - 'tgui/packages/tgfont/dist/tgfont.woff2', + "tgui/packages/tgfont/dist/tgfont.css", + "tgui/packages/tgfont/dist/tgfont.eot", + "tgui/packages/tgfont/dist/tgfont.woff2", ], executes: async () => { - await yarn('tgfont:build'); - fs.copyFileSync('tgui/packages/tgfont/dist/tgfont.css', 'tgui/packages/tgfont/static/tgfont.css'); - fs.copyFileSync('tgui/packages/tgfont/dist/tgfont.eot', 'tgui/packages/tgfont/static/tgfont.eot'); - fs.copyFileSync('tgui/packages/tgfont/dist/tgfont.woff2', 'tgui/packages/tgfont/static/tgfont.woff2'); - } + await yarn("tgfont:build"); + fs.copyFileSync( + "tgui/packages/tgfont/dist/tgfont.css", + "tgui/packages/tgfont/static/tgfont.css" + ); + fs.copyFileSync( + "tgui/packages/tgfont/dist/tgfont.eot", + "tgui/packages/tgfont/static/tgfont.eot" + ); + fs.copyFileSync( + "tgui/packages/tgfont/dist/tgfont.woff2", + "tgui/packages/tgfont/static/tgfont.woff2" + ); + }, }); export const TguiTarget = new Juke.Target({ @@ -303,8 +312,6 @@ export const CleanTarget = new Juke.Target({ dependsOn: [TguiCleanTarget], executes: async () => { Juke.rm("*.{dmb,rsc}"); - Juke.rm("*.mdme*"); - Juke.rm("*.m.*"); Juke.rm("maps/templates.dm"); }, }); diff --git a/tools/build/lib/byond.js b/tools/build/lib/byond.js index 8b6f081c1c01..2d186e2254c6 100644 --- a/tools/build/lib/byond.js +++ b/tools/build/lib/byond.js @@ -139,14 +139,47 @@ export const DreamMaker = async (dmeFile, options = {}) => { throw err; } }; - testOutputFile(`${dmeBaseName}.dmb`); - testOutputFile(`${dmeBaseName}.rsc`); - const runWithWarningChecks = async (dmeFile, args) => { - const execReturn = await Juke.exec(dmeFile, args); + + 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 ( - options.warningsAsErrors && - execReturn.combined.match(/\d+:warning: /) + 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 (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)) { Juke.logger.error(`Compile warnings treated as errors`); throw new Juke.ExitCode(2); } @@ -156,26 +189,11 @@ export const DreamMaker = async (dmeFile, options = {}) => { const { defines } = options; if (defines && defines.length > 0) { Juke.logger.info("Using defines:", defines.join(", ")); - try { - const injectedContent = defines.map((x) => `#define ${x}\n`).join(""); - fs.writeFileSync(`${dmeBaseName}.m.dme`, injectedContent); - const dmeContent = fs.readFileSync(`${dmeBaseName}.dme`); - fs.appendFileSync(`${dmeBaseName}.m.dme`, dmeContent); - await runWithWarningChecks(dmPath, [`${dmeBaseName}.m.dme`]); - fs.writeFileSync( - `${dmeBaseName}.dmb`, - fs.readFileSync(`${dmeBaseName}.m.dmb`) - ); - fs.writeFileSync( - `${dmeBaseName}.rsc`, - fs.readFileSync(`${dmeBaseName}.m.rsc`) - ); - } finally { - Juke.rm(`${dmeBaseName}.m.*`); - } - } else { - await runWithWarningChecks(dmPath, [dmeFile]); } + await runWithWarningChecks(dmPath, [ + ...defines.map((def) => `-D${def}`), + dmeFile, + ]); }; /**