@@ -12,6 +12,8 @@ import src.compilers.HaxeCompiler;
1212
1313import src .utils .LibsManager ;
1414
15+ using StringTools ;
16+
1517/**
1618 * The main compiler, it will start the compilation of the project
1719 * in Haxe and Wii U.
@@ -25,11 +27,74 @@ class MainCompiler {
2527 * Starts the compilation of the project.
2628 */
2729 public static function start (arg2 : String , arg3 : String ): Void {
28- if (SlushiUtils .parseVersion (Main .version ) < SlushiUtils .parseVersion (JsonFile .getJson ().programVersion )) {
29- SlushiUtils .printMsg (" The current version of HxCompileU is older than the one in the JSON file, consider updating it." , WARN );
30+ var jsonVersion : String = JsonFile .getJson ().programVersion ;
31+ var forced : Bool = jsonVersion .endsWith (" :forced" );
32+ var versionStr = forced ? jsonVersion .split (" :" )[0 ] : jsonVersion ;
33+
34+ var operatorStr : String = " " ;
35+ var versionValue : String = versionStr ;
36+
37+ if (versionStr .startsWith (" >=" )) {
38+ operatorStr = " >=" ;
39+ versionValue = versionStr .substr (2 );
40+ } else if (versionStr .startsWith (" >" )) {
41+ operatorStr = " >" ;
42+ versionValue = versionStr .substr (1 );
43+ } else if (versionStr .startsWith (" <=" )) {
44+ operatorStr = " <=" ;
45+ versionValue = versionStr .substr (2 );
46+ } else if (versionStr .startsWith (" <" )) {
47+ operatorStr = " <" ;
48+ versionValue = versionStr .substr (1 );
49+ }
50+
51+ var parsedJsonVersion = SlushiUtils .parseVersion (versionValue );
52+ var currentVersion = SlushiUtils .parseVersion (Main .version );
53+
54+ var versionMismatch : Bool = false ;
55+ var shouldStop : Bool = false ;
56+
57+ if (operatorStr == " >=" ) {
58+ if (currentVersion < parsedJsonVersion ) {
59+ versionMismatch = true ;
60+ shouldStop = true ; // Stop if current version is less than required
61+ }
62+ // If currentVersion >= parsedJsonVersion, continue
63+ } else if (operatorStr == " >" ) {
64+ if (currentVersion <= parsedJsonVersion ) {
65+ versionMismatch = true ;
66+ shouldStop = true ; // Stop if current version is less or equal
67+ }
68+ } else if (operatorStr == " <=" ) {
69+ if (currentVersion > parsedJsonVersion ) {
70+ versionMismatch = true ;
71+ shouldStop = true ; // Stop if current version is greater than required
72+ }
73+ // If currentVersion <= parsedJsonVersion, continue
74+ } else if (operatorStr == " <" ) {
75+ if (currentVersion >= parsedJsonVersion ) {
76+ versionMismatch = true ;
77+ shouldStop = true ; // Stop if current version is greater or equal
78+ }
79+ } else {
80+ if (currentVersion < parsedJsonVersion ) {
81+ SlushiUtils .printMsg (" The current version of HxCompileU is older than the one in the JSON file, consider updating it." , WARN );
82+ if (forced ) {
83+ versionMismatch = true ;
84+ shouldStop = true ; // Stop if forced
85+ }
86+ } else if (currentVersion > parsedJsonVersion ) {
87+ SlushiUtils .printMsg (" The current version of HxCompileU is newer than the one in the JSON file, consider checking the JSON file." , WARN );
88+ if (forced ) {
89+ versionMismatch = true ;
90+ shouldStop = true ; // Stop if forced
91+ }
92+ }
3093 }
31- else if (SlushiUtils .parseVersion (Main .version ) > SlushiUtils .parseVersion (JsonFile .getJson ().programVersion )) {
32- SlushiUtils .printMsg (" The current version of HxCompileU is newer than the one in the JSON file, consider checking the JSON file." , WARN );
94+
95+ if (shouldStop ) {
96+ SlushiUtils .printMsg (" Cannot continue: The JSON requires a specific version of HxCompileU: " + jsonVersion , ERROR );
97+ return ;
3398 }
3499
35100 // Check and get required libs
0 commit comments