项目作者: volks73

项目描述 :
A Rust crate for parsing the output from the `cargo rustc --print cfg` command
高级语言: Rust
项目地址: git://github.com/volks73/cargo-rustc-cfg.git
创建时间: 2020-11-28T17:46:38Z
项目社区:https://github.com/volks73/cargo-rustc-cfg

开源协议:Other

下载


cargo-rustc-cfg

This crate currently needs the nightly toolchain. See the tracking issue for
stabilization.

A 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 that need compiler
configuration information. This crate is not recommended for build scripts.

Crates.io
GitHub release
Crates.io
Build Status
Rust: 1.51.0+
Rust: nightly

Quick Start

Note, this crate currently needs the nightly toolchain.

  1. use cargo_rustc_cfg;
  2. let host = cargo_rustc_cfg::host()?;
  3. println("{:?}", host);

Installation

Add the following to a package’s manifest (Cargo.toml):

  1. cargo-rustc-cfg = "0.3"

If using the Rust 2015 Edition, then also add the following to the lib.rs or main.rs source file:

  1. extern crate cargo_rustc_cfg;

Tests

Tests are run using the cargo test command. Currently, only documentation
tests
are implemented because for a relatively simple, small library these
provide enough coverage. If the default toolchain is stable but the nightly
toolchain is installed, the cargo +nightly test command can be used without
having to switch the default toolchain.

License

The cargo-rustc-cfg project is licensed under either the MIT license or
the Apache 2.0 license. See the LICENSE-MIT or LICENSE-APACHE files for
more information about licensing and copyright.