From d9846b048e0156ec355a5e61252bd96ce6032920 Mon Sep 17 00:00:00 2001 From: wuhuizuo Date: Mon, 1 Apr 2024 12:31:07 +0000 Subject: [PATCH] ci: fix build.rs ignore the no proto files --- OWNERS | 2 +- build.rs | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/OWNERS b/OWNERS index 8ae9709ae..d61c6dd11 100644 --- a/OWNERS +++ b/OWNERS @@ -1,3 +1,3 @@ # See the OWNERS docs at https://go.k8s.io/owners approvers: - - sig-approvers \ No newline at end of file + - sig-approvers diff --git a/build.rs b/build.rs index 4afddff6f..2cf597780 100644 --- a/build.rs +++ b/build.rs @@ -12,10 +12,27 @@ // limitations under the License. use protobuf_build::Builder; +use std::fs; fn main() { + let proto_dir = "proto"; + let mut proto_files = Vec::new(); + + // Walk the proto directory and collect all .proto files. + for entry in fs::read_dir(proto_dir).unwrap() { + let entry = entry.unwrap(); + let path = entry.path(); + if path.is_file() { + if let Some(ext) = path.extension() { + if ext == "proto" { + proto_files.push(path.to_string_lossy().into_owned()); + } + } + } + } + Builder::new() - .search_dir_for_protos("proto") + .files(&proto_files) .append_to_black_list("eraftpb") .generate() }