1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-10-20 23:09:13 +00:00
trezor-firmware/rust/trezor-client/build.rs
2023-07-11 13:50:33 +02:00

27 lines
828 B
Rust

use std::{fs, path::PathBuf};
fn main() {
let proto_path = "../../common/protob";
let protos: Vec<PathBuf> = fs::read_dir(proto_path)
.unwrap()
.filter_map(|entry| {
let entry = entry.unwrap();
let path = entry.path();
if path.is_file() && path.extension().map_or(false, |ext| ext == "proto") {
Some(path)
} else {
None
}
})
.collect();
let out_path = std::env::var("OUT_DIR").unwrap();
let out_dir = PathBuf::from(out_path).join("protos");
fs::create_dir_all(&out_dir).expect("Failed to create output directory");
protobuf_codegen::Codegen::new()
.protoc()
.includes(&[proto_path])
.inputs(protos)
.out_dir(out_dir)
.run_from_script();
}