There are documentations on using build.rs
to print out cargo::rustc-check-cfg
.
References
My question is:
How to pass arguments to cargo
, like cargo build --cfg env=1
, such that the following will work:
fn main() {
#[cfg(env="1")]
println!("This is `env` = `1`");
#[cfg(env="2")]
println!("This is `env` = `2`");
}
Thank you.
cfg
flags are passed to rustc either through the RUSTFLAGS
environment variable, or with config.toml
.
For example:
RUSTFLAGS='--cfg env=1' cargo build
1 Like
Thank you for your reply.
Is it possible to pass them directly through cargo
?
system
Closed
4
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.