Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hide_success and hide_progress options #135

Merged
merged 5 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ pub struct Build {

/// Output files.
pub outs: BuildOuts,

/// True if output of command should be hidden on successful completion.
pub hide_success: bool,
/// True if last line of output should not be shown in status.
pub hide_last_line: bool,
}
impl Build {
pub fn new(loc: FileLoc, ins: BuildIns, outs: BuildOuts) -> Self {
Expand All @@ -188,6 +193,8 @@ impl Build {
ins,
discovered_ins: Vec::new(),
outs,
hide_success: false,
hide_last_line: false,
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,17 @@ impl Loader {
}),
_ => bail!("rspfile and rspfile_content need to be both specified"),
};
let hide_success = lookup("hide_success").as_deref() == Some("1");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the precedent for boolean flags in ninja is the "restat = 1" flag, where it is just a presence/absence check rather than requiring an explicit "1", so maybe we should follow that here?

https://github.com/ninja-build/ninja/blob/2a34463e6ec38dab909af94740070d546354b16c/src/graph.cc#L515

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

yeah the docs say "if present, ..." for these kinds of flags

let hide_last_line = lookup("hide_last_line").as_deref() == Some("1");

build.cmdline = cmdline;
build.desc = desc;
build.depfile = depfile;
build.parse_showincludes = parse_showincludes;
build.rspfile = rspfile;
build.pool = pool;
build.hide_success = hide_success;
build.hide_last_line = hide_last_line;

self.graph.add_build(build)
}
Expand Down
2 changes: 2 additions & 0 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ impl<'text> Parser<'text> {
| "rspfile"
| "rspfile_content"
| "msvc_deps_prefix"
| "hide_success"
| "hide_last_line"
)
})?;
Ok(Rule { name, vars })
Expand Down
2 changes: 1 addition & 1 deletion src/progress_fancy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl FancyState {
// Show task name, status, and output.
let buf = &mut self.pending;
match result.termination {
Termination::Success if result.output.is_empty() => {
Termination::Success if result.output.is_empty() || build.hide_success => {
// Common case: don't show anything.
return;
}
Expand Down
5 changes: 4 additions & 1 deletion src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ impl Runner {
let depfile = build.depfile.clone().map(PathBuf::from);
let rspfile = build.rspfile.clone();
let parse_showincludes = build.parse_showincludes;
let hide_last_line = build.hide_last_line;

let tid = self.tids.claim();
let tx = self.tx.clone();
Expand All @@ -226,7 +227,9 @@ impl Runner {
parse_showincludes,
rspfile.as_ref(),
|line| {
let _ = tx.send(Message::Output((id, line.to_owned())));
if !hide_last_line {
let _ = tx.send(Message::Output((id, line.to_owned())));
}
},
)
.unwrap_or_else(|err| TaskResult {
Expand Down
Loading