rustc: Implement a new --print cfg flag
This commit is an implementation of the new compiler flags required by [RFC 1361][rfc]. This specifically adds a new `cfg` option to the `--print` flag to the compiler. This new directive will print the defined `#[cfg]` directives by the compiler for the target in question. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1361-cargo-cfg-dependencies.md
This commit is contained in:
parent
26105b1a37
commit
a1ffe6b6bb
3 changed files with 36 additions and 0 deletions
|
|
@ -518,6 +518,25 @@ impl RustcDefaultCalls {
|
|||
.to_string_lossy());
|
||||
}
|
||||
}
|
||||
PrintRequest::Cfg => {
|
||||
for cfg in config::build_configuration(sess) {
|
||||
match cfg.node {
|
||||
ast::MetaWord(ref word) => println!("{}", word),
|
||||
ast::MetaNameValue(ref name, ref value) => {
|
||||
println!("{}=\"{}\"", name, match value.node {
|
||||
ast::LitStr(ref s, _) => s,
|
||||
_ => continue,
|
||||
});
|
||||
}
|
||||
// Right now there are not and should not be any
|
||||
// MetaList items in the configuration returned by
|
||||
// `build_configuration`.
|
||||
ast::MetaList(..) => {
|
||||
panic!("MetaList encountered in default cfg")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Compilation::Stop;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue