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

Conversation

dae
Copy link
Contributor

@dae dae commented Feb 16, 2025

This is an implementation of the output suppression I mentioned in #68 (comment), and is related to #101. We've been using it in our project for the last year or so (1), and have been very happy with the balance of immediate output without overwhelming amounts of text being shown (2). I present it here not for immediate inclusion, but to rekindle discussion, as functionality like this would be nice to have in a stock n2 in the future.

(1) I've just rebased our version over the latest code

(2) One minor papercut is that certain terminal formatting codes can sometimes cause the progress output to render incorrectly, such as in the wrong color. But that's not an issue introduced by these changes.

@evmar
Copy link
Owner

evmar commented Feb 16, 2025

Thanks for sending this!

Can you add a section to doc/comparison.md with a name like "ninja extensions" that describes these?

What do you think about naming "hide_last_line" something more like "hide_progress"? I think that better describes the intent of the feature, and might allow more flexibility for changing details on how the feature works in the future, maybe?

For example if you run n2 in a CI pipeline (where there's no terminal, just a stdout logfile) with the hide_last_line flag on, what behavior do you expect, and what behavior do you imagine another user would expect?

src/load.rs Outdated
@@ -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

@Colecf
Copy link
Contributor

Colecf commented Feb 16, 2025

In android, we have a --frontend_file option that makes ninja/n2 emit nothing at all to stdout/stderr, but instead write protobuf-encoded messages about its status to a file. (And in practice we use a FIFO for the file) Then we have a different program wrap ninja and emit the format we want. This may be worth considering as something more generic instead of giving a bunch of discrete flags to control the output.

@evmar
Copy link
Owner

evmar commented Feb 16, 2025

I love the idea of a separate program for customization progress! But this patch is about a per-build-edge customization of behavior. We had discussed this in the past and I didn’t have any better ideas. I guess you could wrap commands in something else that swallowed their stdout maybe?

@Colecf
Copy link
Contributor

Colecf commented Feb 16, 2025

You can do per-build-edge customization based on the information in the EdgeStarted message. In our protobuf the most useful field for that would be the build description, but you could add the ability to add custom fields. One easy way would just be to pass the value of all variables starting with some prefix like "custom_" to the protobuf.

Also in case it wasn't clear, the --frontend_file functionality we have makes ninja redirect all the commands' stdout/stderr into the protobuf as well, so you can play with that too.

@dae
Copy link
Contributor Author

dae commented Feb 18, 2025

frontend_file is certainly the most flexible/generic solution, but for users who are otherwise happy with n2's existing pretty output, requiring them to implement their own frontend is not ideal.

I've made the changes requested above. Regarding the non-pretty output case, I don't think hide_progress makes sense there, as that mode doesn't show progress. If you'd like anything else changed, please let me know.

@dae dae changed the title Add hide_success and hide_last_line options Add hide_success and hide_progress options Feb 18, 2025
@evmar
Copy link
Owner

evmar commented Feb 18, 2025

In general I'm a big fan of the frontend pipe idea (I think I might even have a branch around where I tried some of it, though with json instead of proto). But I also think this change looks good for dae's purposes.

@evmar evmar merged commit c9f7f7a into evmar:main Feb 18, 2025
2 checks passed
@evmar
Copy link
Owner

evmar commented Feb 18, 2025

FYI I fixed CI after this (it was unrelated to your change, just coincidental timing of some github deprecation apparently)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants