add no_std feature and use hashmap_core only on no_std
This commit is contained in:
parent
3c75f65105
commit
3b82da15df
|
@ -14,11 +14,14 @@ exclude = [ "/res/*", "/tests/*", "/fuzz/*", "/benches/*" ]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
# Disable for no_std support
|
# Disable for no_std support
|
||||||
std = ["parity-wasm/std"]
|
std = ["parity-wasm/std"]
|
||||||
|
# Enable for no_std support
|
||||||
|
# hashmap_core only works on no_std
|
||||||
|
no_std = ["hashmap_core"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parity-wasm = { version = "0.31", default-features = false }
|
parity-wasm = { version = "0.31", default-features = false }
|
||||||
byteorder = "1.0"
|
byteorder = "1.0"
|
||||||
hashmap_core = "0.1.9"
|
hashmap_core = { version = "0.1.9", optional = true }
|
||||||
memory_units = "0.3.0"
|
memory_units = "0.3.0"
|
||||||
nan-preserving-float = "0.1.0"
|
nan-preserving-float = "0.1.0"
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,14 @@ cargo test
|
||||||
|
|
||||||
# `no_std` support
|
# `no_std` support
|
||||||
This crate supports `no_std` environments.
|
This crate supports `no_std` environments.
|
||||||
If the `std` feature is disabled, `no_std` is supported.
|
Enable the `no_std` feature and disable default features:
|
||||||
Use like that:
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parity-wasm = { version = "0.31", default-features = false }
|
parity-wasm = {
|
||||||
|
version = "0.31",
|
||||||
|
default-features = false,
|
||||||
|
features = "no_std"
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`no_std` requires the `core` and `alloc` libraries and a nightly compiler.
|
`no_std` requires the `core` and `alloc` libraries and a nightly compiler.
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use alloc::prelude::*;
|
use alloc::prelude::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
use std::collections::HashMap;
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
use hashmap_core::HashMap;
|
use hashmap_core::HashMap;
|
||||||
|
|
||||||
use global::GlobalRef;
|
use global::GlobalRef;
|
||||||
use memory::MemoryRef;
|
use memory::MemoryRef;
|
||||||
use func::FuncRef;
|
use func::FuncRef;
|
||||||
|
|
|
@ -119,6 +119,7 @@ extern crate assert_matches;
|
||||||
|
|
||||||
extern crate parity_wasm;
|
extern crate parity_wasm;
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
extern crate hashmap_core;
|
extern crate hashmap_core;
|
||||||
extern crate memory_units as memory_units_crate;
|
extern crate memory_units as memory_units_crate;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,12 @@ use runner::check_function_args;
|
||||||
use Trap;
|
use Trap;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
use std::collections::HashMap;
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
use hashmap_core::HashMap;
|
use hashmap_core::HashMap;
|
||||||
|
|
||||||
use parity_wasm::elements::{External, InitExpr, Internal, Instruction, ResizableLimits, Type};
|
use parity_wasm::elements::{External, InitExpr, Internal, Instruction, ResizableLimits, Type};
|
||||||
use {Module, Error, Signature, MemoryInstance, RuntimeValue, TableInstance};
|
use {Module, Error, Signature, MemoryInstance, RuntimeValue, TableInstance};
|
||||||
use imports::ImportResolver;
|
use imports::ImportResolver;
|
||||||
|
|
|
@ -3,7 +3,12 @@ use alloc::prelude::*;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::error;
|
use std::error;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
use std::collections::HashSet;
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
use hashmap_core::HashSet;
|
use hashmap_core::HashSet;
|
||||||
|
|
||||||
use parity_wasm::elements::{
|
use parity_wasm::elements::{
|
||||||
BlockType, External, GlobalEntry, GlobalType, Internal, MemoryType, Module, Instruction,
|
BlockType, External, GlobalEntry, GlobalType, Internal, MemoryType, Module, Instruction,
|
||||||
ResizableLimits, TableType, ValueType, InitExpr, Type,
|
ResizableLimits, TableType, ValueType, InitExpr, Type,
|
||||||
|
|
Loading…
Reference in New Issue