mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
Merge #4937
4937: Allow overriding rust-analyzer display version r=matklad a=oxalica The build script invokes `git` for version information which is displayed when rust-analyzer is called with `--version`. But in build environment without `git` or when the source code is not a git repo, there's no way to manually specify the version information. This patch respects environment variable ~`REV`~ `RUST_ANALYZER_REV` in compile time for overriding. Related: https://github.com/NixOS/nixpkgs/pull/90976 Co-authored-by: oxalica <oxalicc@pm.me>
This commit is contained in:
commit
ec6df5d3e8
@ -5,11 +5,14 @@ use std::{env, path::PathBuf, process::Command};
|
||||
fn main() {
|
||||
set_rerun();
|
||||
|
||||
let rev = rev().unwrap_or_else(|| "???????".to_string());
|
||||
let rev =
|
||||
env::var("RUST_ANALYZER_REV").ok().or_else(rev).unwrap_or_else(|| "???????".to_string());
|
||||
println!("cargo:rustc-env=REV={}", rev)
|
||||
}
|
||||
|
||||
fn set_rerun() {
|
||||
println!("cargo:rerun-if-env-changed=RUST_ANALYZER_REV");
|
||||
|
||||
let mut manifest_dir = PathBuf::from(
|
||||
env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is always set by cargo."),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user