1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-21 22:08:08 +00:00

feat: add rust build script for trezor-client

This commit is contained in:
wszdexdrf 2023-06-18 09:56:46 +05:30 committed by matejcik
parent 379446cad7
commit 4f93b187de
3 changed files with 62 additions and 0 deletions

View File

@ -34,6 +34,9 @@ unicode-normalization = { version = "0.1.22", optional = true }
# ethereum
primitive-types = { version = "0.12", default-features = false, optional = true }
[build-dependencies]
protobuf-codegen = "3.2.0"
[dev-dependencies]
tracing-subscriber = "0.3"
serial_test = "2.0.0"

View File

@ -0,0 +1,26 @@
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();
}

View File

@ -0,0 +1,33 @@
include!(concat!(env!("OUT_DIR"), "/protos/mod.rs"));
#[allow(ambiguous_glob_reexports)]
pub use messages::*;
pub use messages_bootloader::*;
pub use messages_common::*;
pub use messages_crypto::*;
pub use messages_debug::*;
pub use messages_management::*;
macro_rules! features {
($($feature:literal => $item:ident)+) => {$(
#[cfg(feature = $feature)]
#[allow(ambiguous_glob_reexports)]
pub use $item::*;
)+};
}
features! {
"bitcoin" => messages_bitcoin
"ethereum" => messages_ethereum
"ethereum" => messages_ethereum_eip712
"ethereum" => messages_ethereum_definitions
"binance" => messages_binance
"cardano" => messages_cardano
"eos" => messages_eos
"monero" => messages_monero
"nem" => messages_nem
"ripple" => messages_ripple
"stellar" => messages_stellar
"tezos" => messages_tezos
"webauthn" => messages_webauthn
}