-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.rs
More file actions
30 lines (24 loc) · 864 Bytes
/
Copy pathbuild.rs
File metadata and controls
30 lines (24 loc) · 864 Bytes
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
use chrono::Utc;
use std::{fs, path::PathBuf};
fn main() {
// Build time for device info
println!("cargo:rustc-env=BUILD_TIME={}", Utc::now());
// Proto input dir
let proto_dir = PathBuf::from("proto");
// Where to put generated Rust
let out_proto_dir = PathBuf::from("src/api");
fs::create_dir_all(&out_proto_dir).expect("Failed to create src/generated");
// Generate Rust .rs files using rust-protobuf
protobuf_codegen::Codegen::new()
.out_dir(&out_proto_dir)
.inputs(&[
proto_dir.join("api.proto"),
proto_dir.join("api_options.proto"),
])
.include(&proto_dir)
.run()
.expect("protoc failed");
// Tell cargo when to rerun
println!("cargo:rerun-if-changed=proto/api.proto");
println!("cargo:rerun-if-changed=proto/api_options.proto");
}