Skip to content

Commit 2753969

Browse files
committed
fix(build): avoid rewriting cmake include files and hide re-running cmake noise
1 parent 89cf1f0 commit 2753969

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/cmake/CMakeBuild.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ namespace vix::cli::build
392392
if (!progressOnly)
393393
return true;
394394

395+
if (line == "ninja: no work to do.")
396+
return false;
397+
398+
if (line.find("Re-running CMake...") != std::string::npos)
399+
return false;
400+
395401
if (line.rfind("FAILED:", 0) == 0)
396402
return true;
397403

src/commands/BuildCommand.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ namespace vix::commands::BuildCommand
9191
return m;
9292
}
9393

94+
static bool write_if_different(const fs::path &path, const std::string &content)
95+
{
96+
if (util::file_exists(path))
97+
{
98+
const std::string current = util::read_text_file_or_empty(path);
99+
if (current == content)
100+
return true;
101+
}
102+
103+
return util::write_text_file_atomic(path, content);
104+
}
105+
94106
static std::optional<process::Preset> resolve_preset(const std::string &name)
95107
{
96108
const auto presets = builtin_presets();
@@ -760,7 +772,7 @@ namespace vix::commands::BuildCommand
760772
const std::string globalPackagesCMake =
761773
build::make_global_packages_cmake(globalPackages);
762774

763-
if (!util::write_text_file_atomic(globalPackagesFile, globalPackagesCMake))
775+
if (!write_if_different(globalPackagesFile, globalPackagesCMake))
764776
{
765777
error("Failed to write global packages file: " + globalPackagesFile.string());
766778
hint("Check filesystem permissions.");
@@ -776,7 +788,7 @@ namespace vix::commands::BuildCommand
776788
if (!opt_.targetTriple.empty())
777789
{
778790
tc = build::toolchain_contents_for_triple(opt_.targetTriple, opt_.sysroot);
779-
if (!util::write_text_file_atomic(plan_.toolchainFile, tc))
791+
if (!write_if_different(plan_.toolchainFile, tc))
780792
{
781793
error("Failed to write toolchain file: " + plan_.toolchainFile.string());
782794
hint("Check filesystem permissions.");

0 commit comments

Comments
 (0)