Skip to content

Commit ec6df5d

Browse files
bors[bot]oxalica
andauthored
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: NixOS/nixpkgs#90976 Co-authored-by: oxalica <oxalicc@pm.me>
2 parents 4575c38 + f9ce7cd commit ec6df5d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crates/rust-analyzer/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ use std::{env, path::PathBuf, process::Command};
55
fn main() {
66
set_rerun();
77

8-
let rev = rev().unwrap_or_else(|| "???????".to_string());
8+
let rev =
9+
env::var("RUST_ANALYZER_REV").ok().or_else(rev).unwrap_or_else(|| "???????".to_string());
910
println!("cargo:rustc-env=REV={}", rev)
1011
}
1112

1213
fn set_rerun() {
14+
println!("cargo:rerun-if-env-changed=RUST_ANALYZER_REV");
15+
1316
let mut manifest_dir = PathBuf::from(
1417
env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is always set by cargo."),
1518
);

0 commit comments

Comments
 (0)