-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
31 lines (21 loc) · 888 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
extern crate pb_rs;
use pb_rs::types::FileDescriptor;
use pb_rs::ConfigBuilder;
use std::path::{Path, PathBuf};
fn main() {
let in_dir = PathBuf::from(::std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("proto");
println!("cargo:rerun-if-changed={}", in_dir.to_str().unwrap());
let in_file = in_dir.join("vector_tile.proto");
println!("cargo:rerun-if-changed={}", in_file.to_str().unwrap());
let out_dir = std::env::var("OUT_DIR").unwrap();
let out_dir = Path::new(&out_dir).join("proto");
if out_dir.exists() {
std::fs::remove_dir_all(&out_dir).unwrap();
}
std::fs::DirBuilder::new().create(&out_dir).unwrap();
let config_builder = ConfigBuilder::new(&[in_file], None, Some(&out_dir), &[in_dir])
.unwrap()
.headers(false)
.single_module(true);
FileDescriptor::run(&config_builder.build()).unwrap()
}