-
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
Allow build scripts to report error messages through cargo::error
#14435
Conversation
8c0028a
to
da2e8eb
Compare
da2e8eb
to
02eb2a8
Compare
@epage This is ready for another look. |
02eb2a8
to
ee7edd2
Compare
@epage This is ready for another look. |
@@ -319,6 +319,8 @@ to set the shared library version or the runtime-path. | |||
The `error` instruction tells Cargo to display an error after the build script | |||
has finished running, and then fail the build. | |||
|
|||
> **MSRV:** Respected as of 1.82 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping a comment open on this so we remember to update it if this slips
@rfcbot fcp merge @torhovland is proposing we insta-stabilize This is following the semantics proposed in a cargo team meeting (#10159 (comment)): @kornelski counters that this means we have two ways to cause a build script to error when we should only have one. They suggest warning if an error appears without a failure (#10159 (comment)). However, that does mean that we have error messages that might not be tied to a failure which can cause user confusion and I think we should keep the Cargo team's previous proposal on this. This is only supported with As for insta-stabiliaze, I can understand that it seems like a lot to create an unstable feature just for this build directive. We don't have anything like |
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
2b1c7a9
to
f94b442
Compare
cargo::error
The primary motivation for this feature was #10159, where the main problem was noisy output from By default |
I would assume that the caller of pkg-config would be responsible for printing |
@ehuss The downside is that instead of improving one crate to benefit the whole ecosystem, it'll be necessary to change 750 downstream crates.
system-deps too. which means these crates can't adopt |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Thanks for the work on this @torhovland ! @bors r+ |
Allow build scripts to report error messages through `cargo::error` Related to #10159. Adds the `cargo::error` build script directive. It is similar to `cargo::warning`, but it emits an error message and it also fails the build.
💔 Test failed - checks-actions |
@torhovland looks like some other changes cause the output in the new tests to change and the commits need to be updated. |
Allow build scripts to report error messages through `cargo::error` Adds the `cargo::error` build script directive. It is similar to `cargo::warning`, but it emits an error message and it also fails the build. This is a repost of #14435 with the tests updated, a note added to the documentation about using this in a library, and updating the MSRV. Closes #10159
☔ The latest upstream changes (presumably #14743) made this pull request unmergeable. Please resolve the merge conflicts. |
Closing in favor of #14743. |
Related to #10159.
Adds the
cargo::error
build script directive. It is similar tocargo::warning
, but it emits an error message and it also fails the build.