Skip to content

Commit

Permalink
fix: can't build without .proto files directory
Browse files Browse the repository at this point in the history
  • Loading branch information
FichteFoll authored and Yumeo0 committed Nov 11, 2024
1 parent 9567483 commit 68c0907
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions proto_gen/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use protobuf_codegen::Codegen;
use std::fs;
use std::io;
use std::path::PathBuf;
use tracing::warn;

Expand Down Expand Up @@ -44,9 +45,12 @@ fn main() {
}

fn get_proto_files(proto_src: &str) -> Vec<PathBuf> {
fs::read_dir(proto_src)
.expect("Failed to read proto directory")
.filter_map(|entry| {
let read_dir = match fs::read_dir(proto_src) {
Err(err) if err.kind() == io::ErrorKind::NotFound => return vec![],
Err(err) => panic!("Failed to read proto directory. {}", err),
Ok(read_dir) => read_dir,
};
return read_dir.filter_map(|entry| {
let path = entry.ok()?.path();
if path.extension()?.to_str()? == "proto" {
Some(path)
Expand Down

0 comments on commit 68c0907

Please sign in to comment.