-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
95 lines (89 loc) · 3.46 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use prost_wkt_build::*;
use std::{env, path::PathBuf};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
let descriptor_file = out.join("descriptors.bin");
let mut prost_config = prost_build::Config::new();
prost_config.protoc_arg("--experimental_allow_proto3_optional");
tonic_build::configure()
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
.type_attribute(
".openfga.v1.Userset",
"#[serde(rename_all = \"camelCase\")]",
)
.type_attribute(
".openfga.v1.TupleToUserset",
"#[serde(rename_all = \"camelCase\")]",
)
.field_attribute(
".openfga.v1.Userset.this",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.Userset.computed_userset",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.Userset.tuple_to_userset",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.Userset.union",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.Userset.intersection",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.Userset.difference",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.TupleToUserset.tupleset",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.TupleToUserset.computed_userset",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.CheckRequest.contextual_tuples",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.CheckRequest.trace",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.CheckRequest.store_id",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.CheckResponse.resolution",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.RelationReference.relation",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.field_attribute(
".openfga.v1.RelationReference.wildcard",
"#[serde(skip_serializing_if = \"Option::is_none\")]",
)
.extern_path(".google.protobuf.Any", "::prost_wkt_types::Any")
.extern_path(".google.protobuf.Timestamp", "::prost_wkt_types::Timestamp")
.extern_path(".google.protobuf.Value", "::prost_wkt_types::Value")
.build_server(false)
.file_descriptor_set_path(&descriptor_file)
.compile_with_config(
prost_config,
&["proto/openfga/v1/openfga_service.proto"],
&["proto"],
)
.unwrap();
let descriptor_bytes = std::fs::read(descriptor_file).unwrap();
let descriptor = FileDescriptorSet::decode(&descriptor_bytes[..]).unwrap();
prost_wkt_build::add_serde(out, descriptor);
Ok(())
}