fix: decide a build step by its exit code, not by whether it printed
RunCommand merged stderr into stdout, dropped pclose's status and returned the text; every compile, link and archive site then read "printed something" as "failed". A warning is printing something, so a translation unit that warned failed the build — but only on the run that actually recompiled it, since warnings aren't re-emitted for an object that's already up to date. The same unchanged source therefore passed or failed depending on the state of the build tree: flaky-looking tests locally, and a cold CI checkout surfacing every latent warning in a project at once as unrelated failures. RunCommand is gone, replaced by RunBuildCommand: it goes through RunCommandChecked, returns "" when the command exited 0 (so every caller's `if (!result.empty())` error path is unchanged) and hands any warnings to the new Progress::Diagnostic instead of to the error path. That also closes the quiet half of the bug — a compiler killed by the OOM killer prints nothing, so it used to read as success and leave the build carrying on with a missing object; it now reports the signal that killed it. Warnings are now shown rather than swallowed, which they weren't in either direction before: invisible on an incremental build, fatal on a cold one. Failing on them stays a project's choice, via -Werror in compileFlags.
This commit is contained in:
parent
046b5eee61
commit
8e2d21a2bc
7 changed files with 77 additions and 64 deletions
|
|
@ -18,8 +18,18 @@ namespace Crafter {
|
|||
};
|
||||
std::string BuildStdPcm(const Configuration& config, fs::path stdPcm);
|
||||
fs::path GetCacheDir();
|
||||
std::string RunCommand(const std::string_view command);
|
||||
CommandResult RunCommandChecked(std::string_view command);
|
||||
// A compile / link / archive step. Success is the command's exit status,
|
||||
// never whether it printed anything: a warning does not stop the compiler
|
||||
// from writing a valid object, and warnings are only emitted when a
|
||||
// translation unit is actually recompiled — so keying failure off the
|
||||
// output made the same unchanged source pass or fail depending on whether
|
||||
// its object happened to be up to date.
|
||||
//
|
||||
// Returns an empty string on success (any warnings go to the user via
|
||||
// Progress::Diagnostic), otherwise the compiler's diagnostics. Callers
|
||||
// therefore keep the `if (!result.empty())` shape they already had.
|
||||
std::string RunBuildCommand(std::string_view command);
|
||||
export CRAFTER_API CommandResult RunCommandWithTimeout(std::string_view command, std::chrono::seconds timeout);
|
||||
std::string GetBaseCommand(const Configuration& config);
|
||||
export CRAFTER_API Configuration LoadProject(const fs::path& projectFile, std::span<const std::string_view> args);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ export namespace Crafter::Progress {
|
|||
// Verbose-mode command echo. No-op outside Verbose.
|
||||
CRAFTER_API void EchoCommand(std::string_view command);
|
||||
|
||||
// Non-fatal output from a build step that succeeded — compiler and linker
|
||||
// warnings. Erases the status line first so the text doesn't land on top of
|
||||
// it, then writes to stderr. No-op on Quiet.
|
||||
CRAFTER_API void Diagnostic(std::string_view text);
|
||||
|
||||
// Erase the in-place status line so subsequent stderr writes (errors,
|
||||
// banners) don't collide with it. No-op when not in TTY-redraw mode.
|
||||
CRAFTER_API void Clear();
|
||||
|
|
|
|||
Loading…
Reference in a new issue