From 0cc19d482c28397752942a62e0dce2d694ea06e8 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Mon, 22 Jul 2024 11:14:11 +0200 Subject: [PATCH 1/2] checkVersion tag --- commandline/ArgParser.hx | 10 ++-- commandline/Main.hx | 2 +- commandline/Utils.hx | 10 ++-- commandline/commands/Optimizer.hx | 8 +-- commandline/commands/Setup.hx | 90 +++++++++++++++---------------- libs.xml | 2 +- setup-dev-branch.xml | 2 +- setup-dev.xml | 2 +- 8 files changed, 63 insertions(+), 63 deletions(-) diff --git a/commandline/ArgParser.hx b/commandline/ArgParser.hx index 61ff15b8..94ddcaac 100644 --- a/commandline/ArgParser.hx +++ b/commandline/ArgParser.hx @@ -17,18 +17,18 @@ class ArgParser { this.args = args; this.options = new Map(); - var copy = args.copy(); + final copy = args.copy(); var i = 0; while(copy.length > 0) { var arg = copy.shift(); // this parses the -NAME=VALUE if (arg.startsWith("-")) { var key = arg.substr(1); - var isLongKey = key.startsWith("-"); + final isLongKey = key.startsWith("-"); if (isLongKey) { key = key.substr(1); } - var split = key.split("="); + final split = key.split("="); var longName = split.shift(); if(!isLongKey) { // Allow -ABC to be parsed as -A -B -C @@ -43,8 +43,8 @@ class ArgParser { // Parse the last option with value support } - var name = rename(longName); - var value = (split.length > 0) ? split.join("=") : null; + final name = rename(longName); + final value = (split.length > 0) ? split.join("=") : null; options.set(name, value); args.splice(i, 1); diff --git a/commandline/Main.hx b/commandline/Main.hx index df51e641..1a1db23c 100644 --- a/commandline/Main.hx +++ b/commandline/Main.hx @@ -131,7 +131,7 @@ class Main { public static function main() { initCommands(); - var args = Sys.args(); + final args = Sys.args(); var commandName = args.shift(); if (commandName != null) commandName = commandName.toLowerCase(); diff --git a/commandline/Utils.hx b/commandline/Utils.hx index 20216822..3cc94a40 100644 --- a/commandline/Utils.hx +++ b/commandline/Utils.hx @@ -17,11 +17,11 @@ class Utils { condition = condition.replace('&&', '&').replace('||', '|').replace(" ", ""); - var stack:Array = []; + final stack:Array = []; var i = 0; while (i < condition.length) { - var char = condition.charAt(i); + final char = condition.charAt(i); switch (char) { case '(': @@ -32,7 +32,7 @@ class Utils { if (condition.charAt(j) == '(') balance++; if (condition.charAt(j) == ')') balance--; } - var subExpr = condition.substr(i + 1, j - i - 1); + final subExpr = condition.substr(i + 1, j - i - 1); stack.push(evaluateArgsCondition(subExpr, args)); i = j; case '&', '|': @@ -55,8 +55,8 @@ class Utils { public static function evaluate(stack:Array):Bool { var result = stack.shift(); while (stack.length > 0) { - var op = stack.shift(); - var next = stack.shift(); + final op = stack.shift(); + final next = stack.shift(); switch(op) { case '&': result = result && next; diff --git a/commandline/commands/Optimizer.hx b/commandline/commands/Optimizer.hx index b82d9182..a30d2949 100644 --- a/commandline/commands/Optimizer.hx +++ b/commandline/commands/Optimizer.hx @@ -4,17 +4,17 @@ import sys.io.File; class Optimizer { public static function main(args:Array) { - var args = ArgParser.parse(args); - var saveOld = args.existsOption("no-old"); + final args = ArgParser.parse(args); + final saveOld = !args.existsOption("no-old"); if(args.length == 0) { Sys.println(Main.curCommand.dDoc); return; } - var filename = args.get(0); + final filename = args.get(0); - var data = File.getContent(filename); + final data = File.getContent(filename); var json = null; try { json = haxe.Json.parse(data); diff --git a/commandline/commands/Setup.hx b/commandline/commands/Setup.hx index 9f53b448..94af0a43 100644 --- a/commandline/commands/Setup.hx +++ b/commandline/commands/Setup.hx @@ -8,10 +8,10 @@ import sys.FileSystem; class Setup { public static function main(args:Array) { - var args = ArgParser.parse(args, ["S" => "silent-progress", "silent" => "silent-progress"]); - var CHECK_VSTUDIO = !args.existsOption("no-vscheck"); - var REINSTALL_ALL = args.existsOption("reinstall"); - var SILENT = args.existsOption("silent-progress"); + final args = ArgParser.parse(args, ["S" => "silent-progress", "silent" => "silent-progress"]); + final CHECK_VSTUDIO = !args.existsOption("no-vscheck"); + final REINSTALL_ALL = args.existsOption("reinstall"); + final SILENT = args.existsOption("silent-progress"); // to prevent messing with currently installed libs if (!FileSystem.exists('.haxelib')) @@ -35,13 +35,13 @@ class Setup { return; } - var events:Array = []; - var libsXML:Access = new Access(Xml.parse(File.getContent(libFile)).firstElement()); + final events:Array = []; + final libsXML:Access = new Access(Xml.parse(File.getContent(libFile)).firstElement()); function handleLib(libNode:Access) { switch(libNode.name) { case "lib" | "git": - var lib:Library = { + final lib:Library = { name: libNode.att.name, type: libNode.name }; @@ -58,7 +58,6 @@ class Setup { data: lib }); case "cmd": - events.push({ type: CMD, data: { @@ -89,20 +88,21 @@ class Setup { } } - var platform = switch(Sys.systemName()) { + final platform = switch(Sys.systemName()) { case "Windows": "windows"; case "Mac": "mac"; case "Linux": "linux"; case def: def.toLowerCase(); } - var defines = args.args.copy(); + final defines = args.args.copy(); defines.push(platform); + defines.push("true"); if(args.args.length == 0) defines.push("all"); function parse(libNode:Access) { if(libNode.name == "if") { - var cond = libNode.att.cond; + final cond = libNode.att.cond; if(!Utils.evaluateArgsCondition(cond, defines)) { return; } @@ -115,6 +115,8 @@ class Setup { } } + final shouldCheckHaxeVersion = !libsXML.has.checkVersion || Utils.evaluateArgsCondition(libsXML.att.checkVersion, defines); + for (libNode in libsXML.elements) { parse(libNode); } @@ -139,14 +141,14 @@ class Setup { prettyPrint('Cannot resolve library of type "${lib.type}"'); } case CMD: - var cmd:CmdData = event.data; - var lib = cmd.inLib; - var oldCwd = Sys.getCwd(); + final cmd:CmdData = event.data; + final lib = cmd.inLib; + final oldCwd = Sys.getCwd(); if(lib != null) { - var libPrefix = '.haxelib/$lib'; + final libPrefix = '.haxelib/$lib'; if(FileSystem.exists(libPrefix)) { if(FileSystem.exists(libPrefix + '/.dev')) { // haxelib dev - var devPath = File.getContent(libPrefix + '/.dev'); + final devPath = File.getContent(libPrefix + '/.dev'); if(!FileSystem.exists(devPath)) { Sys.println('Cannot find dev path $devPath for $lib'); Sys.setCwd(oldCwd); @@ -154,7 +156,7 @@ class Setup { } Sys.setCwd(devPath); } else if(FileSystem.exists(libPrefix + '/.current')) { - var version = StringTools.replace(File.getContent(libPrefix + '/.current'), ".", ","); + final version = StringTools.replace(File.getContent(libPrefix + '/.current'), ".", ","); if(!FileSystem.exists(libPrefix + '/$version')) { Sys.println('Cannot find version $version of $lib'); Sys.setCwd(oldCwd); @@ -169,13 +171,13 @@ class Setup { } } for(line in cmd.lines) { - var line = StringTools.replace(line, "$PLATFORM", platform); + final line = StringTools.replace(line, "$PLATFORM", platform); //Sys.println(line); Sys.command(line); } Sys.setCwd(oldCwd); case PRINT: - var data:PrintData = event.data; + final data:PrintData = event.data; if(data.pretty) prettyPrint(data.text); else @@ -183,30 +185,28 @@ class Setup { } } - /*var proc = new Process('haxe --version'); - proc.exitCode(true); - var haxeVer = proc.stdout.readLine(); - if (haxeVer != "4.2.5") { - // check for outdated haxe - var curHaxeVer = [for(v in haxeVer.split(".")) Std.parseInt(v)]; - var requiredHaxeVer = [4, 2, 5]; - for(i in 0...requiredHaxeVer.length) { - if (curHaxeVer[i] < requiredHaxeVer[i]) { - prettyPrint("!! WARNING !!"); - Sys.println("Your current Haxe version is outdated."); - Sys.println('You\'re using ${haxeVer}, while the required version is 4.2.5.'); - Sys.println('The engine may not compile with your current version of Haxe.'); - Sys.println('We recommend upgrading to 4.2.5'); - break; - } else if (curHaxeVer[i] > requiredHaxeVer[i]) { - prettyPrint("!! WARNING !!" - + "\nUsing Haxe 4.3.0 and above is currently not recommended due to lack of testing."); - Sys.println(''); - Sys.println('We recommend downgrading back to 4.2.5.'); - break; + if(shouldCheckHaxeVersion) { + final proc = new Process('haxe --version'); + proc.exitCode(true); + final haxeVer = proc.stdout.readLine(); + if (haxeVer != "4.2.5" || haxeVer != "4.3.4") { + // check for outdated haxe + final curHaxeVer = [for(v in haxeVer.split(".")) Std.parseInt(v)]; + final requiredHaxeVer = [4, 2, 5]; + for(i in 0...requiredHaxeVer.length) { + if (curHaxeVer[i] < requiredHaxeVer[i]) { + prettyPrint([ + "!! WARNING !!", + "Your current Haxe version is outdated.", + 'You\'re using ${haxeVer}, whilst the required version is 4.2.5 or newer.', + 'The engine may not compile with your current version of Haxe.', + 'We recommend upgrading to 4.2.5 or newer' + ].join("\n")); + break; + } } } - }*/ + } // vswhere.exe its used to find any visual studio related installations on the system, including full visual studio ide installations, visual studio build tools installations, and other related components - Nex if (CHECK_VSTUDIO && Compiler.getBuildTarget().toLowerCase() == "windows" && new Process('"C:/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" -property catalog_productDisplayVersion').exitCode(true) == 1) { @@ -224,7 +224,7 @@ class Setup { } public static function prettyPrint(text:String) { - var lines = text.split("\n"); + final lines = text.split("\n"); var length = -1; for(line in lines) if(line.length > length) @@ -242,9 +242,9 @@ class Setup { public static function centerText(text:String, width:Int):String { - var centerOffset = (width - text.length) / 2; - var left = repeat(' ', Math.floor(centerOffset)); - var right = repeat(' ', Math.ceil(centerOffset)); + final centerOffset = (width - text.length) / 2; + final left = repeat(' ', Math.floor(centerOffset)); + final right = repeat(' ', Math.ceil(centerOffset)); return left + text + right; } diff --git a/libs.xml b/libs.xml index 7d3715b5..3e3e7b56 100644 --- a/libs.xml +++ b/libs.xml @@ -1,5 +1,5 @@ - + Preparing installation... diff --git a/setup-dev-branch.xml b/setup-dev-branch.xml index b28b3da5..b940c5c2 100644 --- a/setup-dev-branch.xml +++ b/setup-dev-branch.xml @@ -1,5 +1,5 @@ - + Switching to branch 'time-fix'... diff --git a/setup-dev.xml b/setup-dev.xml index c1c4fad3..010bee50 100644 --- a/setup-dev.xml +++ b/setup-dev.xml @@ -1,5 +1,5 @@ - + Setting up dev libs... From 719cb576830c314cdb3f5ea55a7603ba39aeb9fe Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Mon, 22 Jul 2024 11:18:40 +0200 Subject: [PATCH 2/2] Fix Version check --- commandline/commands/Setup.hx | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/commandline/commands/Setup.hx b/commandline/commands/Setup.hx index 94af0a43..f259f46f 100644 --- a/commandline/commands/Setup.hx +++ b/commandline/commands/Setup.hx @@ -189,21 +189,21 @@ class Setup { final proc = new Process('haxe --version'); proc.exitCode(true); final haxeVer = proc.stdout.readLine(); - if (haxeVer != "4.2.5" || haxeVer != "4.3.4") { - // check for outdated haxe - final curHaxeVer = [for(v in haxeVer.split(".")) Std.parseInt(v)]; - final requiredHaxeVer = [4, 2, 5]; - for(i in 0...requiredHaxeVer.length) { - if (curHaxeVer[i] < requiredHaxeVer[i]) { - prettyPrint([ - "!! WARNING !!", - "Your current Haxe version is outdated.", - 'You\'re using ${haxeVer}, whilst the required version is 4.2.5 or newer.', - 'The engine may not compile with your current version of Haxe.', - 'We recommend upgrading to 4.2.5 or newer' - ].join("\n")); - break; - } + + // check for outdated haxe + final curHaxeVer = [for(v in haxeVer.split(".")) Std.parseInt(v)]; + final minumumVersion = [4, 2, 5]; + for(i in 0...minumumVersion.length) { + if (curHaxeVer[i] > minumumVersion[i]) break; + if (curHaxeVer[i] < minumumVersion[i]) { + prettyPrint([ + "!! WARNING !!", + "Your current Haxe version is outdated.", + 'You\'re using ${haxeVer}, whilst the required version is 4.2.5 or newer.', + 'The engine may not compile with your current version of Haxe.', + 'We recommend upgrading to 4.2.5 or newer' + ].join("\n")); + break; } } }