Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f315353

Browse files
committed
Merge branch 'patch-2' of https://github.com/jgranick/hxcpp into jgranick-patch-2
Conflicts: run.n
2 parents 5a43903 + f5a9c45 commit f315353

13 files changed

Lines changed: 186 additions & 170 deletions

File tree

build-tool/BuildCommon.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<xml>
22

3-
<echo value="Using config : ${HXCPP_CONFIG}" if="verbose" />
4-
53
<set name="DBG" value="-debug" if="debug"/>
64
<set name="M64" value="64" if="HXCPP_M64"/>
75
<set name="F32" value="-f32" if="HXCPP_FLOAT32"/>

run.n

6.02 KB
Binary file not shown.

tools/run/BuildTool.hx

Lines changed: 77 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import haxe.io.Path;
22
import haxe.xml.Fast;
3+
import haxe.Json;
34
import sys.io.Process;
45
import 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" :

tools/run/Compiler.hx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ class Compiler
121121
if (FileSystem.exists(cacheName))
122122
{
123123
sys.io.File.copy(cacheName, obj_name);
124-
LogManager.info("use cache for " + obj_name + "(" + md5 + ")" );
124+
Log.info("use cache for " + obj_name + "(" + md5 + ")" );
125125
found = true;
126126
}
127127
else
128128
{
129-
LogManager.info("", " not in cache " + cacheName);
129+
Log.info("", " not in cache " + cacheName);
130130
}
131131
}
132132
else
@@ -169,7 +169,7 @@ class Compiler
169169
if (cacheName!=null)
170170
{
171171
sys.io.File.copy(obj_name, cacheName);
172-
LogManager.info("", " caching " + cacheName);
172+
Log.info("", " caching " + cacheName);
173173
}
174174
}
175175

@@ -190,9 +190,9 @@ class Compiler
190190
}
191191

192192
var versionString = Setup.readStderr(exe,args).join(" ");
193-
LogManager.info("", "--- Compiler version ---");
194-
LogManager.info("", versionString);
195-
LogManager.info("", "------------------------");
193+
Log.info("", "--- Compiler version ---");
194+
Log.info("", versionString);
195+
Log.info("", "------------------------");
196196

197197
mCompilerVersion = Md5.encode(versionString);
198198
mCached = true;
@@ -224,7 +224,7 @@ class Compiler
224224
var dir = inObjDir + "/" + inGroup.getPchDir() + "/";
225225
var pch_name = dir + file + mPCHExt;
226226

227-
//LogManager.info("", "Make pch dir " + dir );
227+
//Log.info("", "Make pch dir " + dir );
228228
PathManager.mkdir(dir);
229229

230230
if (mPCH!="gcc")
@@ -243,14 +243,14 @@ class Compiler
243243
}
244244
else
245245
{
246-
//LogManager.info("", "Creating PCH directory \"" + dir + header + "\"");
246+
//Log.info("", "Creating PCH directory \"" + dir + header + "\"");
247247
PathManager.mkdir(dir + header);
248248
args.push( "-o" );
249249
args.push(pch_name);
250250
args.push( inGroup.mPrecompiledHeaderDir + "/" + inGroup.mPrecompiledHeader + ".h" );
251251
}
252252

253-
//LogManager.info("Creating " + pch_name + "...");
253+
//Log.info("Creating " + pch_name + "...");
254254

255255
var split = mExe.split (" ");
256256
var exe = split.shift ();
@@ -261,7 +261,7 @@ class Compiler
261261
{
262262
if (FileSystem.exists(pch_name))
263263
FileSystem.deleteFile(pch_name);
264-
LogManager.error("Could not create PCH");
264+
Log.error("Could not create PCH");
265265
//throw "Error creating pch: " + result + " - build cancelled";
266266
}
267267
}

tools/run/File.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class File
5151
var source_name = mDir+mName;
5252
if (!FileSystem.exists(source_name))
5353
{
54-
LogManager.error("Could not find source file \"" + source_name + "\"");
54+
Log.error("Could not find source file \"" + source_name + "\"");
5555
//throw "Could not find source '" + source_name + "'";
5656
}
5757
var source_stamp = FileSystem.stat(source_name).mtime.getTime();
@@ -61,7 +61,7 @@ class File
6161
{
6262
if (!FileSystem.exists(depend))
6363
{
64-
LogManager.error("Could not find dependency \"" + depend + "\" for \"" + mName + "\"");
64+
Log.error("Could not find dependency \"" + depend + "\" for \"" + mName + "\"");
6565
//throw "Could not find dependency '" + depend + "' for '" + mName + "'";
6666
}
6767
if (FileSystem.stat(depend).mtime.getTime() > obj_stamp )

0 commit comments

Comments
 (0)