diff --git a/tools/hxcpp/BuildTool.hx b/tools/hxcpp/BuildTool.hx index cd5a48f5b..35c40a0f7 100644 --- a/tools/hxcpp/BuildTool.hx +++ b/tools/hxcpp/BuildTool.hx @@ -600,7 +600,7 @@ class BuildTool first = false; Log.lock(); Log.println(""); - Log.info("\x1b[33;1mCompiling group: " + group.mId + "\x1b[0m"); + Log.info("\x1b[33;1mCompiling group: " + group.mId + " (" + to_be_compiled.length + " file" + (to_be_compiled.length==1 ? "" : "s") + ")\x1b[0m"); var message = "\x1b[1m" + (nvcc ? getNvcc() : mCompiler.mExe) + "\x1b[0m"; var flags = group.mCompilerFlags; if (!nvcc) @@ -636,10 +636,15 @@ class BuildTool } : null; Profile.push("compile"); + + var compile_progress = null; + if (!Log.verbose) + compile_progress = new Progress(0,to_be_compiled.length); + if (threadPool==null) { for(file in to_be_compiled) - mCompiler.compile(file,-1,groupHeader,pchStamp); + mCompiler.compile(file,-1,groupHeader,pchStamp,compile_progress); } else { @@ -655,7 +660,7 @@ class BuildTool break; var file = to_be_compiled[index]; - compiler.compile(file,threadId,groupHeader,pchStamp); + compiler.compile(file,threadId,groupHeader,pchStamp,compile_progress); } }); } diff --git a/tools/hxcpp/Compiler.hx b/tools/hxcpp/Compiler.hx index 8afdc4bbe..33182190d 100644 --- a/tools/hxcpp/Compiler.hx +++ b/tools/hxcpp/Compiler.hx @@ -1,6 +1,14 @@ import haxe.crypto.Md5; import haxe.io.Path; import sys.FileSystem; +#if haxe4 +import sys.thread.Mutex; +#elseif cpp +import cpp.vm.Mutex; +#else +import neko.vm.Mutex; +#end + using StringTools; private class FlagInfo @@ -358,7 +366,9 @@ class Compiler catch(e:Dynamic) { } } - public function compile(inFile:File,inTid:Int,headerFunc:Void->Void,pchTimeStamp:Null) + static public var printMutex = new Mutex(); + + public function compile(inFile:File,inTid:Int,headerFunc:Void->Void,pchTimeStamp:Null,inProgress:Null) { var obj_name = getObjName(inFile); var args = getArgs(inFile); @@ -439,29 +449,44 @@ class Compiler if (delayedFilename!=null) args.push(delayedFilename); - var tagInfo = inFile.mTags==null ? "" : " " + inFile.mTags.split(","); - - var fileName = inFile.mName; - var split = fileName.split ("/"); - if (split.length > 1) + if (!Log.verbose && (inTid >= 0 && BuildTool.threadExitCode == 0)) { - fileName = " \x1b[2m-\x1b[0m \x1b[33m" + split.slice(0, split.length - 1).join("/") + "/\x1b[33;1m" + split[split.length - 1] + "\x1b[0m"; - } - else - { - fileName = " \x1b[2m-\x1b[0m \x1b[33;1m" + fileName + "\x1b[0m"; - } - fileName += " \x1b[3m" + tagInfo + "\x1b[0m"; + printMutex.acquire(); + + var tagInfo = inFile.mTags == null ? "" : "\x1b[3m" + inFile.mTags.split(",") + "\x1b[0m"; + var fileName = inFile.mName; + var split = fileName.split("/"); + + if (split.length > 1) + { + fileName = split.slice(0, split.length - 1).join("/") + "/"; + fileName = "\x1b[33m" + fileName + "\x1b[33;1m" + split[split.length - 1] + "\x1b[0m"; + } + else + { + fileName = "\x1b[33;1m" + fileName + "\x1b[0m"; + } + + var output = ""; + + if (inProgress != null) + { + inProgress.current++; + + output = ['-', inProgress.getFormattedProgress(), fileName, tagInfo].join(" "); + } + else + output = ['-', fileName, tagInfo].join(" "); + Log.info(output); + + printMutex.release(); + } if (inTid >= 0) { if (BuildTool.threadExitCode == 0) { - if (!Log.verbose) - { - Log.info(fileName); - } var err = ProcessManager.runProcessThreaded(exe, args, null); cleanTmp(tmpFile); if (err!=0) @@ -474,10 +499,6 @@ class Compiler } else { - if (!Log.verbose) - { - Log.info(fileName); - } var result = ProcessManager.runProcessThreaded(exe, args, null); cleanTmp(tmpFile); if (result!=0) diff --git a/tools/hxcpp/Progress.hx b/tools/hxcpp/Progress.hx new file mode 100644 index 000000000..563bf5061 --- /dev/null +++ b/tools/hxcpp/Progress.hx @@ -0,0 +1,37 @@ +package; + +class Progress +{ + public var current:Int; + public var total:Int; + + public function new(inCurrent:Int, inTotal:Int) + { + current = inCurrent; + total = inTotal; + } + + public function getProgress():String + { + var percent = current / total; + var pct = Std.int(percent * 1000) / 10; + var progress = Std.string(pct); + + if (Std.int(pct) == pct) + progress += ".0"; + + return progress + "%"; + } + + public function getFormattedProgress():String + { + var progress = getProgress(); + + var spaces = ""; + + while ((spaces.length + progress.length) < 6) + spaces += " "; + + return "\x1b[1m[\x1b[0m" + spaces + "\x1b[33;1m" + progress + "\x1b[0m\x1b[1m]\x1b[0m"; + } +} \ No newline at end of file