Page MenuHomePhabricator

D5154.id16716.diff
No OneTemporary

D5154.id16716.diff

diff --git a/services/commtest/build.rs b/services/commtest/build.rs
--- a/services/commtest/build.rs
+++ b/services/commtest/build.rs
@@ -1,26 +1,21 @@
use std::fs;
-use std::io::{Error, ErrorKind};
+use std::io::Error;
+
+const PROTO_DIR: &'static str = "../../shared/protos";
fn main() -> Result<(), Error> {
- const PROTO_FILES_PATH: &str = "../../shared/protos";
- let proto_files = fs::read_dir(PROTO_FILES_PATH)?;
+ let proto_files = fs::read_dir(PROTO_DIR)?;
for path in proto_files {
- let path_str = path?
- .path()
- .file_name()
- .ok_or(Error::new(
- ErrorKind::Other,
- "failed to obtain the file name",
- ))?
- .to_string_lossy()
- .into_owned();
- println!("{}", path_str.as_str());
- // skip CMakeLists.txt and _generated directory
- if path_str.contains("CMakeLists.txt") || path_str.eq("_generated") {
+ let filename: String = path?.file_name().to_string_lossy().to_string();
+
+ // Avoid passing non protobuf files to tonic
+ if !filename.ends_with(".proto") {
continue;
}
- assert!(path_str.contains(".proto"));
- tonic_build::compile_protos(format!("{}/{}", PROTO_FILES_PATH, path_str))?;
+
+ println!("Compiling protobuf file: {}", filename);
+ println!("cargo:rerun-if-changed={}/{}", PROTO_DIR, filename);
+ tonic_build::compile_protos(format!("{}/{}", PROTO_DIR, filename))?;
}
Ok(())
}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 28, 5:05 AM (24 m, 45 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2723725
Default Alt Text
D5154.id16716.diff (1 KB)

Event Timeline