| Crates.io | cargo-rustc-cfg |
| lib.rs | cargo-rustc-cfg |
| version | 0.2.0 |
| created_at | 2020-11-28 17:50:33.570063+00 |
| updated_at | 2020-11-30 22:10:14.124919+00 |
| description | Runs the `cargo rustc -- --print cfg` command and parses the output |
| homepage | https://github.com/volks73/cargo-rustc-cfg |
| repository | https://github.com/volks73/cargo-rustc-cfg |
| max_upload_size | |
| id | 317493 |
| size | 67,547 |
cargo rustc -- --print cfg command and parsing the outputA Rust library (crate) that runs the cargo rustc -- --print cfg command and parses the output. This is inspired by the rustc-cfg crate, which runs the rustc --print cfg command and parses the output, but it does not take into account any flags or configurations passed from Cargo to the Rust compiler (rustc) when building a project using Cargo. For example, if the RUSTFLAGS environment variable is used to add a target feature, i.e. RUSTFLAGS="-C target-feature=+crt-static, then the rustc --print cfg command will not list the added target feature in its output because the RUSTFLAGS environment variable is managed by Cargo. However, the cargo rustc -- --print cfg will list the added target feature in its output. This crate is useful for developing third-party Cargo custom subcommands that need compiler configuration information. This crate is not recommeded for build scripts.
use cargo_rustc_cfg::Cfg;
let cfg = Cfg::host()?;
println("{:?}", cfg);
Add the following to a package's manifest (Cargo.toml):
cargo-rustc-cfg = "0.1"
If using the Rust 2015 Edition, then also add the following to the lib.rs or main.rs source file:
extern crate cargo_rustc_cfg;
Tests are running using the cargo test command. Currently, only documentation tests are implemented because for a relatively simple, small library these provide enough coverage.
The cargo-rustc-cfg project is licensed under either the MIT license or Apache 2.0 license. See the LICENSE-MIT or LICENSE-APACHE files for more information about licensing and copyright.