Parser for CARGO_ENCODED_RUSTFLAGS
CARGO_ENCODED_RUSTFLAGS
is one of the environment variables provided by Cargo
to build scripts. It synthesizes several sources of flags affecting
Cargo's rustc invocations that build scripts might care about:
- Flags passed via the RUSTFLAGS environment variable,
- Cargo config entries under
target.<triple>.rustflags
andtarget.<cfg>.rustflags
andbuild.rustflags
, including from the project-specific Cargo config file and the Cargo config in the user's CARGO_HOME.
If a build script needs to make some rustc invocations, or needs to characterize aspects of the upcoming rustc invocation, it likely needs these flags.
[]
= "0.1"
Example
This build script uses the cmake
crate to compile some C code, and must
configure it with a particular C preprocessor #define if the Rust build is being
performed with sanitizers.
// build.rs
use Flag;
use env;
use PathBuf;