-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
52 lines (44 loc) · 1.05 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use std::fs;
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let out_dir = "src/generated";
// ensure out_dir exists
fs::create_dir_all(out_dir)?;
// compile proto files
tonic_build::configure().out_dir(out_dir).compile_protos(
&[
"proto/babylon/btclightclient/v1/query.proto",
"proto/babylon/btclightclient/v1/params.proto",
],
&["proto", "proto/third_party"],
)?;
// generate mod.rs file
let mod_content = r#"
pub mod cosmos {
pub mod base {
pub mod query {
pub mod v1beta1 {
include!("cosmos.base.query.v1beta1.rs");
}
}
}
}
pub mod babylon {
pub mod btclightclient {
pub mod v1 {
include!("babylon.btclightclient.v1.rs");
}
}
}
pub mod cosmos_proto {
include!("cosmos_proto.rs");
}
pub mod google {
pub mod api {
include!("google.api.rs");
}
}
"#;
fs::write(Path::new(out_dir).join("mod.rs"), mod_content.trim())?;
Ok(())
}