-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.rs
43 lines (35 loc) · 1.25 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
use std::path::Path;
fn init_proto() -> Result<(), Box<dyn std::error::Error>> {
// Define the path to the output directory within the `src` folder
let out_dir = Path::new("src/proto");
std::fs::create_dir_all(out_dir)?;
let descriptor_set_path = format!(
"{}/ratings_descriptor.bin",
std::env::var("OUT_DIR").unwrap()
);
let files = &[
"proto/ratings_features_app.proto",
"proto/ratings_features_chart.proto",
"proto/ratings_features_user.proto",
"proto/ratings_features_common.proto",
];
tonic_build::configure()
.protoc_arg("--experimental_allow_proto3_optional") // needed to run on GHA because it's jammy
.build_server(true)
.file_descriptor_set_path(descriptor_set_path)
.out_dir(out_dir)
.type_attribute("Category", "#[derive(sqlx::Type, strum::EnumString)]")
.type_attribute(
"Category",
r#"#[strum(serialize_all = "kebab_case", ascii_case_insensitive)]"#,
)
.compile(files, &["proto"])?;
if std::env::var("SKIP_CACHE").is_ok() {
println!("cargo:rustc-cfg=feature=\"skip_cache\"");
}
Ok(())
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
init_proto()?;
Ok(())
}