-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
executable file
·53 lines (48 loc) · 1.73 KB
/
build.rs
File metadata and controls
executable file
·53 lines (48 loc) · 1.73 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
43
44
45
46
47
48
49
50
51
52
53
// build.rs
/// This script runs at build time to compile all gRPC definitions
/// into Rust code for RustRay compatibility.
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=proto");
// Ensure proto directory exists
let proto_root = std::path::Path::new("proto");
if !proto_root.exists() {
panic!("The 'proto' directory was not found at root. Please ensure it exists.");
}
// List of RustRay proto files to compile
// These are the core proto files needed for gRPC API compatibility with rr-ui
let rustray_protos = vec![
"proto/common.proto",
"proto/common_serial.proto",
"proto/common_protocol.proto",
"proto/rustray.proto",
"proto/stats.proto",
"proto/proxyman.proto",
"proto/router.proto",
"proto/log.proto",
"proto/observatory.proto",
"proto/transport.proto",
"proto/reality.proto",
"proto/vless.proto",
"proto/vmess.proto",
"proto/trojan.proto",
"proto/flow-j.proto",
"proto/hysteria2.proto",
"proto/tuic.proto",
"proto/wiregaurd.proto",
"proto/warp.proto",
"proto/control.proto",
];
// Verify all proto files exist
for proto_file in &rustray_protos {
let path = std::path::Path::new(proto_file);
if !path.exists() {
panic!("Required proto file not found: {}", proto_file);
}
}
// Use tonic-build to compile the RustRay proto files
tonic_build::configure()
.build_server(true) // Build server implementations for gRPC services
.build_client(true) // We are the server, not the client
.compile_protos(&rustray_protos, &["proto"])?;
Ok(())
}