-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
35 lines (28 loc) · 836 Bytes
/
build.rs
File metadata and controls
35 lines (28 loc) · 836 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
31
32
33
34
35
use std::env;
use std::io::Result;
use std::path::PathBuf;
fn main() -> Result<()> {
let pb_env = env::var("GENERATE_PB").unwrap_or_else(|_| "0".to_string());
if pb_env == "1" {
generate_pb()?;
} else {
// println!("cargo:warning=Skipping protobuf generation");
}
Ok(())
}
fn generate_pb() -> Result<()> {
let output_dir = PathBuf::from("src/generated/pb");
prost_build::Config::new()
.out_dir(&output_dir)
.default_package_filename("a2o")
.compile_protos(&["pb/A2o.proto"], &["pb"])?;
prost_build::Config::new()
.out_dir(&output_dir)
.default_package_filename("o2a")
.compile_protos(&["pb/O2a.proto"], &["pb"])?;
println!(
"cargo:warning=Generated protobuf files in {}",
output_dir.display()
);
Ok(())
}