This RFC proposes to add a
COLOR environment variable to tell build scripts to pass on the colour options.
Currently, crates like
cc-rs pipes the output into a buffer, which is not a terminal. This will disable the C compilers from outputting coloured messages. This message is dumped upon error, but without colours it may be harder to figure out what’s going on.
COLOR environment variable is passed during runtime of build scripts, just like others documented here. Cargo determines whether we should have colours or not by its own mechanism (currently it uses
termcolor plus accepting CLI options). The possible values for
COLOR are only two:
Then, the build script or a downstream crate reads this environment variable, and passes the corresponding to the compiler, for instance
-fdiagnostics-color option to gcc/clang.
- Passing arguments to the build scripts: this sound more Unix-ish but argument parsing is normally hard.
- A few alternatives for the environment variable name:
- We can also use 0/1 for the possible values.
Does this need a RFC?