Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bors[bot] and oxalica authored Jun 19, 2020
2 parents 4575c38 + f9ce7cd commit ec6df5d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/rust-analyzer/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
);
Expand Down

0 comments on commit ec6df5d

Please sign in to comment.