-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Support cargo:info=MESSAGE
in build.rs
stdout
#7037
Comments
This would be quite useful. |
I was looking at putting up a PR for this, but after looking at the code, I can see there is some more discussion needed first. Internally, cargo has support for printing "warn", "error" and "note" messages to the shell. For consistency, I suggest this feature should be implemented as "cargo:note=MESSAGE" which would print the cyan note message. Additionally, similar functionality should be implemented for "error" as well (presumably error would also trigger cargo to abort). A complication with the existing architecture is that messages are collected from the custom build script and are not written to the console until after the build script has completed. Would this restriction still support the motivating use cases for this feature? In my use case, waiting until the end of the build script would not be sufficient. I have a build which requires the presence of a 500MB archive, which is downloaded if not present. I want to display a note to the user that this download is in progress, otherwise the impression is that cargo build has hung, particularly on slow connections. |
We talked about this in today's @rust-lang/cargo meeting. A summary of the rough consensus:
|
Yeah, that would be a problem, but I think this might be useful too for . We can perhaps allow logs from certain crates with configuration or/and crates that are locally hosted (rather than fetched from Crates.io)? |
If you want a workaround you can abuse escape codes to overwrite the line with something new. macro_rules! p {
($($tokens: tt)*) => {
println!("cargo:warning=\r\x1b[32;1m {}", format!($($tokens)*))
}
} p!("Compiling XYZ"); |
This is also blocked on #11461 being resolved.. |
I overlooked at that time. #11593 seems kinda a duplicate of this? |
Isn't #11593 about non-cap-lint build script warnings while this is about info messages? |
Describe the problem you are trying to solve
Provide meaningful information to a developer when using a
build.rs
script.In my case, I provide duration of specific steps to monitor the performance of thoses.
Currently, I use
cargo:warning=MESSAGE
to provide this output.This is not fine because it is not an actual warning.
Describe the solution you'd like
Supporting
cargo:info=MESSAGE
to output a string in the cargo's output with info log level.Example:
(build.rs)
Will print in the cargo output if the
build.rs
script is executed:with the look of an info entry.
The text was updated successfully, but these errors were encountered: