From 3b78b39d75da269e39ac0d02fae8932c4994d482 Mon Sep 17 00:00:00 2001 From: Niklas Adofsson Date: Sun, 3 Jun 2018 14:39:19 +0200 Subject: [PATCH] Enable libusb for android * Tested by it compiling succesfully with `cargo build --target=armv7--linux-androideabi` * The binary is ~66 MB ```bash $ size size target/armv7-linux-androideabi/release/parity text data bss dec hex filename 50676230 416200 31456 51123886 30c16ae target/armv7-linux-androideabi/release/parity ``` --- ethcore/src/account_provider/mod.rs | 10 +++++----- ethcore/src/lib.rs | 2 +- rpc/src/lib.rs | 2 +- rpc/src/v1/helpers/dispatch.rs | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ethcore/src/account_provider/mod.rs b/ethcore/src/account_provider/mod.rs index d7b1093f37c..5f697a38389 100644 --- a/ethcore/src/account_provider/mod.rs +++ b/ethcore/src/account_provider/mod.rs @@ -18,7 +18,7 @@ mod stores; -#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))] +#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android")))] mod no_hw; use ethstore::{ @@ -38,12 +38,12 @@ pub use ethstore::ethkey::Signature; pub use ethstore::{Derivation, IndexDerivation, KeyFile}; pub use super::transaction::{Action, Transaction}; -#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))] mod hw { pub use hardware_wallet::{Error as HardwareError, HardwareWalletManager, KeyPath, TransactionInfo}; } -#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))] +#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android")))] mod hw { pub use account_provider::no_hw::{HardwareError, HardwareWalletManager}; } @@ -178,7 +178,7 @@ impl AccountProvider { pub fn new(sstore: Box, settings: AccountProviderSettings) -> Self { let mut hardware_store = None; - #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] + #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))] { if settings.enable_hardware_wallets { match hw::HardwareWalletManager::new() { @@ -826,7 +826,7 @@ impl AccountProvider { } /// Sign transaction with hardware wallet. - #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] + #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))] pub fn sign_with_hardware(&self, address: Address, transaction: &Transaction, chain_id: Option, rlp_encoded_transaction: &[u8]) -> Result { let t_info = hw::TransactionInfo { nonce: transaction.nonce, diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 5d681ee2283..0ee37f019f2 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -108,7 +108,7 @@ extern crate wasm; extern crate memory_cache; extern crate journaldb; -#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))] extern crate hardware_wallet; #[cfg(test)] diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 376928a101c..6f410e924ad 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -68,7 +68,7 @@ extern crate rlp; extern crate stats; extern crate keccak_hash as hash; -#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))] extern crate hardware_wallet; extern crate patricia_trie as trie; diff --git a/rpc/src/v1/helpers/dispatch.rs b/rpc/src/v1/helpers/dispatch.rs index 426fede3c96..8f6523d7b5b 100644 --- a/rpc/src/v1/helpers/dispatch.rs +++ b/rpc/src/v1/helpers/dispatch.rs @@ -52,7 +52,7 @@ use v1::types::{ DecryptRequest as RpcDecryptRequest, }; -#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))] use rlp; pub use self::nonce::Reservations; @@ -433,7 +433,7 @@ fn sign_transaction( data: filled.data, }; - #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] + #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))] { if accounts.is_hardware_address(&filled.from) { return hardware_signature(accounts, filled.from, t, chain_id).map(WithToken::No) @@ -717,7 +717,7 @@ fn signature(accounts: &AccountProvider, address: Address, hash: H256, password: } // obtain a hardware signature from the given account. -#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))] fn hardware_signature(accounts: &AccountProvider, address: Address, t: Transaction, chain_id: Option) -> Result {