-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
41 lines (34 loc) · 1.2 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
fn main() -> Result<(), Box<dyn std::error::Error>> {
let pkg_version = if let Ok(date) = std::env::var("DATE") {
format!("{}.{}", env!("CARGO_PKG_VERSION"), date)
} else {
env!("CARGO_PKG_VERSION").to_string()
};
println!("cargo:rustc-env=CARGO_PKG_VERSION={}", pkg_version);
let version = versionisator::Version::new(
env!("CARGO_MANIFEST_DIR"),
env!("CARGO_PKG_NAME").to_string(),
pkg_version,
);
println!("cargo:rustc-env=FULL_VERSION={}", version.full());
println!("cargo:rustc-env=SIMPLE_VERSION={}", version.simple());
println!("cargo:rustc-env=SOURCE_VERSION={}", version.hash());
build_protobuf()?;
Ok(())
}
fn build_protobuf() -> Result<(), Box<dyn std::error::Error>> {
const PROTO_PATH: &str = "./proto";
tonic_build::configure()
.build_server(true)
.build_client(true)
.type_attribute(".", "#[derive(serde::Deserialize, serde::Serialize)]")
.compile(
&["proto/taskqueue.proto", "proto/grpc.health.proto"],
&["proto/"],
)?;
println!(
"cargo:rerun-if-changed={}",
format!("{}/{}", PROTO_PATH, "taskqueue.proto")
);
Ok(())
}