rtsa-services/crates/rtsa_dto/build.rs
soul-walker e502f5b6a5
All checks were successful
build / build-rust (push) Successful in 2m10s
添加发布电子地图数据查询接口
2024-11-13 17:47:37 +08:00

60 lines
1.8 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use std::process::Command;
use prost_build::Config;
fn main() {
// 获取构建的profile
let profile = std::env::var("PROFILE").unwrap();
println!("profile: {}", profile);
// 如果是release模式不重新生成
if profile == "release" {
return;
}
// println!("cargo:rerun-if-changed=build.rs");
#[cfg(target_os = "windows")]
{
std::env::set_var(
"PROTOC",
"../../rtsa-proto-msg/protoc/protoc-27.4-win64/bin/protoc.exe",
);
}
Config::new()
.out_dir("src/pb")
.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)]",
)
.type_attribute(
"common.LineType",
"#[derive(async_graphql::Enum, serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
"common.IscsStyle",
"#[derive(async_graphql::Enum, serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
"common.FeatureType",
"#[derive(sqlx::Type, async_graphql::Enum, serde::Serialize, serde::Deserialize)]",
)
.compile_protos(
&[
"../../rtsa-proto-msg/src/common.proto",
"../../rtsa-proto-msg/src/iscs_graphic_data.proto",
"../../rtsa-proto-msg/src/simulation.proto",
],
&["../../rtsa-proto-msg/src/"],
)
.unwrap();
// Run cargo fmt to format the generated code
Command::new("cargo")
.args(["fmt"])
.status()
.expect("Failed to run cargo fmt on rtsa-dto");
}