2024-09-14 16:45:33 +08:00
|
|
|
use std::process::Command;
|
|
|
|
|
2024-08-29 15:45:28 +08:00
|
|
|
use prost_build::Config;
|
|
|
|
fn main() {
|
2024-09-14 16:45:33 +08:00
|
|
|
// println!("cargo:rerun-if-changed=build.rs");
|
2024-08-29 15:45:28 +08:00
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
{
|
|
|
|
std::env::set_var(
|
|
|
|
"PROTOC",
|
|
|
|
"../../rtss-proto-msg/protoc/protoc-27.4-win64/bin/protoc.exe",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
Config::new()
|
|
|
|
.out_dir("src/pb")
|
2024-09-14 16:45:33 +08:00
|
|
|
.type_attribute("common.DataType", "#[derive(sqlx::Type)]")
|
|
|
|
.type_attribute("common.DataType", "#[derive(async_graphql::Enum)]")
|
|
|
|
.type_attribute("common.FeatureType", "#[derive(sqlx::Type)]")
|
2024-08-29 15:45:28 +08:00
|
|
|
.compile_protos(
|
2024-09-14 16:45:33 +08:00
|
|
|
&[
|
|
|
|
"../../rtss-proto-msg/src/em_data.proto",
|
|
|
|
"../../rtss-proto-msg/src/common.proto",
|
|
|
|
],
|
2024-08-29 15:45:28 +08:00
|
|
|
&["../../rtss-proto-msg/src/"],
|
|
|
|
)
|
|
|
|
.unwrap();
|
2024-09-14 16:45:33 +08:00
|
|
|
|
|
|
|
// Run cargo fmt to format the generated code
|
|
|
|
Command::new("cargo")
|
|
|
|
.args(["fmt"])
|
|
|
|
.status()
|
|
|
|
.expect("Failed to run cargo fmt on rtss-dto");
|
2024-08-29 15:45:28 +08:00
|
|
|
}
|