mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 06:18:07 +00:00
feat: add rust build script for trezor-client
This commit is contained in:
parent
379446cad7
commit
4f93b187de
@ -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"
|
||||
|
26
rust/trezor-client/build.rs
Normal file
26
rust/trezor-client/build.rs
Normal 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();
|
||||
}
|
33
rust/trezor-client/src/protos/mod.rs
Normal file
33
rust/trezor-client/src/protos/mod.rs
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user