checkVersion tag

This commit is contained in:
Ne_Eo
2024-07-22 11:14:11 +02:00
parent 79ff4f8636
commit 0cc19d482c
8 changed files with 63 additions and 63 deletions
+5 -5
View File
@@ -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);
+1 -1
View File
@@ -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();
+5 -5
View File
@@ -17,11 +17,11 @@ class Utils {
condition = condition.replace('&&', '&').replace('||', '|').replace(" ", "");
var stack:Array<Dynamic> = [];
final stack:Array<Dynamic> = [];
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<Dynamic>):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;
+4 -4
View File
@@ -4,17 +4,17 @@ import sys.io.File;
class Optimizer {
public static function main(args:Array<String>) {
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);
+45 -45
View File
@@ -8,10 +8,10 @@ import sys.FileSystem;
class Setup {
public static function main(args:Array<String>) {
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<Event> = [];
var libsXML:Access = new Access(Xml.parse(File.getContent(libFile)).firstElement());
final events:Array<Event> = [];
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;
}
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<libraries>
<libraries checkVersion="update || all">
<if cond="update || all">
<print pretty="true">Preparing installation...</print>
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<libraries>
<libraries checkVersion="false">
<if cond="time-fix">
<print pretty="true">Switching to branch 'time-fix'...</print>
<cmd inLib="lime" cmd="git checkout time-fix" />
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<libraries>
<libraries checkVersion="false">
<print pretty="true">Setting up dev libs...</print>
<cmd>