From bd219e38a3e9a1a5047ce41d8cd01210bef3af43 Mon Sep 17 00:00:00 2001 From: martipops Date: Fri, 9 Oct 2026 16:52:17 -0400 Subject: [PATCH] fix: drive compile progress from ninja's [done/total] counter (#285) The compile slice advanced a fixed step per line of build output, so how far it moved depended on how many lines the build printed. When aurora and its dependencies are compiled locally (as on macOS) the bar reached its cap long before the game itself was compiled. Read ninja's edge counter instead. --- .../InstallProgress.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Launcher/WiiCompiled.Setup.Linux/InstallProgress.cs b/Launcher/WiiCompiled.Setup.Linux/InstallProgress.cs index e816e62..0517dc5 100644 --- a/Launcher/WiiCompiled.Setup.Linux/InstallProgress.cs +++ b/Launcher/WiiCompiled.Setup.Linux/InstallProgress.cs @@ -184,18 +184,31 @@ internal sealed class BuildProgressWindow } // Anything else - a plain MKWCBUILD note, or raw tool output - stays a diagnostic and only - // feeds the heartbeat below. + // feeds the compile progress below. _reporter.Diagnostic(line); - // Compilation announces itself once and then emits thousands of compiler lines. Treat that - // output as a heartbeat so the slice keeps creeping forward, but only publish a progress - // line when the rounded percentage actually changes. - if (_fraction >= CompileFraction) + // Compilation announces itself once and then ninja prefixes every edge with [done/total]. + // Follow that counter rather than counting lines: how many lines a build prints depends on + // whether aurora and its dependencies are prebuilt (AppImage) or compiled here (macOS), so a + // fixed per-line step reached the top long before the game itself compiled. + if (_fraction >= CompileFraction && TryParseNinjaProgress(line, out var done, out var total)) { - _fraction = Math.Min(0.97, _fraction + 0.0015); + _fraction = Math.Max(_fraction, CompileFraction + (0.97 - CompileFraction) * done / total); Emit(); } } + private static bool TryParseNinjaProgress(string line, out int done, out int total) + { + done = total = 0; + if (!line.StartsWith('[')) return false; + var close = line.IndexOf(']'); + var slash = line.IndexOf('/'); + return close > 0 && slash > 0 && slash < close + && int.TryParse(line.AsSpan(1, slash - 1), out done) + && int.TryParse(line.AsSpan(slash + 1, close - slash - 1), out total) + && total > 0 && done <= total; + } + private void Emit() { var percent = Interpolate(_fraction);