Skip to content

Commit

Permalink
feat: refactor rust polaris build.rs (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
daheige authored May 8, 2023
1 parent a102d6e commit 9937a9a
Show file tree
Hide file tree
Showing 3 changed files with 2,789 additions and 2,801 deletions.
2 changes: 1 addition & 1 deletion source/rust/polaris-specification/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polaris-specification"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
authors = ["https://github.com/polarismesh"]
license = "MIT OR Apache-2.0"
Expand Down
36 changes: 12 additions & 24 deletions source/rust/polaris-specification/build.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
extern crate prost_build;

use prost_build;
use std::io::Result;
use std::path::PathBuf;

fn main() -> Result<()> {
let proto_dir: PathBuf = "proto".into(); // rust proto file dir
let mut proto_list = Vec::new(); // proto file list
let lists = proto_dir.read_dir().expect("read proto dir failed");
for entry_path in lists {
if entry_path.as_ref().unwrap().path().is_file() {
proto_list.push(entry_path.unwrap().path())
}
}

let mut config = prost_build::Config::new();
config.protoc_arg("--experimental_allow_proto3_optional");
config.default_package_filename("specification");
config
.out_dir("src")
.compile_protos(
&[
"proto/config_file.proto",
"proto/config_file_response.proto",
"proto/grpc_config_api.proto",
"proto/auth.proto",
"proto/model.proto",
"proto/namespace.proto",
"proto/code.proto",
"proto/client.proto",
"proto/service.proto",
"proto/request.proto",
"proto/response.proto",
"proto/grpcapi.proto",
"proto/configrelease.proto",
"proto/routing.proto",
"proto/ratelimit.proto",
"proto/circuitbreaker.proto",
"proto/fault_detector.proto",
],
&["proto/"],
)
.compile_protos(&proto_list, &["proto/"])
.unwrap();
Ok(())
}
Loading

0 comments on commit 9937a9a

Please sign in to comment.