2022-05-16 01:57:25 +00:00
|
|
|
use std::process::Command;
|
|
|
|
|
2021-01-12 04:59:53 +00:00
|
|
|
fn main() -> shadow_rs::SdResult<()> {
|
2022-05-16 01:57:25 +00:00
|
|
|
// Look up the current Git commit ourselves instead of relying on shadow_rs,
|
|
|
|
// because shadow_rs does it in a really slow-to-compile way (it builds libgit2)
|
2022-08-10 15:31:12 +00:00
|
|
|
let hash = get_git_hash().unwrap_or_default();
|
2023-01-30 01:37:54 +00:00
|
|
|
println!("cargo:rustc-env=NU_COMMIT_HASH={hash}");
|
2022-05-16 01:57:25 +00:00
|
|
|
|
2021-01-12 04:59:53 +00:00
|
|
|
shadow_rs::new()
|
|
|
|
}
|
2022-05-16 01:57:25 +00:00
|
|
|
|
2022-08-10 15:31:12 +00:00
|
|
|
fn get_git_hash() -> Option<String> {
|
|
|
|
Command::new("git")
|
|
|
|
.args(["rev-parse", "HEAD"])
|
|
|
|
.output()
|
|
|
|
.ok()
|
|
|
|
.filter(|output| output.status.success())
|
|
|
|
.and_then(|output| String::from_utf8(output.stdout).ok())
|
|
|
|
.map(|hash| hash.trim().to_string())
|
2022-05-16 01:57:25 +00:00
|
|
|
}
|