-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
At present, I can use println!("cargo:warning={}", message)
in a build script to ask cargo to emit a warning message during compilation. Unfortunately, this warning message cannot be seen from end-users of a library unless they pass -vv
to their cargo
invocation. Of course, this is not something that users do, and as a result, these warnings are never seen by end-users.
This inability to unconditionally emit a warning message during compilation leads to usability issues in libraries that utilize build scripts. As an example, consider Rocket's build script. The script attempts to detect the version of the user's rustc
so that it can decline to compile with known incompatible versions. When the rustc
version cannot be determined, the build script attempts to emit a warning. Unfortunately this warning is hidden by cargo
by default leading to users being confused about why Rocket is failing to build; this is the exact thing the script is trying to prevent.
I would like a mechanism by which build scripts can log to the console, regardless of the verbosity level set by the user. I can think of several such mechanisms:
- Use the same
cargo:warning={}
trick, but always emit the warnings. - Emit everything written to
stderr
from build scripts. - Add levels to warnings, and always emit errors above some threshold. Something like:
cargo:warning(k)
wherek
is some integer defining the level. - Add something like
cargo:critical={}
which unconditionally emits critical messages.
My personal preference is for 2. This is what I would expect when writing a build script, but I'd be content with any solution.