-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.rs
39 lines (34 loc) · 1.3 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
use std::env;
use std::path::PathBuf;
use std::process::Command;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let tmp = tempfile::Builder::new()
.prefix("parallax-worker-build")
.tempdir()?;
let tmp_output_path = tmp.path().join("parallax.pb");
println!("generating protobuf descriptor");
let mut protoc = Command::new("protoc");
let output = protoc
.arg("-I../third-party/googleapis")
.arg("-I../api/proto/")
.arg("--include_imports")
.arg("--include_source_info")
.arg("--descriptor_set_out")
.arg(&tmp_output_path)
.arg("../api/proto/parallax/type/error/v1/error.proto")
.arg("../api/proto/parallax/service/resource/v1/resource.proto")
.arg("../api/proto/parallax/service/job/v1/job.proto")
.arg("../api/proto/parallax/config/resource/v1/resource.proto")
.output()?;
if !output.status.success() {
let stderr = String::from_utf8(output.stderr).unwrap_or("<not utf-8>".to_string());
panic!(
"failed to generate descriptor set for third-party: {}",
stderr
);
}
let output_path =
PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR to be set")).join("parallax.pb");
std::fs::copy(tmp_output_path, output_path)?;
Ok(())
}