From f8ed61b11ca78c16828deb64a57b8346fb3eb6ce Mon Sep 17 00:00:00 2001 From: Andres_Github <81278332+Slushi-Github@users.noreply.github.com> Date: Tue, 10 Nov 2026 12:24:31 -0400 Subject: [PATCH] Add another way to show the compilation progress Now you can define `HXCPP_PROGRESS_PERCENT` for see the compilation progress as a percentage --- tools/hxcpp/BuildTool.hx | 2 +- tools/hxcpp/Progress.hx | 32 ++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tools/hxcpp/BuildTool.hx b/tools/hxcpp/BuildTool.hx index 3bda4d3d..7fa8dc4d 100644 --- a/tools/hxcpp/BuildTool.hx +++ b/tools/hxcpp/BuildTool.hx @@ -688,7 +688,7 @@ class BuildTool } : null; Profile.push("compile"); - var progress = new Progress(to_be_compiled.length); + var progress = new Progress(to_be_compiled.length, mDefines.exists("HXCPP_PROGRESS_PERCENT")); if (threadPool==null) { for(file in to_be_compiled) diff --git a/tools/hxcpp/Progress.hx b/tools/hxcpp/Progress.hx index 0bbc560d..6a75642a 100644 --- a/tools/hxcpp/Progress.hx +++ b/tools/hxcpp/Progress.hx @@ -1,25 +1,33 @@ // How many of a group's files have compiled, shown before each file as it starts -class Progress -{ +class Progress { var finished:Int; var total:Int; + var usePercent:Bool; - public function new(inTotal:Int) - { + public function new(inTotal:Int, usePercent:Bool = false) { finished = 0; total = inTotal; + this.usePercent = usePercent; } - public function label():String - { - var done = Std.string(finished); - while (done.length < Std.string(total).length) - done = " " + done; - return "\x1b[1m[" + done + "/" + total + "]\x1b[0m"; + public function label():String { + if (usePercent) { + var percent = finished / total; + var pct = Std.int(percent * 1000) / 10; + var str = Std.string(pct); + if (Std.int(pct) == pct) { + str += ".0"; + } + return "\x1b[1m[" + str + "%]\x1b[0m"; + } else { + var done = Std.string(finished); + while (done.length < Std.string(total).length) + done = " " + done; + return "\x1b[1m[" + done + "/" + total + "]\x1b[0m"; + } } - public function fileDone() - { + public function fileDone() { Log.lock(); finished++; Log.unlock();