-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
36 lines (32 loc) · 886 Bytes
/
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
extern crate protoc_rust;
use std::env;
use std::process::Command;
#[allow(unused_macros)]
macro_rules! src_dir {
() => {
"third_party/onnx"
};
($src_path:expr) => {
concat!(src_dir!(), "/", $src_path)
};
}
fn protoc_installed() -> bool {
Command::new("protoc").arg("--version").output().is_ok()
}
fn main() {
env::set_var("RUST_BACKTRACE", "1");
if protoc_installed() {
protoc_rust::Codegen::new()
.out_dir("src/onnx_rustime/onnx_proto")
.inputs(&[
src_dir!("onnx-ml.proto3"),
src_dir!("onnx-operators-ml.proto3"),
src_dir!("onnx-data.proto3"),
])
.include(src_dir!())
.run()
.expect("Failed to run protoc");
} else {
println!("cargo:warning=protoc not found. Skipping code generation.");
}
}