mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 12:16:11 -05:00
57dd66ec3d
This slightly degrades the performance of CJS export analysis on subsequent runs because I changed it to no longer cache in the DENO_DIR with this PR (denort now properly has no idea about the DENO_DIR). We'll have to change it to embed this data in the binary and that will also allow us to get rid of swc in denort (will do that in a follow-up PR).
33 lines
837 B
Rust
33 lines
837 B
Rust
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
|
|
fn main() {
|
|
let commit_hash = git_commit_hash();
|
|
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", commit_hash);
|
|
println!("cargo:rerun-if-env-changed=GIT_COMMIT_HASH");
|
|
println!(
|
|
"cargo:rustc-env=GIT_COMMIT_HASH_SHORT={}",
|
|
&commit_hash[..7]
|
|
);
|
|
}
|
|
|
|
fn git_commit_hash() -> String {
|
|
if let Ok(output) = std::process::Command::new("git")
|
|
.arg("rev-list")
|
|
.arg("-1")
|
|
.arg("HEAD")
|
|
.output()
|
|
{
|
|
if output.status.success() {
|
|
std::str::from_utf8(&output.stdout[..40])
|
|
.unwrap()
|
|
.to_string()
|
|
} else {
|
|
// When not in git repository
|
|
// (e.g. when the user install by `cargo install deno`)
|
|
"UNKNOWN".to_string()
|
|
}
|
|
} else {
|
|
// When there is no git command for some reason
|
|
"UNKNOWN".to_string()
|
|
}
|
|
}
|