1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 14:58:09 +00:00
trezor-firmware/rust/trezor-client/build.rs
Pavol Rusnak b4825f408a
feat(rust): use symlink for trezor-client/protob
to satisfy cargo publish --dry-run

it seems there is something smart going on and the symlink is expanded
to file copies during the build

[no changelog]
2023-07-12 15:47:43 +02:00

27 lines
815 B
Rust

use std::{fs, path::PathBuf};
fn main() {
let proto_path = "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();
}