mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
perf(build-rs): Always emit :: directives
Our MSRV is much higher than 1.77. Also, as time goes on, there is less incentive to drop it below 1.77, especially with the MSRV-aware resolver in 1.84
This commit is contained in:
parent
f9ef2c547c
commit
0f62101676
@ -1,14 +1,5 @@
|
||||
use std::{process::Command, sync::OnceLock};
|
||||
|
||||
fn rust_version_minor() -> u32 {
|
||||
static VERSION_MINOR: OnceLock<u32> = OnceLock::new();
|
||||
*VERSION_MINOR.get_or_init(|| {
|
||||
version_minor(&crate::input::cargo_pkg_rust_version().unwrap_or_default())
|
||||
// assume build-rs's MSRV if none specified for the current package
|
||||
.unwrap_or_else(|| version_minor(env!("CARGO_PKG_RUST_VERSION")).unwrap())
|
||||
})
|
||||
}
|
||||
|
||||
fn cargo_version_minor() -> u32 {
|
||||
static VERSION_MINOR: OnceLock<u32> = OnceLock::new();
|
||||
*VERSION_MINOR.get_or_init(|| {
|
||||
@ -33,11 +24,6 @@ fn version_minor(version: &str) -> Option<u32> {
|
||||
Some(minor)
|
||||
}
|
||||
|
||||
pub(crate) fn double_colon_directives() -> bool {
|
||||
// cargo errors on `cargo::` directives with insufficient package.rust-version
|
||||
rust_version_minor() >= 77
|
||||
}
|
||||
|
||||
pub(crate) fn check_cfg() -> bool {
|
||||
// emit check-cfg if the toolchain being used supports it
|
||||
cargo_version_minor() >= 80
|
||||
|
@ -13,11 +13,7 @@ use crate::{
|
||||
use std::{ffi::OsStr, fmt::Display, fmt::Write, path::Path, str};
|
||||
|
||||
fn emit(directive: &str, value: impl Display) {
|
||||
if allow_use::double_colon_directives() {
|
||||
println!("cargo::{}={}", directive, value);
|
||||
} else {
|
||||
println!("cargo:{}={}", directive, value);
|
||||
}
|
||||
println!("cargo::{}={}", directive, value);
|
||||
}
|
||||
|
||||
/// The `rerun-if-changed` instruction tells Cargo to re-run the build script if the
|
||||
@ -421,9 +417,5 @@ pub fn metadata(key: &str, val: &str) {
|
||||
panic!("cannot emit metadata: invalid value {val:?}");
|
||||
}
|
||||
|
||||
if allow_use::double_colon_directives() {
|
||||
emit("metadata", format_args!("{}={}", key, val));
|
||||
} else {
|
||||
emit(key, val);
|
||||
}
|
||||
emit("metadata", format_args!("{}={}", key, val));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user