Skip to content

Commit da1974f

Browse files
Show compile progress in the build tool
Each group now says how many files it compiles, and each file, as it starts, how many of the group's files have finished, as [3/40]. The count goes up when a compile completes, under the log lock, so it holds with several compile threads, and it shows with one thread too. Based on HaxeFoundation/hxcpp#1140 by @NeeEoo and HaxeFoundation/hxcpp#1423 by @MRK2009 Fixes #38
1 parent d1d9316 commit da1974f

4 files changed

Lines changed: 38 additions & 6 deletions

File tree

‎Changes.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ The first libhxcpp version. It is based on hxcpp 4.3 (the changes listed under 4
208208
* Fixed TLS certificate verification failing on iOS and tvOS, which have no root store to load: a chain mbedTLS cannot trust is judged by the system's trust, and a wrong hostname, an expired certificate or a bad signature is still an error (hxcpp #1331, #570)
209209
* Added the arm64 macOS Cppia host to releases, in bin/MacArm64, and project/compile-cppia.hxml builds the host's own architecture unless one is given (hxcpp #1149)
210210
* Changed the build tool to decide on colour from the terminal's environment instead of running tput, to honour NO_COLOR, and to take HXCPP_COLOR to force colour on (hxcpp #1146)
211+
* Added compile progress to the build tool: each group says how many files it compiles, and each file how many of them have finished (hxcpp #1140, #1423)
211212
* Added the libhxcpp define: a build that uses the library gets -D libhxcpp=<version>. Compare it with version("x.y.z"); a plain string comparison compares text
212213
* Added separate Linux ARMv7 and ARM64 build architectures (hxcpp #1355)
213214
* Fixed AndroidCompat.cpp closing its extern "C" section in the wrong place (hxcpp #1404)

‎tools/hxcpp/BuildTool.hx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ class BuildTool
603603
first = false;
604604
Log.lock();
605605
Log.println("");
606-
Log.info("\x1b[33;1mCompiling group: " + group.mId + "\x1b[0m");
606+
Log.info("\x1b[33;1mCompiling group: " + group.mId + " (" + to_be_compiled.length + " file" + (to_be_compiled.length==1 ? "" : "s") + ")\x1b[0m");
607607
var message = "\x1b[1m" + (nvcc ? getNvcc() : mCompiler.mExe) + "\x1b[0m";
608608
var flags = group.mCompilerFlags;
609609
if (!nvcc)
@@ -639,10 +639,11 @@ class BuildTool
639639
} : null;
640640

641641
Profile.push("compile");
642+
var progress = new Progress(to_be_compiled.length);
642643
if (threadPool==null)
643644
{
644645
for(file in to_be_compiled)
645-
mCompiler.compile(file,-1,groupHeader,pchStamp);
646+
mCompiler.compile(file,-1,groupHeader,pchStamp,progress);
646647
}
647648
else
648649
{
@@ -658,7 +659,7 @@ class BuildTool
658659
break;
659660
var file = to_be_compiled[index];
660661

661-
compiler.compile(file,threadId,groupHeader,pchStamp);
662+
compiler.compile(file,threadId,groupHeader,pchStamp,progress);
662663
}
663664
});
664665
}

‎tools/hxcpp/Compiler.hx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ class Compiler
358358
catch(e:Dynamic) { }
359359
}
360360

361-
public function compile(inFile:File,inTid:Int,headerFunc:Void->Void,pchTimeStamp:Null<Float>)
361+
public function compile(inFile:File,inTid:Int,headerFunc:Void->Void,pchTimeStamp:Null<Float>,inProgress:Progress)
362362
{
363363
var obj_name = getObjName(inFile);
364364
var args = getArgs(inFile);
@@ -460,7 +460,7 @@ class Compiler
460460
{
461461
if (!Log.verbose)
462462
{
463-
Log.info(fileName);
463+
Log.info(" " + inProgress.label() + fileName);
464464
}
465465
var err = ProcessManager.runProcessThreaded(exe, args, null);
466466
cleanTmp(tmpFile);
@@ -470,13 +470,15 @@ class Compiler
470470
FileSystem.deleteFile(obj_name);
471471
BuildTool.setThreadError(err);
472472
}
473+
else
474+
inProgress.fileDone();
473475
}
474476
}
475477
else
476478
{
477479
if (!Log.verbose)
478480
{
479-
Log.info(fileName);
481+
Log.info(" " + inProgress.label() + fileName);
480482
}
481483
var result = ProcessManager.runProcessThreaded(exe, args, null);
482484
cleanTmp(tmpFile);
@@ -487,6 +489,7 @@ class Compiler
487489
Tools.exit (result);
488490
//throw "Error : " + result + " - build cancelled";
489491
}
492+
inProgress.fileDone();
490493
}
491494

492495
if (cacheName!=null && !useCacheInPlace)

‎tools/hxcpp/Progress.hx‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// How many of a group's files have compiled, shown before each file as it starts
2+
class Progress
3+
{
4+
var finished:Int;
5+
var total:Int;
6+
7+
public function new(inTotal:Int)
8+
{
9+
finished = 0;
10+
total = inTotal;
11+
}
12+
13+
public function label():String
14+
{
15+
var done = Std.string(finished);
16+
while (done.length < Std.string(total).length)
17+
done = " " + done;
18+
return "\x1b[1m[" + done + "/" + total + "]\x1b[0m";
19+
}
20+
21+
public function fileDone()
22+
{
23+
Log.lock();
24+
finished++;
25+
Log.unlock();
26+
}
27+
}

0 commit comments

Comments
 (0)