-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.rs
35 lines (32 loc) · 1.13 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
use std::env;
use std::fs;
use std::io::Write;
use std::path::Path;
fn main() {
// Prepare OUT_DIR/proto directory
let out_dir = Path::new(&env::var("OUT_DIR").unwrap()).join("proto");
fs::create_dir_all(&out_dir).expect("Failed to create $OUT_DIR/proto directory");
protobuf_codegen_pure::Codegen::new()
.out_dir(&out_dir)
.inputs(&[if cfg!(feature = "webrtc-extensions") {
"protos/MumbleWithWebRTC.proto"
} else {
"protos/Mumble.proto"
}])
.includes(&["protos"])
.customize(protobuf_codegen_pure::Customize {
generate_accessors: Some(true),
..Default::default()
})
.run()
.expect("protoc");
// Create mod.rs (see https://github.com/stepancheg/rust-protobuf/issues/324)
let content = if cfg!(feature = "webrtc-extensions") {
"mod MumbleWithWebRTC; pub use MumbleWithWebRTC::*;"
} else {
"mod Mumble; pub use Mumble::*;"
};
let mut file = fs::File::create(out_dir.join("mod.rs")).unwrap();
file.write_all(content.as_bytes())
.expect("Failed to write proto/mod.rs")
}