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-15 11:13:08 +08:00
|
|
|
|
// 获取构建的profile
|
|
|
|
|
let profile = std::env::var("PROFILE").unwrap();
|
|
|
|
|
println!("profile: {}", profile);
|
|
|
|
|
|
|
|
|
|
// 如果是release模式,不重新生成
|
|
|
|
|
if profile == "release" {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
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",
|
2024-10-31 15:12:26 +08:00
|
|
|
|
"../../rtsa-proto-msg/protoc/protoc-27.4-win64/bin/protoc.exe",
|
2024-08-29 15:45:28 +08:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
Config::new()
|
|
|
|
|
.out_dir("src/pb")
|
2024-09-26 20:45:48 +08:00
|
|
|
|
.type_attribute(
|
|
|
|
|
"common.Role",
|
|
|
|
|
"#[derive(sqlx::Type, async_graphql::Enum, serde::Serialize, serde::Deserialize)]",
|
|
|
|
|
)
|
|
|
|
|
.type_attribute(
|
|
|
|
|
"common.DataType",
|
|
|
|
|
"#[derive(sqlx::Type, async_graphql::Enum, serde::Serialize, serde::Deserialize)]",
|
|
|
|
|
)
|
2024-11-13 14:39:19 +08:00
|
|
|
|
.type_attribute(
|
|
|
|
|
"common.LineType",
|
|
|
|
|
"#[derive(async_graphql::Enum, serde::Serialize, serde::Deserialize)]",
|
|
|
|
|
)
|
2024-09-19 00:07:53 +08:00
|
|
|
|
.type_attribute(
|
|
|
|
|
"common.IscsStyle",
|
2024-09-26 20:45:48 +08:00
|
|
|
|
"#[derive(async_graphql::Enum, serde::Serialize, serde::Deserialize)]",
|
|
|
|
|
)
|
|
|
|
|
.type_attribute(
|
|
|
|
|
"common.FeatureType",
|
|
|
|
|
"#[derive(sqlx::Type, async_graphql::Enum, serde::Serialize, serde::Deserialize)]",
|
2024-09-19 00:07:53 +08:00
|
|
|
|
)
|
2024-08-29 15:45:28 +08:00
|
|
|
|
.compile_protos(
|
2024-09-14 16:45:33 +08:00
|
|
|
|
&[
|
2024-10-31 15:12:26 +08:00
|
|
|
|
"../../rtsa-proto-msg/src/common.proto",
|
|
|
|
|
"../../rtsa-proto-msg/src/iscs_graphic_data.proto",
|
|
|
|
|
"../../rtsa-proto-msg/src/simulation.proto",
|
2024-09-14 16:45:33 +08:00
|
|
|
|
],
|
2024-10-31 15:12:26 +08:00
|
|
|
|
&["../../rtsa-proto-msg/src/"],
|
2024-08-29 15:45:28 +08:00
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
2024-09-14 16:45:33 +08:00
|
|
|
|
|
|
|
|
|
// Run cargo fmt to format the generated code
|
|
|
|
|
Command::new("cargo")
|
|
|
|
|
.args(["fmt"])
|
|
|
|
|
.status()
|
2024-10-31 15:12:26 +08:00
|
|
|
|
.expect("Failed to run cargo fmt on rtsa-dto");
|
2024-08-29 15:45:28 +08:00
|
|
|
|
}
|