butterfly: Inline protocol file names
-extern crate pkg_config;
-extern crate prost;
-extern crate prost_build;
-
-use std::{env,
- fs,
- path::PathBuf};
+use prost_build;
fn main() {
let mut config = prost_build::Config::new();
config.type_attribute(".butterfly.newscast.Rumor.payload",
"#[allow(clippy::large_enum_variant)]");
config.type_attribute(".", "#[derive(Serialize, Deserialize)]");
- config.compile_protos(&protocol_files(), &protocol_includes())
- .expect("Error compiling protobuf definitions");
+ config.compile_protos(&["protocols/common.proto",
+ "protocols/newscast.proto",
+ "protocols/swim.proto"],
+ &["protocols/"])
+ .expect("Couldn't compile protobufs!");
for file in generated_files() {
fs::copy(&file,
// NB: src/generated is presumed to exist; if you delete
@@ -35,20 +32,3 @@ fn generated_files() -> Vec<PathBuf> {
}
files
}
-
-fn protocol_includes() -> Vec<String> { vec!["protocols".to_string()] }
-
-fn protocol_files() -> Vec<String> {
- let mut files = vec![];
- for entry in fs::read_dir("protocols").unwrap() {
- let file = entry.unwrap();
- // skip vim temp files
- if file.file_name().to_str().unwrap().starts_with('.') {
- continue;
- }
- if file.metadata().unwrap().is_file() {
- files.push(file.path().to_string_lossy().into_owned());
- }
- }
- files
-}
