Skip to content

Commit

Permalink
compile fix attemp 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Blundir committed Mar 21, 2024
1 parent d3be841 commit b51822b
Showing 1 changed file with 5 additions and 71 deletions.
76 changes: 5 additions & 71 deletions tools/build/lib/byond.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@ import { regQuery } from './winreg.js';
*/
let dmPath;

const getDmPath = async (namedVersion) => {
// Use specific named version
if(namedVersion) {
return getNamedByondVersionPath(namedVersion);
}
const getDmPath = async () => {
if (dmPath) {
return dmPath;
}
dmPath = await (async () => {
// Search in array of paths
const paths = [
...((process.env.DM_EXE && process.env.DM_EXE.split(',')) || []),
...getDefaultNamedByondVersionPath(),
'C:\\Program Files\\BYOND\\bin\\dm.exe',
'C:\\Program Files (x86)\\BYOND\\bin\\dm.exe',
['reg', 'HKLM\\Software\\Dantom\\BYOND', 'installpath'],
Expand Down Expand Up @@ -63,69 +58,15 @@ const getDmPath = async (namedVersion) => {
return dmPath;
};



const getNamedByondVersionPath = (namedVersion) =>{
const all_entries = getAllNamedDmVersions(true)
const map_entry = all_entries.find(x => x.name === namedVersion);
if(map_entry === undefined){
Juke.logger.error(`No named byond version with name "${namedVersion}" found.`);
throw new Juke.ExitCode(1);
}
return map_entry.path;
}

const getDefaultNamedByondVersionPath = () =>{
const all_entries = getAllNamedDmVersions(false)
const map_entry = all_entries.find(x => x.default == true);
if(map_entry === undefined)
return []
return [map_entry.path];
}


/** @type {[{ name, path, default }]} */
let namedDmVersionList;
export const NamedVersionFile = "tools/build/dm_versions.json"

const getAllNamedDmVersions = (throw_on_fail) => {
if(!namedDmVersionList){
if(!fs.existsSync(NamedVersionFile)){
if(throw_on_fail){
Juke.logger.error(`No byond version map file found.`);
throw new Juke.ExitCode(1);
}
namedDmVersionList = []
return namedDmVersionList;
}
try{
namedDmVersionList = JSON.parse(fs.readFileSync(NamedVersionFile));
}
catch(err){
if(throw_on_fail){
Juke.logger.error(`Failed to parse byond version map file. ${err}`);
throw new Juke.ExitCode(1);
}
namedDmVersionList = []
return namedDmVersionList;
}
}
return namedDmVersionList;
}

/**
* @param {string} dmeFile
* @param {{
* defines?: string[];
* warningsAsErrors?: boolean;
* namedDmVersion?: string;
* }} options
*/
export const DreamMaker = async (dmeFile, options = {}) => {
if(options.namedDmVersion !== null){
Juke.logger.info('Using named byond version:', options.namedDmVersion);
}
const dmPath = await getDmPath(options.namedDmVersion);
const dmPath = await getDmPath();
// Get project basename
const dmeBaseName = dmeFile.replace(/\.dme$/, '');
// Make sure output files are writable
Expand Down Expand Up @@ -179,17 +120,10 @@ export const DreamMaker = async (dmeFile, options = {}) => {
}
};


/**
* @param {{
* dmbFile: string;
* namedDmVersion?: string;
* }} options
*/
export const DreamDaemon = async (options, ...args) => {
const dmPath = await getDmPath(options.namedDmVersion);
export const DreamDaemon = async (dmbFile, ...args) => {
const dmPath = await getDmPath();
const baseDir = path.dirname(dmPath);
const ddExeName = process.platform === 'win32' ? 'dreamdaemon.exe' : 'DreamDaemon';
const ddExePath = baseDir === '.' ? ddExeName : path.join(baseDir, ddExeName);
return Juke.exec(ddExePath, [options.dmbFile, ...args]);
return Juke.exec(ddExePath, [dmbFile, ...args]);
};

0 comments on commit b51822b

Please sign in to comment.