hbbft/build.rs

36 lines
843 B
Rust
Raw Normal View History

extern crate protoc_rust;
use std::env;
fn protoc_exists() -> bool {
let name = "PATH";
match env::var_os(name) {
Some(paths) => {
for path in env::split_paths(&paths) {
if path.join("protoc").exists() {
return true;
}
}
}
2018-04-30 08:55:51 -07:00
None => println!("PATH environment variable is not defined."),
}
false
}
fn main() {
if !protoc_exists() {
2018-04-30 08:55:51 -07:00
panic!(
"
protoc cannot be found. Install the protobuf compiler in the \
2018-04-30 08:55:51 -07:00
system path."
);
} else {
println!("cargo:rerun-if-changed=proto/message.proto");
protoc_rust::run(protoc_rust::Args {
out_dir: "src/proto",
input: &["proto/message.proto"],
includes: &["proto"],
}).expect("protoc");
}
}