Ed Page 8e90ce9a24 feat(build-script): Pass CARGO_CFG_FEATURE
This may look redundant with `CARGO_FEATURE_<CASE_CONVERTED_NAME>=1`
except that doesn't provide a lossless way of getting the names, e.g. for
forwarding for child builds like tests that need to build examples.

This also makes things more consistent as users
conditionalize on features through `cfg` and this even fits with what
the `CARGO_CFG_` docs say:

> For each configuration option of the package being built, this
> environment variable will contain the value of the configuration, where
> <cfg> is the name of the configuration uppercased and having -
> translated to _. Boolean configurations are present if they are set, and
> not present otherwise. Configurations with multiple values are joined to
> a single variable with the values delimited by ,. This includes values
> built-in to the compiler (which can be seen with rustc --print=cfg) and
> values set by build scripts and extra flags passed to rustc (such as
> those defined in RUSTFLAGS). Some examples of what these variables are:

Fixes #3702
2024-12-09 12:38:11 -06:00

61 lines
1.5 KiB
Rust

//! build-rs provides a strongly typed interface around the Cargo build script
//! protocol. Cargo provides inputs to the build script by environment variable
//! and accepts commands by printing to stdout.
//!
//! > This crate is maintained by the Cargo team for use by the wider
//! > ecosystem. This crate follows semver compatibility for its APIs.
#![cfg_attr(all(doc, feature = "unstable"), feature(doc_auto_cfg, doc_cfg))]
#![allow(clippy::disallowed_methods)] // HACK: deferred resoling this
#![allow(clippy::print_stdout)] // HACK: deferred resoling this
#[cfg(feature = "unstable")]
macro_rules! unstable {
($feature:ident, $issue:literal) => {
concat!(
r#"<div class="stab unstable">"#,
r#"<span class="emoji">🔬</span>"#,
r#"<span>This is a nightly-only experimental API. (<code>"#,
stringify!($feature),
r#"</code>&nbsp;<a href="https://github.com/rust-lang/rust/issues/"#,
$issue,
r#"">#"#,
$issue,
r#"</a>)</span>"#,
r#"</div>"#
)
};
}
macro_rules! respected_msrv {
($ver:literal) => {
concat!(
r#"<div class="warning">
MSRV: Respected as of "#,
$ver,
r#".
</div>"#
)
};
}
macro_rules! requires_msrv {
($ver:literal) => {
concat!(
r#"<div class="warning">
MSRV: Requires "#,
$ver,
r#".
</div>"#
)
};
}
mod ident;
pub mod input;
pub mod output;