Rebuild on commit change.
This commit is contained in:
parent
c882bbd7fd
commit
9d9e4837da
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
/data
|
||||
Cargo.lock
|
||||
*.pem
|
||||
.commit
|
||||
|
@ -1,5 +1,7 @@
|
||||
use std::process::Command;
|
||||
|
||||
const F_COMMIT :&str = ".commit";
|
||||
|
||||
fn main()
|
||||
{
|
||||
let output = Command::new("git")
|
||||
@ -8,5 +10,12 @@ fn main()
|
||||
.expect("Failed to acquire git HEAD");
|
||||
let git_hash = String::from_utf8(output.stdout).expect("Invalid UTF-8 output from git HEAD");
|
||||
let git_hash = git_hash.trim();
|
||||
|
||||
let previous_hash = std::fs::read_to_string(F_COMMIT).unwrap_or_default();
|
||||
if git_hash != previous_hash {
|
||||
std::fs::write(F_COMMIT, &git_hash).ok();
|
||||
}
|
||||
|
||||
println!("cargo:rerun-if-changed={}", F_COMMIT);
|
||||
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user