forked from niteshbalusu11/lnd-grpc-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
54 lines (49 loc) · 1.61 KB
/
build.rs
File metadata and controls
54 lines (49 loc) · 1.61 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
54
use std::path::PathBuf;
fn main() -> std::io::Result<()> {
println!("cargo:rerun-if-env-changed=LND_REPO_DIR");
let dir = match std::env::var_os("LND_REPO_DIR") {
Some(lnd_repo_path) => {
let mut lnd_rpc_dir = PathBuf::from(lnd_repo_path);
lnd_rpc_dir.push("lnrpc");
lnd_rpc_dir
.to_str()
.expect("LND_REPO_DIR must be a valid UTF-8 path")
.to_string()
}
None => "vendor".to_string(),
};
let protos = vec![
"autopilotrpc/autopilot.proto",
"chainrpc/chainkit.proto",
"chainrpc/chainnotifier.proto",
"devrpc/dev.proto",
"invoicesrpc/invoices.proto",
"lightning.proto",
"stateservice.proto",
"walletunlocker.proto",
"lnclipb/lncli.proto",
"neutrinorpc/neutrino.proto",
"peersrpc/peers.proto",
"routerrpc/router.proto",
"signrpc/signer.proto",
"verrpc/verrpc.proto",
"walletrpc/walletkit.proto",
"watchtowerrpc/watchtower.proto",
"wtclientrpc/wtclient.proto",
];
let proto_paths: Vec<_> = protos
.iter()
.map(|proto| {
let mut path = PathBuf::from(&dir);
path.push(proto);
path.display().to_string()
})
.collect();
tonic_prost_build::configure()
.build_client(true)
.build_server(false)
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
.protoc_arg("--experimental_allow_proto3_optional")
.compile_protos(&proto_paths, &[dir])?;
Ok(())
}