Skip to content

Commit dfb9dae

Browse files
committed
fix(build): show live configure heartbeat
2 parents 72935e3 + 8a0586f commit dfb9dae

2 files changed

Lines changed: 65 additions & 8 deletions

File tree

src/cmake/CMakeBuild.cpp

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,20 +288,30 @@ namespace vix::cli::build
288288

289289
const bool filterCMakeSummary = is_configure_cmd(argv) && !cmakeVerbose;
290290

291+
const bool isConfigure = is_configure_cmd(argv);
292+
291293
const bool heartbeatEnabled = [&]() -> bool
292294
{
293295
if (quiet)
294296
return false;
295297

298+
/*
299+
* Configure can stay silent for a long time when CMake FetchContent
300+
* downloads dependencies. Keep a heartbeat enabled by default for
301+
* configure, while still allowing explicit control through the env var.
302+
*/
296303
const char *v = vix::utils::vix_getenv("VIX_BUILD_HEARTBEAT");
297-
if (!v)
298-
return false;
304+
if (!v || !*v)
305+
return isConfigure;
299306

300307
std::string s(v);
301308
s = util::trim(s);
302309
for (char &c : s)
303310
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
304311

312+
if (s == "0" || s == "false" || s == "no" || s == "off")
313+
return false;
314+
305315
return (s == "1" || s == "true" || s == "yes" || s == "on");
306316
}();
307317

@@ -353,6 +363,7 @@ namespace vix::cli::build
353363

354364
std::string currentProgressLine;
355365
bool progressVisible = false;
366+
bool heartbeatVisible = false;
356367
std::size_t lastRenderedWidth = 0;
357368
std::string lastRenderedProgressLine;
358369
auto lastProgressRenderTs = std::chrono::steady_clock::now();
@@ -565,6 +576,17 @@ namespace vix::cli::build
565576
lastRenderedProgressLine.clear();
566577
};
567578

579+
auto finish_heartbeat_line = [&]() -> void
580+
{
581+
if (quiet || !heartbeatVisible)
582+
return;
583+
584+
const std::string newline = "\n";
585+
write_all_fd(STDOUT_FILENO, newline.data(), newline.size());
586+
587+
heartbeatVisible = false;
588+
};
589+
568590
auto should_echo_line = [&](const std::string &line) -> bool
569591
{
570592
if (quiet)
@@ -670,6 +692,7 @@ namespace vix::cli::build
670692
{
671693
line.push_back('\n');
672694
write_all_fd(STDOUT_FILENO, line.data(), line.size());
695+
heartbeatVisible = true;
673696
}
674697

675698
start = nl + 1;
@@ -702,10 +725,43 @@ namespace vix::cli::build
702725
if (progressVisible)
703726
clear_progress_line();
704727

705-
std::string msg =
706-
"[building] still running... (" + util::format_seconds(elapsedMs) + ")";
707-
msg.push_back('\n');
708-
write_all_fd(STDOUT_FILENO, msg.data(), msg.size());
728+
std::string msg;
729+
730+
if (isConfigure)
731+
{
732+
msg =
733+
" " +
734+
std::string(style::CYAN) +
735+
"configure" +
736+
style::RESET +
737+
" still running... " +
738+
style::GRAY +
739+
"(" + util::format_seconds(elapsedMs) + ", checking/downloading dependencies)" +
740+
style::RESET;
741+
}
742+
else
743+
{
744+
msg =
745+
" " +
746+
std::string(style::CYAN) +
747+
"build" +
748+
style::RESET +
749+
" still running... " +
750+
style::GRAY +
751+
"(" + util::format_seconds(elapsedMs) + ")" +
752+
style::RESET;
753+
}
754+
755+
const std::size_t width = terminal_width();
756+
757+
std::string line;
758+
line += "\r";
759+
line.append(width, ' ');
760+
line += "\r";
761+
line += truncate_progress_text(msg, width);
762+
763+
write_all_fd(STDOUT_FILENO, line.data(), line.size());
764+
heartbeatVisible = true;
709765

710766
if (!currentProgressLine.empty())
711767
render_progress_line(currentProgressLine);
@@ -761,6 +817,7 @@ namespace vix::cli::build
761817
}
762818

763819
r.capturedFirstLine = util::trim(firstLine);
820+
finish_heartbeat_line();
764821
return r;
765822
}
766823

src/commands/BuildCommand.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,8 +2367,8 @@ namespace vix::commands::BuildCommand
23672367
out << " -h, --help Show this help\n\n";
23682368

23692369
out << "Environment variables:\n";
2370-
out << " VIX_BUILD_HEARTBEAT=1 Enable build heartbeat when no output is produced\n";
2371-
out << " for several seconds (disabled by default)\n\n";
2370+
out << " VIX_BUILD_HEARTBEAT=0 Disable configure/build heartbeat\n";
2371+
out << " VIX_BUILD_HEARTBEAT=1 Force heartbeat when no output is produced\n\n";
23722372

23732373
out << "Examples:\n";
23742374
out << " vix build\n";

0 commit comments

Comments
 (0)