-
Notifications
You must be signed in to change notification settings - Fork 31
/
build.rs
70 lines (65 loc) · 1.88 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use std::io::Result;
#[cfg(feature = "services")]
const SERVICES: &[&str] = &[
"src/service/router.proto",
"src/service/state_channel.proto",
"src/service/local.proto",
"src/service/transaction.proto",
"src/service/follower.proto",
"src/service/poc_mobile.proto",
"src/service/poc_lora.proto",
"src/service/poc_entropy.proto",
"src/service/packet_router.proto",
"src/service/iot_config.proto",
"src/service/mobile_config.proto",
"src/service/downlink.proto",
"src/service/multi_buy.proto",
"src/service/packet_verifier.proto",
];
const MESSAGES: &[&str] = &[
"src/blockchain_txn.proto",
"src/decimal.proto",
"src/entropy.proto",
"src/service_provider.proto",
"src/data_rate.proto",
"src/region.proto",
"src/mapper.proto",
"src/reward_manifest.proto",
"src/blockchain_region_param_v1.proto",
"src/price_report.proto",
"src/hex_boosting.proto",
];
macro_rules! config {
($config:expr) => {
$config
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
.enum_attribute(
".helium.service_provider",
"#[derive(strum_macros::EnumIter)]",
)
.field_attribute(
".helium.tagged_spreading.region_spreading",
"#[serde(with = \"serde_region_spreading\" )]",
)
};
}
#[cfg(feature = "services")]
fn main() -> Result<()> {
config!(tonic_build::configure())
.build_server(true)
.build_client(true)
.compile(
&MESSAGES
.iter()
.chain(SERVICES)
.copied()
.collect::<Vec<&str>>(),
&["src"],
)?;
Ok(())
}
#[cfg(not(feature = "services"))]
fn main() -> Result<()> {
config!(prost_build::Config::new()).compile_protos(MESSAGES, &["src"])?;
Ok(())
}