11import haxe .io .Path ;
22import haxe .xml .Fast ;
3+ import haxe .Json ;
34import sys .io .Process ;
45import sys .FileSystem ;
56#if neko
@@ -58,7 +59,7 @@ class BuildTool
5859 try {
5960 make_contents = sys.io. File .getContent (inMakefile );
6061 } catch (e : Dynamic ) {
61- LogManager .error (" Could not open build file \" " + inMakefile + " \" " );
62+ Log .error (" Could not open build file \" " + inMakefile + " \" " );
6263 // println("Could not open build file '" + inMakefile + "'");
6364 // Sys.exit(1);
6465 }
@@ -91,20 +92,20 @@ class BuildTool
9192 }
9293 else
9394 {
94- LogManager .error (" Could not find compiler cache \" " + compileCache + " \" " );
95+ Log .error (" Could not find compiler cache \" " + compileCache + " \" " );
9596 // throw "Could not find compiler cache: " + compileCache;
9697 }
9798 }
9899
99100 if (useCache && (! mDefines .exists (" haxe_ver" ) && ! mDefines .exists (" HXCPP_DEPENDS_OK" )))
100101 {
101- LogManager .info (" " , " Ignoring compiler cache because of possible missing dependencies" );
102+ Log .info (" " , " Ignoring compiler cache because of possible missing dependencies" );
102103 useCache = false ;
103104 }
104105
105106 if (useCache )
106107 {
107- LogManager .info (" " , " Using compiler cache \" " + compileCache + " \" " );
108+ Log .info (" " , " Using compiler cache \" " + compileCache + " \" " );
108109 }
109110
110111 if (inTargets .remove (" clear" ))
@@ -124,12 +125,12 @@ class BuildTool
124125 // Sys.println("Build : " + inTarget );
125126 if (! mTargets .exists (inTarget ))
126127 {
127- LogManager .error (" Could not find build target \" " + inTarget + " \" " );
128+ Log .error (" Could not find build target \" " + inTarget + " \" " );
128129 // throw "Could not find target '" + inTarget + "' to build.";
129130 }
130131 if (mCompiler == null )
131132 {
132- LogManager .error (" No compiler defined for the current build target" );
133+ Log .error (" No compiler defined for the current build target" );
133134 // throw "No compiler defined";
134135 }
135136
@@ -162,8 +163,7 @@ class BuildTool
162163 if (target .mBuildDir != " " )
163164 {
164165 restoreDir = Sys .getCwd ();
165- Sys .println (target .mBuildDir );
166- LogManager .info (" " , " \x1b [1mChanging directory:\x1b [0m " + target .mBuildDir );
166+ Log .info (" " , " - \x1b [1mChanging directory:\x1b [0m " + target .mBuildDir );
167167 Sys .setCwd (target .mBuildDir );
168168 }
169169
@@ -270,7 +270,7 @@ class BuildTool
270270 case " linker" :
271271 if (! mLinkers .exists (target .mToolID ))
272272 {
273- LogManager .error (" Could not find linker for \" " + target .mToolID + " \" " );
273+ Log .error (" Could not find linker for \" " + target .mToolID + " \" " );
274274 // throw "Missing linker :\"" + target.mToolID + "\"";
275275 }
276276
@@ -289,12 +289,12 @@ class BuildTool
289289 // Sys.println("Build : " + inTarget );
290290 if (! mTargets .exists (inTarget ))
291291 {
292- LogManager .error (" Could not find build target \" " + inTarget + " \" " );
292+ Log .error (" Could not find build target \" " + inTarget + " \" " );
293293 // throw "Could not find target '" + inTarget + "' to build.";
294294 }
295295 if (mCompiler == null )
296296 {
297- LogManager .error (" No compiler defined" );
297+ Log .error (" No compiler defined" );
298298 // throw "No compiler defined";
299299 }
300300
@@ -308,7 +308,7 @@ class BuildTool
308308 if (target .mBuildDir != " " )
309309 {
310310 restoreDir = Sys .getCwd ();
311- LogManager .info (" " , " \x1b [1mChanging directory:\x1b [0m " + target .mBuildDir );
311+ Log .info (" " , " - \x1b [1mChanging directory:\x1b [0m " + target .mBuildDir );
312312 Sys .setCwd (target .mBuildDir );
313313 }
314314
@@ -361,11 +361,11 @@ class BuildTool
361361 }
362362 else if (! el .has .noerror )
363363 {
364- LogManager .error (" Could not find include file \" " + name + " \" " );
364+ Log .error (" Could not find include file \" " + name + " \" " );
365365 // throw "Could not find include file " + name;
366366 }
367367 default :
368- LogManager .error (" Unknown compiler option \" " + el .name + " \" " );
368+ Log .error (" Unknown compiler option \" " + el .name + " \" " );
369369 // throw "Unknown compiler option: '" + el.name + "'";
370370 }
371371 }
@@ -569,10 +569,10 @@ class BuildTool
569569 }
570570 else if (isLinux )
571571 {
572- result = ProcessManager .runProcess (" " , " nproc" , []);
572+ result = ProcessManager .runProcess (" " , " nproc" , [], true , false );
573573 if (result == null )
574574 {
575- var cpuinfo = ProcessManager .runProcess (" " , " cat" , [ " /proc/cpuinfo" ]);
575+ var cpuinfo = ProcessManager .runProcess (" " , " cat" , [ " /proc/cpuinfo" ], true , false );
576576 if (cpuinfo != null )
577577 {
578578 var split = cpuinfo .split (" processor" );
@@ -599,6 +599,19 @@ class BuildTool
599599 return Std .parseInt (result );
600600 }
601601 }
602+
603+ private static function getVersion (): String
604+ {
605+ try
606+ {
607+ var json = Json .parse (sys.io. File .getContent (PathManager .getHaxelib (" hxcpp" ) + " /haxelib.json" ));
608+ return json .version ;
609+ }
610+ catch (e : Dynamic )
611+ {
612+ return " 0.0.0" ;
613+ }
614+ }
602615
603616 public static function isMsvc ()
604617 {
@@ -618,7 +631,7 @@ class BuildTool
618631 var args = Sys .args ();
619632 var env = Sys .environment ();
620633
621- LogManager .verbose = env .exists (" HXCPP_VERBOSE" );
634+ Log .verbose = env .exists (" HXCPP_VERBOSE" );
622635
623636 // Check for calling from haxelib ...
624637 if (args .length > 0 )
@@ -662,10 +675,10 @@ class BuildTool
662675 else
663676 defines .set (val ," " );
664677 if (val == " verbose" )
665- LogManager .verbose = true ;
678+ Log .verbose = true ;
666679 }
667680 else if (arg == " -v" || arg == " -verbose" )
668- LogManager .verbose = true ;
681+ Log .verbose = true ;
669682 else if (arg .substr (0 ,2 )== " -I" )
670683 include_path .push (PathManager .standardize (arg .substr (2 )));
671684 else if (makefile .length == 0 )
@@ -686,14 +699,14 @@ class BuildTool
686699 {
687700 if (! defines .exists (" HXCPP" ))
688701 {
689- LogManager .error (" Please run hxcpp using haxelib" );
702+ Log .error (" Please run hxcpp using haxelib" );
690703 // throw "HXCPP not set, and not run from haxelib";
691704 }
692705 HXCPP = PathManager .standardize (defines .get (" HXCPP" ));
693706 defines .set (" HXCPP" ,HXCPP );
694707 }
695708
696- LogManager .info (" " , " HXCPP : " + HXCPP );
709+ // Log .info("", "HXCPP : " + HXCPP);
697710
698711 include_path .push (" ." );
699712 if (env .exists (" HOME" ))
@@ -724,20 +737,20 @@ class BuildTool
724737
725738 if (defines .exists (" ios" ))
726739 {
727- if (defines .exists (" simulator" ))
728- {
729- defines .set (" iphonesim" , " iphonesim" );
730- }
731- else if (! defines .exists (" iphonesim" ))
732- {
733- defines .set (" iphoneos" , " iphoneos" );
734- }
735- defines .set (" iphone" , " iphone" );
740+ if (defines .exists (" simulator" ))
741+ {
742+ defines .set (" iphonesim" , " iphonesim" );
743+ }
744+ else if (! defines .exists (" iphonesim" ))
745+ {
746+ defines .set (" iphoneos" , " iphoneos" );
747+ }
748+ defines .set (" iphone" , " iphone" );
736749 }
737750
738751 if (defines .exists (" iphoneos" ))
739752 {
740- defines .set (" toolchain" ," iphoneos" );
753+ defines .set (" toolchain" ," iphoneos" );
741754 defines .set (" iphone" ," iphone" );
742755 defines .set (" apple" ," apple" );
743756 defines .set (" BINDIR" ," iPhone" );
@@ -765,7 +778,7 @@ class BuildTool
765778 defines .set (" ANDROID_HOST" ," linux-x86" );
766779 else
767780 {
768- LogManager .error (" Unknown android host \" " + os + " \" " );
781+ Log .error (" Unknown android host \" " + os + " \" " );
769782 // throw "Unknown android host:" + os;
770783 }
771784 }
@@ -965,13 +978,40 @@ class BuildTool
965978
966979 if (targets .length == 0 )
967980 targets .push (" default" );
968-
981+
982+ if (makefile == " " || Log .verbose )
983+ {
984+ Log .println (" \x1b [33;1m __ " );
985+ Log .println (" /\\ \\ " );
986+ Log .println (" \\ \\ \\ ___ __ _ ___ _____ _____ " );
987+ Log .println (" \\ \\ _ `\\ /\\ \\ /'\\ /'___\\ /\\ '__`\\ /\\ '__`\\ " );
988+ Log .println (" \\ \\ \\ \\ \\\\ /> <//\\ \\ __/\\ \\ \\ L\\ \\ \\ \\ L\\ \\ " );
989+ Log .println (" \\ \\ _\\ \\ _\\ /\\ _/\\ _\\ \\ ____\\\\ \\ ,__/\\ \\ ,__/" );
990+ Log .println (" \\ /_/\\ /_/\\ //\\ /_/\\ /____/ \\ \\ \\ / \\ \\ \\ / " );
991+ Log .println (" \\ \\ _\\ \\ \\ _\\ " );
992+ Log .println (" \\ /_/ \\ /_/ \x1b [0m" );
993+ Log .println (" " );
994+ Log .println (" \x1b [1mhxcpp \x1b [0m\x1b [3;37m(Haxe C++ Runtime Support)\x1b [0m \x1b [1m(" + getVersion () + " )\x1b [0m" );
995+ Log .println (" " );
996+ }
997+
969998 if (makefile == " " )
970999 {
971- LogManager .info (" Usage : BuildTool makefile.xml [-DFLAG1] ... [-DFLAGN] ... [target1]...[targetN]" );
1000+ Log .println (" \x1b [33;1mUsage:\x1b [0m\x1b [1m haxelib run hxcpp\x1b [0m Build.xml \x1b [3;37m[options]\x1b [0m" );
1001+ Log .println (" " );
1002+ Log .println (" \x1b [33;1mOptions:\x1b [0m " );
1003+ Log .println (" " );
1004+ Log .println (" \x1b [1m-D\x1b [0;3mvalue\x1b [0m -- Specify a define to use when processing other commands" );
1005+ Log .println (" \x1b [1m-verbose\x1b [0m -- Print additional information (when available)" );
1006+ Log .println (" " );
9721007 }
9731008 else
9741009 {
1010+ Log .info (" " , " \x1b [33;1mUsing makefile: " + makefile + " \x1b [0m" );
1011+ Log .info (" " , " \x1b [33;1mReading HXCPP config: " + defines .get (" HXCPP_CONFIG" ) + " \x1b [0m" );
1012+ Log .info (" " , " \x1b [33;1mUsing target toolchain: " + defines .get (" toolchain" ) + " \x1b [0m" );
1013+ if (Log .verbose ) Log .println (" " );
1014+
9751015 for (e in env .keys ())
9761016 defines .set (e , Sys .getEnv (e ) );
9771017
@@ -1002,7 +1042,7 @@ class BuildTool
10021042 var name = substitute (el .att .name );
10031043 Setup .setup (name ,mDefines );
10041044 case " echo" :
1005- LogManager .info (substitute (el .att .value ));
1045+ Log .info (substitute (el .att .value ));
10061046 case " setenv" :
10071047 var name = el .att .name ;
10081048 var value = substitute (el .att .value );
@@ -1013,7 +1053,7 @@ class BuildTool
10131053 throw (error );
10141054 case " path" :
10151055 var path = substitute (el .att .name );
1016- LogManager .info (" " , " Adding path " + path );
1056+ Log .info (" " , " Adding path " + path );
10171057 var os = Sys .systemName ();
10181058 var sep = mDefines .exists (" windows_host" ) ? " ;" : " :" ;
10191059 var add = path + sep + Sys .getEnv (" PATH" );
@@ -1047,7 +1087,7 @@ class BuildTool
10471087 }
10481088 else if (! el .has .noerror )
10491089 {
1050- LogManager .error (" Could not find include file \" " + name + " \" " );
1090+ Log .error (" Could not find include file \" " + name + " \" " );
10511091 // throw "Could not find include file " + name;
10521092 }
10531093 case " target" :
0 commit comments