-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.rs
49 lines (39 loc) · 1.64 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
use std::{env, path::PathBuf};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let proto_file = "contracts/projects/warehouse_events/warehouse_events.proto";
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.build_client(false)
.build_server(true)
.file_descriptor_set_path(out_dir.join("warehouse_events_descriptor.bin"))
.out_dir(out_dir)
.compile(&[proto_file], &["proto"])?;
// off_chain
let proto_file = "contracts/projects/off_chain/off_chain.proto";
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.build_client(false)
.build_server(true)
.file_descriptor_set_path(out_dir.join("off_chain_descriptor.bin"))
.out_dir(out_dir)
.compile(&[proto_file], &["proto"])?;
// offchain_canister
let proto_file = "contracts/projects/off_chain/offchain_canister.proto";
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.build_client(false)
.build_server(true)
.file_descriptor_set_path(out_dir.join("offchain_canister_descriptor.bin"))
.out_dir(out_dir)
.compile(&[proto_file], &["proto"])?;
// GRPC clients
let ml_feed_proto = "contracts/projects/ml_feed/ml_feed.proto";
let nsfw_proto = "contracts/projects/ml/nsfw_detector.proto";
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.build_client(true)
.build_server(false)
.out_dir(out_dir)
.compile(&[ml_feed_proto, nsfw_proto], &["proto"])?;
Ok(())
}