-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
20 lines (18 loc) · 722 Bytes
/
build.rs
File metadata and controls
20 lines (18 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::process::Command;
// Generates the tonic/grpc code from the .proto file
fn main() {
// Compile Protocol Buffers definitions
tonic_prost_build::compile_protos("proto/manycastr.proto")
.expect("Failed to compile Protobuf definitions");
// Gets commit string
let git_hash = std::env::var("GIT_HASH").unwrap_or_else(|_| {
Command::new("git")
.args(["rev-parse", "--short=7", "HEAD"])
.output()
.ok()
.and_then(|output| String::from_utf8(output.stdout).ok())
.unwrap_or_else(|| "unknown".to_string())
});
println!("cargo:rustc-env=GIT_HASH=git-{git_hash}");
println!("cargo:rustc-rerun-if-changed=.git/HEAD");
}