-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
34 lines (28 loc) · 981 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
32
33
34
// Copyright 2025 Hedgehog
// SPDX-License-Identifier: Apache-2.0
fn main() {
#[cfg(feature = "regenerate")] {
// We will use self-contained protoc binary, have to hack env param to force it to use
unsafe {
std::env::set_var("PROTOC", protoc_bin_vendored::protoc_bin_path().unwrap());
}
let proto = "proto/dataplane.proto";
let res = tonic_build::configure()
.type_attribute(".", "#[derive(::serde::Deserialize, ::serde::Serialize)]")
.build_server(true)
.build_client(true)
.out_dir("src/generated")
.compile_protos(&[proto], &["proto"]);
match res {
Ok(_) => println!("Protobuf compiled successfully!"),
Err(e) => {
eprintln!("Failed to compile Protobuf: {}", e);
std::process::exit(1);
}
}
}
#[cfg(not(feature = "regenerate"))]
{
// Do nothing
}
}