3798572b0c
All checks were successful
build / build-rust (push) Successful in 1m49s
添加feature数据库访问功能及实现 添加feature几个api接口及实现 调整数据库模型枚举字段使用枚举取代i32 添加设计文档
56 lines
1.7 KiB
Rust
56 lines
1.7 KiB
Rust
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",
|
||
"../../rtss-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.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(
|
||
&[
|
||
"../../rtss-proto-msg/src/em_data.proto",
|
||
"../../rtss-proto-msg/src/common.proto",
|
||
"../../rtss-proto-msg/src/iscs_graphic_data.proto",
|
||
],
|
||
&["../../rtss-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 rtss-dto");
|
||
}
|