-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.rs
More file actions
27 lines (23 loc) · 750 Bytes
/
build.rs
File metadata and controls
27 lines (23 loc) · 750 Bytes
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
use tonic_build;
use walkdir::WalkDir;
fn main() {
let proto_dir = "src/xray_proto";
let proto_files: Vec<String> = WalkDir::new(proto_dir)
.into_iter()
.filter_map(|entry| entry.ok())
.filter(|entry| {
entry
.path()
.extension()
.map(|ext| ext == "proto")
.unwrap_or(false)
})
.map(|entry| entry.path().to_str().unwrap().to_string())
.collect();
tonic_build::configure()
.build_client(true)
.build_server(false)
.compile_protos(&proto_files, &[proto_dir])
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
println!("cargo:rerun-if-changed={}", proto_dir);
}