Remove CARGO_VERSION* env vars

Cargo and Rustc are co-versioned at the moment anyway.
This commit is contained in:
Jon Gjengset 2021-06-25 11:01:20 -07:00
parent 715fab4ff5
commit c16b9d4c55
3 changed files with 4 additions and 28 deletions

View File

@ -256,14 +256,6 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
cmd.env_remove("RUSTC_WRAPPER");
}
cmd.env("RUSTFLAGS", bcx.rustflags_args(unit).join(" "));
let version = crate::version();
cmd.env(
"CARGO_VERSION",
format!("{}.{}.{}", version.major, version.minor, version.patch),
);
cmd.env("CARGO_VERSION_MAJOR", version.major.to_string());
cmd.env("CARGO_VERSION_MINOR", version.minor.to_string());
cmd.env("CARGO_VERSION_PATCH", version.patch.to_string());
let version = &bcx.rustc().version;
cmd.env(
"RUSTC_VERSION",

View File

@ -344,9 +344,6 @@ let out_dir = env::var("OUT_DIR").unwrap();
* `RUSTFLAGS` — the `RUSTFLAGS` that Cargo invokes `rustc` with.
See [`build.rustflags`].
* `CARGO_PKG_<var>` - The package information variables, with the same names and values as are [provided during crate building][variables set for crates].
* `CARGO_VERSION` - The version of cargo used to invoke the build
script. Its constituent parts are also available as
`CARGO_VERSION_MAJOR`, `_MINOR`, and `_PATCH`.
* `RUSTC_VERSION` - The version of rustc used by the cargo that invokes
the build script. Its constituent parts are also
available as `CARGO_VERSION_MAJOR`, `_MINOR`, and

View File

@ -82,7 +82,6 @@ fn custom_build_env_vars() {
)
.file("bar/src/lib.rs", "pub fn hello() {}");
let cargo_version = cargo::version();
let rustc_version = semver::Version::parse(rustc_release()).unwrap();
let file_content = format!(
r#"
@ -126,23 +125,14 @@ fn custom_build_env_vars() {
let rustflags = env::var("RUSTFLAGS").unwrap();
assert_eq!(rustflags, "");
let version = env::var("CARGO_VERSION").unwrap();
assert_eq!(version, "{1}.{2}.{3}", "bad cargo version");
let version = env::var("CARGO_VERSION_MAJOR").unwrap();
assert_eq!(version, "{1}");
let version = env::var("CARGO_VERSION_MINOR").unwrap();
assert_eq!(version, "{2}");
let version = env::var("CARGO_VERSION_PATCH").unwrap();
assert_eq!(version, "{3}");
let version = env::var("RUSTC_VERSION").unwrap();
assert_eq!(version, "{4}.{5}.{6}", "bad rust version");
assert_eq!(version, "{1}.{2}.{3}", "bad rust version");
let version = env::var("RUSTC_VERSION_MAJOR").unwrap();
assert_eq!(version, "{4}");
assert_eq!(version, "{1}");
let version = env::var("RUSTC_VERSION_MINOR").unwrap();
assert_eq!(version, "{5}");
assert_eq!(version, "{2}");
let version = env::var("RUSTC_VERSION_PATCH").unwrap();
assert_eq!(version, "{6}");
assert_eq!(version, "{3}");
}}
"#,
p.root()
@ -150,9 +140,6 @@ fn custom_build_env_vars() {
.join("debug")
.join("build")
.display(),
cargo_version.major,
cargo_version.minor,
cargo_version.patch,
rustc_version.major,
rustc_version.minor,
rustc_version.patch,