Skip to content

Commit f0f97dc

Browse files
Add HXCPP_PROGRESS_PERCENT to show compile progress as a percentage (#433)
With HXCPP_PROGRESS_PERCENT defined, the build tool shows each group's progress as a percentage of its files, [42.5% ], instead of a count, [425/1000]. The percentage is padded to the width of 100.0% so the file names after it stay in one column. Co-authored-by: Chris Speciale <christopher.gaf@gmail.com>
1 parent a125493 commit f0f97dc

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎Changes.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
libhxcpp 6.0.0 (unreleased)
33
------------------------------------------------------------
44

5+
* Added HXCPP_PROGRESS_PERCENT, which shows a group's compile progress as a percentage of its files, [42.5% ], instead of a count, [425/1000]
56
* Fixed a program on Linux with glibc staying as large as its largest burst of large allocations, such as the files a game reads while it loads: glibc keeps a freed buffer's memory in its heap unless it had mapped the buffer on its own, and once a buffer mapped on its own has been freed it stops mapping those of that size or less, up to 32 MB. The memory of the large buffers a collection freed then stayed the process's. The collector now trims the C heap once 16 MB has been freed to it, on the thread that frees the buffers. A program that dropped 384 MB of 4 MB buffers stayed at 396 MB resident and now returns to 12 MB
67
* Fixed a native extension that includes hx/CFFI.h before hx/CFFIPrime.h, as SteamWrap does, failing to compile with hxs_encoding, hxs_utf16 and alloc_hxs_utf8 not declared: CFFI.h included first declares the CFFI API without HXCPP_PRIME, so without the Prime string functions that the ordinary wrapper of a DEFINE_PRIME function now uses. CFFIPrime.h declares them then
78
* Made the collector's thread context on Linux a __thread pointer, read with one load from the thread pointer, instead of a call to pthread_getspecific each time an allocation leaves the inline path or a String or number is boxed. It was 3 to 4% of an OpenFL game's main thread. HXCPP_PTHREAD_FAST_TLS keeps pthread_getspecific (libhxcpp #429)

‎docs/build_xml/Defines.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Other defines:
8181
| *HXCPP_QUIET* | Print less output from the build tool |
8282
| *HXCPP_SILENT* | Print only errors from the build tool |
8383
| *HXCPP_COMPILE_THREADS* | Number of files to compile at once (also read from the environment) |
84+
| *HXCPP_PROGRESS_PERCENT* | Show a group's progress as a percentage of its files, instead of a count |
8485
| *HXCPP_COMPILE_CACHE* | Directory for the compile cache, usually set in the environment. See [CompileCache.md](../CompileCache.md) |
8586
| *HXCPP_TIMES* | Show some basic profiling information |
8687
| *HXCPP_NEKO_BUILDTOOL* | Force use of hxcpp.n, rather than compiled BuildTool.exe

‎tools/hxcpp/BuildTool.hx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ class BuildTool
688688
} : null;
689689

690690
Profile.push("compile");
691-
var progress = new Progress(to_be_compiled.length);
691+
var progress = new Progress(to_be_compiled.length, mDefines.exists("HXCPP_PROGRESS_PERCENT"));
692692
if (threadPool==null)
693693
{
694694
for(file in to_be_compiled)

‎tools/hxcpp/Progress.hx‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1-
// How many of a group's files have compiled, shown before each file as it starts
1+
// How many of a group's files have compiled, shown before each file as it
2+
// starts: a count, or with HXCPP_PROGRESS_PERCENT a percentage
23
class Progress
34
{
45
var finished:Int;
56
var total:Int;
7+
var percent:Bool;
68

7-
public function new(inTotal:Int)
9+
public function new(inTotal:Int, inPercent = false)
810
{
911
finished = 0;
1012
total = inTotal;
13+
percent = inPercent;
1114
}
1215

1316
public function label():String
1417
{
18+
if (percent)
19+
{
20+
// Pad to the width of 100.0% so the file names line up
21+
var tenths = total > 0 ? Std.int(finished * 1000 / total) : 1000;
22+
var done = Std.int(tenths / 10) + "." + (tenths % 10) + "%";
23+
while (done.length < 6)
24+
done = done + " ";
25+
return "\x1b[1m[" + done + "]\x1b[0m";
26+
}
1527
var done = Std.string(finished);
1628
while (done.length < Std.string(total).length)
1729
done = " " + done;

0 commit comments

Comments
 (0)