-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
42 lines (35 loc) · 1.21 KB
/
Copy pathbuild.rs
File metadata and controls
42 lines (35 loc) · 1.21 KB
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
36
37
38
39
40
41
42
use std::io;
use std::io::ErrorKind;
use std::path::Path;
const PROTO_FILES: &[&str] = &[
"./vendor2/v2ray-core/app/observatory/command/command.proto",
"./vendor2/v2ray-core/app/subscription/subscriptionmanager/command/command.proto",
"./vendor2/v2ray-core/app/router/command/command.proto",
];
const INCLUDE_DIRS: &[&str] = &["./vendor2/protoc/include", "./vendor2/v2ray-core"];
fn require_path(path: &str, description: &str) -> io::Result<()> {
if !Path::new(path).exists() {
return Err(io::Error::new(
ErrorKind::NotFound,
format!(
"missing {description}: {path}. Populate vendor2/protoc and vendor2/v2ray-core before building"
),
));
}
Ok(())
}
fn main() -> io::Result<()> {
for include_dir in INCLUDE_DIRS {
require_path(include_dir, "protobuf include directory")?;
}
for proto_file in PROTO_FILES {
require_path(proto_file, "V2Ray protobuf file")?;
}
tonic_prost_build::configure()
.build_server(false)
.build_client(true)
.build_transport(false)
.compile_protos(PROTO_FILES, INCLUDE_DIRS)
.expect("failed to compile V2Ray protobuf definitions");
Ok(())
}