@@ -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