forked from axolotl-chat/presage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
33 lines (28 loc) · 1.09 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
use std::io::Result;
use std::path::Path;
fn main() -> Result<()> {
let protobuf = Path::new("src/protobuf").to_owned();
// Build script does not automagically rerun when a new protobuf file is added.
// Directories are checked against mtime, which is platform specific
println!("cargo:rerun-if-changed=src/protobuf");
// Adding src/proto.rs means an extra `include!` will trigger a rerun. This is on best-effort
// basis.
println!("cargo:rerun-if-changed=src/proto.rs");
let input: Vec<_> = protobuf
.read_dir()
.expect("protobuf directory")
.filter_map(|entry| {
let entry = entry.expect("readable protobuf directory");
let path = entry.path();
if Some("proto") == path.extension().and_then(std::ffi::OsStr::to_str) {
assert!(path.is_file());
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
Some(path)
} else {
None
}
})
.collect();
prost_build::compile_protos(&input, &[protobuf])?;
Ok(())
}