mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 03:38:00 +00:00
Some fixes to compile for Android (#1063)
* Some fixes to compile for Android * Revert change to cli
This commit is contained in:
@@ -24,7 +24,7 @@ sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", op
|
||||
parking_lot = { version = "0.10.0", optional = true }
|
||||
log = { version = "0.4.8", optional = true }
|
||||
|
||||
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "unknown")))'.dependencies]
|
||||
shared_memory = { version = "0.10.0", optional = true }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -28,7 +28,7 @@ use sp_core::traits::CallInWasm;
|
||||
use sp_wasm_interface::HostFunctions as _;
|
||||
use sp_externalities::Extensions;
|
||||
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
|
||||
pub use validation_host::{run_worker, ValidationPool, EXECUTION_TIMEOUT_SEC};
|
||||
|
||||
mod validation_host;
|
||||
@@ -49,14 +49,14 @@ impl ParachainExt {
|
||||
}
|
||||
}
|
||||
|
||||
/// A stub validation-pool defined when compiling for WASM.
|
||||
#[cfg(target_os = "unknown")]
|
||||
/// A stub validation-pool defined when compiling for Android or WASM.
|
||||
#[cfg(any(target_os = "android", target_os = "unknown"))]
|
||||
#[derive(Clone)]
|
||||
pub struct ValidationPool {
|
||||
_inner: (), // private field means not publicly-instantiable
|
||||
}
|
||||
|
||||
#[cfg(target_os = "unknown")]
|
||||
#[cfg(any(target_os = "android", target_os = "unknown"))]
|
||||
impl ValidationPool {
|
||||
/// Create a new `ValidationPool`.
|
||||
pub fn new() -> Self {
|
||||
@@ -64,6 +64,12 @@ impl ValidationPool {
|
||||
}
|
||||
}
|
||||
|
||||
/// A stub function defined when compiling for Android or WASM.
|
||||
#[cfg(any(target_os = "android", target_os = "unknown"))]
|
||||
pub fn run_worker(_: &str) -> Result<(), String> {
|
||||
Err("Cannot run validation worker on this platform".to_string())
|
||||
}
|
||||
|
||||
/// WASM code execution mode.
|
||||
///
|
||||
/// > Note: When compiling for WASM, the `Remote` variants are not available.
|
||||
@@ -101,7 +107,7 @@ pub enum Error {
|
||||
#[display(fmt = "WASM worker error: {}", _0)]
|
||||
External(String),
|
||||
#[display(fmt = "Shared memory error: {}", _0)]
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
|
||||
SharedMem(shared_memory::SharedMemError),
|
||||
}
|
||||
|
||||
@@ -111,7 +117,7 @@ impl std::error::Error for Error {
|
||||
Error::WasmExecutor(ref err) => Some(err),
|
||||
Error::Io(ref err) => Some(err),
|
||||
Error::System(ref err) => Some(&**err),
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
|
||||
Error::SharedMem(ref err) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
@@ -137,20 +143,20 @@ pub fn validate_candidate<E: Externalities + 'static>(
|
||||
ExecutionMode::Local => {
|
||||
validate_candidate_internal(validation_code, ¶ms.encode(), ext)
|
||||
},
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
|
||||
ExecutionMode::Remote(pool) => {
|
||||
pool.validate_candidate(validation_code, params, ext, false)
|
||||
},
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "unknown")))]
|
||||
ExecutionMode::RemoteTest(pool) => {
|
||||
pool.validate_candidate(validation_code, params, ext, true)
|
||||
},
|
||||
#[cfg(target_os = "unknown")]
|
||||
#[cfg(any(target_os = "android", target_os = "unknown"))]
|
||||
ExecutionMode::Remote(pool) =>
|
||||
Err(Error::System(Box::<dyn std::error::Error + Send + Sync>::from(
|
||||
"Remote validator not available".to_string()
|
||||
) as Box<_>)),
|
||||
#[cfg(target_os = "unknown")]
|
||||
#[cfg(any(target_os = "android", target_os = "unknown"))]
|
||||
ExecutionMode::RemoteTest(pool) =>
|
||||
Err(Error::System(Box::<dyn std::error::Error + Send + Sync>::from(
|
||||
"Remote validator not available".to_string()
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#![cfg(not(target_os = "unknown"))]
|
||||
#![cfg(not(any(target_os = "android", target_os = "unknown")))]
|
||||
|
||||
use std::{process, env, sync::Arc, sync::atomic, mem};
|
||||
use codec::{Decode, Encode, EncodeAppend};
|
||||
|
||||
@@ -45,7 +45,7 @@ pub use polkadot_primitives::parachain::{CollatorId, ParachainHost};
|
||||
pub use polkadot_primitives::Block;
|
||||
pub use sp_runtime::traits::{Block as BlockT, self as runtime_traits, BlakeTwo256};
|
||||
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec};
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
#[cfg(feature = "full-node")]
|
||||
pub use consensus::run_validation_worker;
|
||||
pub use codec::Codec;
|
||||
pub use polkadot_runtime;
|
||||
|
||||
@@ -53,7 +53,6 @@ pub use self::shared_table::{
|
||||
};
|
||||
pub use self::validation_service::{ServiceHandle, ServiceBuilder};
|
||||
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
pub use parachain::wasm_executor::run_worker as run_validation_worker;
|
||||
|
||||
mod dynamic_inclusion;
|
||||
|
||||
Reference in New Issue
Block a user