From f05f43b883c627a37166969a5344a56a9dda8fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Wed, 21 Oct 2020 20:24:49 +0200 Subject: [PATCH 1/6] Unify pwasm-utils and pwasm-utils-cli packet --- Cargo.toml | 51 ++++++++++++++++++++++++++++++--- cli/Cargo.toml | 51 --------------------------------- cli/README.md | 11 ------- cli/build/main.rs | 4 +-- cli/check/main.rs | 4 +-- cli/ext/main.rs | 4 +-- cli/gas/main.rs | 4 +-- cli/pack/main.rs | 4 +-- cli/prune/main.rs | 4 +-- cli/stack_height/main.rs | 4 +-- src/build.rs | 2 -- src/ext.rs | 3 +- src/gas/mod.rs | 4 +-- src/gas/validation.rs | 4 +-- src/lib.rs | 2 ++ cli/src/lib.rs => src/logger.rs | 7 ++--- src/optimizer.rs | 2 +- 17 files changed, 72 insertions(+), 93 deletions(-) delete mode 100644 cli/Cargo.toml delete mode 100644 cli/README.md rename cli/src/lib.rs => src/logger.rs (76%) diff --git a/Cargo.toml b/Cargo.toml index b77aa0e..0346577 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "pwasm-utils" version = "0.15.0" +edition = "2018" authors = ["Nikolay Volf ", "Sergey Pepyakin "] license = "MIT/Apache-2.0" readme = "README.md" @@ -8,6 +9,41 @@ description = "Collection of command-line utilities and corresponding Rust api f keywords = ["wasm", "webassembly", "pwasm"] repository = "https://github.com/paritytech/wasm-utils" +[[bin]] +name = "wasm-prune" +path = "cli/prune/main.rs" +required-features = ["cli"] + +[[bin]] +name = "wasm-ext" +path = "cli/ext/main.rs" +required-features = ["cli"] + +[[bin]] +name = "wasm-gas" +path = "cli/gas/main.rs" +required-features = ["cli"] + +[[bin]] +name = "wasm-build" +path = "cli/build/main.rs" +required-features = ["cli"] + +[[bin]] +name = "wasm-stack-height" +path = "cli/stack_height/main.rs" +required-features = ["cli"] + +[[bin]] +name = "wasm-pack" +path = "cli/pack/main.rs" +required-features = ["cli"] + +[[bin]] +name = "wasm-check" +path = "cli/check/main.rs" +required-features = ["cli"] + [dependencies] # If you add the feature "bulk", make sure you fixed all expects that say # "parity-wasm is compiled without bulk-memory operations" @@ -15,6 +51,12 @@ parity-wasm = { version = "0.41.0", default-features = false } log = { version = "0.4", default-features = false } byteorder = { version = "1", default-features = false } +# Dependencies only used by the binaries +glob = { version = "0.2", optional = true } +clap = { version = "2.24", optional = true } +env_logger = { version = "0.5", optional = true } +lazy_static = { version = "1.0", optional = true } + [dev-dependencies] tempdir = "0.3" wabt = "0.10" @@ -26,8 +68,9 @@ binaryen = "0.8" [features] default = ["std"] std = ["parity-wasm/std", "log/std", "byteorder/std"] - -[workspace] -members = [ - "./cli", +cli = [ + "glob", + "clap", + "env_logger", + "lazy_static", ] diff --git a/cli/Cargo.toml b/cli/Cargo.toml deleted file mode 100644 index 0aa1508..0000000 --- a/cli/Cargo.toml +++ /dev/null @@ -1,51 +0,0 @@ -[package] -name = "pwasm-utils-cli" -version = "0.15.0" -authors = ["Nikolay Volf ", "Sergey Pepyakin "] -license = "MIT/Apache-2.0" -readme = "README.md" -description = "Collection of command-line utilities and corresponding Rust api for producing pwasm-compatible executables" -keywords = ["wasm", "webassembly", "pwasm"] -repository = "https://github.com/paritytech/wasm-utils" - -[lib] - -[[bin]] -name = "wasm-prune" -path = "prune/main.rs" - -[[bin]] -name = "wasm-ext" -path = "ext/main.rs" - -[[bin]] -name = "wasm-gas" -path = "gas/main.rs" - -[[bin]] -name = "wasm-build" -path = "build/main.rs" - -[[bin]] -name = "wasm-stack-height" -path = "stack_height/main.rs" - -[[bin]] -name = "wasm-pack" -path = "pack/main.rs" - -[[bin]] -name = "wasm-check" -path = "check/main.rs" - -[dependencies] -parity-wasm = "0.41.0" -pwasm-utils = { path = "..", version = "0.15" } -glob = "0.2" -clap = "2.24" -log = "0.4" -env_logger = "0.5" -lazy_static = "1.0" - -[dev-dependencies] -tempdir = "0.3" diff --git a/cli/README.md b/cli/README.md deleted file mode 100644 index 7604c69..0000000 --- a/cli/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# pwasm-utils-cli - -Collection of WASM utilities used in Parity and WASM contract devepment - -## Install - -Easiest way to use is to install via `cargo install`: - -``` -cargo install pwasm-utils-cli -``` diff --git a/cli/build/main.rs b/cli/build/main.rs index a03229a..f374d15 100644 --- a/cli/build/main.rs +++ b/cli/build/main.rs @@ -5,7 +5,7 @@ extern crate clap; extern crate glob; extern crate pwasm_utils as utils; extern crate parity_wasm; -extern crate pwasm_utils_cli as logger; +use pwasm_utils::logger; mod source; @@ -67,7 +67,7 @@ pub fn process_output(input: &source::SourceInput) -> Result<(), Error> { } fn do_main() -> Result<(), Error> { - logger::init_log(); + logger::init(); let matches = App::new("wasm-build") .version(crate_version!()) diff --git a/cli/check/main.rs b/cli/check/main.rs index d3d7a3b..7c95c7b 100644 --- a/cli/check/main.rs +++ b/cli/check/main.rs @@ -1,6 +1,6 @@ extern crate parity_wasm; extern crate pwasm_utils as utils; -extern crate pwasm_utils_cli as logger; +use pwasm_utils::logger; extern crate clap; use clap::{App, Arg}; @@ -40,7 +40,7 @@ const ALLOWED_IMPORTS: &[&str] = &[ ]; fn main() { - logger::init_log(); + logger::init(); let matches = App::new("wasm-check") .arg(Arg::with_name("input") diff --git a/cli/ext/main.rs b/cli/ext/main.rs index 02d8ba3..aabb13c 100644 --- a/cli/ext/main.rs +++ b/cli/ext/main.rs @@ -1,12 +1,12 @@ extern crate parity_wasm; extern crate pwasm_utils as utils; -extern crate pwasm_utils_cli as logger; +use pwasm_utils::logger; use std::env; fn main() { - logger::init_log(); + logger::init(); let args = env::args().collect::>(); if args.len() != 3 { diff --git a/cli/gas/main.rs b/cli/gas/main.rs index 6eec5b6..6ec45ee 100644 --- a/cli/gas/main.rs +++ b/cli/gas/main.rs @@ -1,11 +1,11 @@ extern crate parity_wasm; extern crate pwasm_utils as utils; -extern crate pwasm_utils_cli as logger; +use pwasm_utils::logger; use std::env; fn main() { - logger::init_log(); + logger::init(); let args = env::args().collect::>(); if args.len() != 3 { diff --git a/cli/pack/main.rs b/cli/pack/main.rs index 5f163e2..f96219b 100644 --- a/cli/pack/main.rs +++ b/cli/pack/main.rs @@ -1,12 +1,12 @@ extern crate parity_wasm; extern crate pwasm_utils as utils; -extern crate pwasm_utils_cli as logger; +use pwasm_utils::logger; extern crate clap; use clap::{App, Arg}; fn main() { - logger::init_log(); + logger::init(); let target_runtime = utils::TargetRuntime::pwasm(); diff --git a/cli/prune/main.rs b/cli/prune/main.rs index c23ba58..d4fcd41 100644 --- a/cli/prune/main.rs +++ b/cli/prune/main.rs @@ -1,12 +1,12 @@ extern crate parity_wasm; extern crate pwasm_utils as utils; -extern crate pwasm_utils_cli as logger; +use pwasm_utils::logger; extern crate clap; use clap::{App, Arg}; fn main() { - logger::init_log(); + logger::init(); let target_runtime = utils::TargetRuntime::pwasm(); diff --git a/cli/stack_height/main.rs b/cli/stack_height/main.rs index 774baee..1b6842a 100644 --- a/cli/stack_height/main.rs +++ b/cli/stack_height/main.rs @@ -1,12 +1,12 @@ extern crate pwasm_utils as utils; extern crate parity_wasm; -extern crate pwasm_utils_cli as logger; +use pwasm_utils::logger; use std::env; use utils::stack_height; fn main() { - logger::init_log(); + logger::init(); let args = env::args().collect::>(); if args.len() != 3 { diff --git a/src/build.rs b/src/build.rs index e79b72d..5370563 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,4 +1,3 @@ -use std; use super::{ optimize, pack_instance, @@ -10,7 +9,6 @@ use super::{ OptimizerError, TargetRuntime, }; -use parity_wasm; use parity_wasm::elements; #[derive(Debug)] diff --git a/src/ext.rs b/src/ext.rs index 5dc1489..11c5f18 100644 --- a/src/ext.rs +++ b/src/ext.rs @@ -3,9 +3,10 @@ use std::vec::Vec; use std::borrow::ToOwned; use parity_wasm::{elements, builder}; -use optimizer::{import_section, export_section}; use byteorder::{LittleEndian, ByteOrder}; +use crate::optimizer::{import_section, export_section}; + type Insertion = (usize, u32, u32, String); pub fn update_call_index(instructions: &mut elements::Instructions, original_imports: usize, inserts: &[Insertion]) { diff --git a/src/gas/mod.rs b/src/gas/mod.rs index 779029c..860b1c3 100644 --- a/src/gas/mod.rs +++ b/src/gas/mod.rs @@ -12,7 +12,7 @@ use std::mem; use std::vec::Vec; use parity_wasm::{elements, builder}; -use rules::Rules; +use crate::rules::Rules; pub fn update_call_index(instructions: &mut elements::Instructions, inserted_index: u32) { use parity_wasm::elements::Instruction::*; @@ -518,7 +518,7 @@ mod tests { use parity_wasm::{serialize, builder, elements}; use parity_wasm::elements::Instruction::*; use super::*; - use rules; + use crate::rules; pub fn get_function_body(module: &elements::Module, index: usize) -> Option<&[elements::Instruction]> diff --git a/src/gas/validation.rs b/src/gas/validation.rs index d0b1c22..604906c 100644 --- a/src/gas/validation.rs +++ b/src/gas/validation.rs @@ -9,8 +9,8 @@ //! the worst case. use super::MeteredBlock; -use rules::Set as RuleSet; -use rules::Rules; +use crate::rules::Set as RuleSet; +use crate::rules::Rules; use parity_wasm::elements::{FuncBody, Instruction}; use std::collections::HashMap; diff --git a/src/lib.rs b/src/lib.rs index feae73d..081d99f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,6 +25,8 @@ mod ref_list; mod symbols; #[cfg(feature = "std")] mod export_globals; +#[cfg(feature = "cli")] +pub mod logger; pub mod stack_height; diff --git a/cli/src/lib.rs b/src/logger.rs similarity index 76% rename from cli/src/lib.rs rename to src/logger.rs index eeaabb0..222ad50 100644 --- a/cli/src/lib.rs +++ b/src/logger.rs @@ -1,10 +1,7 @@ -#[macro_use] extern crate log; -#[macro_use] extern crate lazy_static; -extern crate env_logger; - use std::env; use log::LevelFilter; use env_logger::Builder; +use lazy_static::lazy_static; lazy_static! { static ref LOG_DUMMY: bool = { @@ -22,6 +19,6 @@ lazy_static! { } /// Intialize log with default settings -pub fn init_log() { +pub fn init() { let _ = *LOG_DUMMY; } diff --git a/src/optimizer.rs b/src/optimizer.rs index 1497544..a123cd6 100644 --- a/src/optimizer.rs +++ b/src/optimizer.rs @@ -7,7 +7,7 @@ use std::mem; use parity_wasm::elements; -use symbols::{Symbol, expand_symbols, push_code_symbols, resolve_function}; +use crate::symbols::{Symbol, expand_symbols, push_code_symbols, resolve_function}; #[derive(Debug)] pub enum Error { From f556bde4a47907b82216df16cabdf0ff067ac389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Wed, 21 Oct 2020 20:26:22 +0200 Subject: [PATCH 2/6] Ignore .vscode directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 05ba60f..6fc8f03 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ target .cargo .DS_Store .idea +.vscode From 3142a74de2fb9ab6773b6bf6cb82836939615f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Wed, 21 Oct 2020 20:49:34 +0200 Subject: [PATCH 3/6] Update README.md to reflect the new package unification --- README.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f780e45..37032d3 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,29 @@ -# wasm-utils +# pwasm-utils [![Build Status](https://travis-ci.org/paritytech/wasm-utils.svg?branch=master)](https://travis-ci.org/paritytech/wasm-utils) -Collection of WASM utilities used in pwasm-ethereum and substrate contract development +A collection of WASM utilities used in pwasm-ethereum and substrate contract development. -## Build tools for cargo - -Easiest way to use is to install via `cargo install`: +This repository contains the package `pwasm-utils` which consists of a library crate +and a collection of cli binaries that make use of this library. +## Installation of cli tools ``` -cargo install pwasm-utils-cli --bin wasm-build +cargo install pwasm-utils --features cli ``` +This will install the following binaries: +* wasm-build +* wasm-check +* wasm-ext +* wasm-gas +* wasm-pack +* wasm-prune +* wasm-stack-height + ## Symbols pruning (wasm-prune) ``` -cargo install pwasm-utils-cli --bin wasm-prune wasm-prune ``` @@ -26,14 +34,9 @@ This will optimize WASM symbols tree to leave only those elements that are used For development puposes, raw WASM contract can be injected with gas counters (the same way as it done by pwasm-ethereum/substrate runtime when running contracts) ``` -cargo install pwasm-utils-cli --bin wasm-gas wasm-gas ``` -## API - -All executables use corresponding api methods of the root crate and can be combined in other build tools. - # License `wasm-utils` is primarily distributed under the terms of both the MIT From a2653cff5adf15f51892184126f16a240a664b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Thu, 22 Oct 2020 10:26:26 +0200 Subject: [PATCH 4/6] Update CI script --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d856856..691eaf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,5 @@ rust: - stable script: - - cargo build --all --release --verbose - - cargo test --all --verbose - - cargo build --no-default-features + - cargo test --all-features --verbose + - cargo build --no-default-features --verbose From aebfc0fbd72c8f07941f0ca9ce977aecca73c1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Thu, 22 Oct 2020 12:26:24 +0200 Subject: [PATCH 5/6] Fixes necessary for having no_std imports work with edition2018 --- src/build.rs | 5 +++-- src/ext.rs | 6 +++--- src/gas/mod.rs | 6 +++--- src/gas/validation.rs | 10 +++++++--- src/graph.rs | 2 +- src/lib.rs | 8 +++++++- src/logger.rs | 2 +- src/optimizer.rs | 8 ++++---- src/pack.rs | 6 +++--- src/ref_list.rs | 16 ++++++++-------- src/rules.rs | 9 +++++---- src/stack_height/max_height.rs | 2 +- src/stack_height/mod.rs | 4 ++-- src/stack_height/thunk.rs | 6 +++--- src/symbols.rs | 6 +++--- 15 files changed, 54 insertions(+), 42 deletions(-) diff --git a/src/build.rs b/src/build.rs index 5370563..8f742fc 100644 --- a/src/build.rs +++ b/src/build.rs @@ -8,6 +8,7 @@ use super::{ PackingError, OptimizerError, TargetRuntime, + std::fmt, }; use parity_wasm::elements; @@ -36,8 +37,8 @@ pub enum SourceTarget { Unknown, } -impl std::fmt::Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { use self::Error::*; match self { Encoding(err) => write!(f, "Encoding error ({})", err), diff --git a/src/ext.rs b/src/ext.rs index 11c5f18..3b129e7 100644 --- a/src/ext.rs +++ b/src/ext.rs @@ -1,6 +1,6 @@ -use std::string::String; -use std::vec::Vec; -use std::borrow::ToOwned; +use crate::std::string::String; +use crate::std::vec::Vec; +use crate::std::borrow::ToOwned; use parity_wasm::{elements, builder}; use byteorder::{LittleEndian, ByteOrder}; diff --git a/src/gas/mod.rs b/src/gas/mod.rs index 860b1c3..90d63ca 100644 --- a/src/gas/mod.rs +++ b/src/gas/mod.rs @@ -7,9 +7,9 @@ #[cfg(test)] mod validation; -use std::cmp::min; -use std::mem; -use std::vec::Vec; +use crate::std::cmp::min; +use crate::std::mem; +use crate::std::vec::Vec; use parity_wasm::{elements, builder}; use crate::rules::Rules; diff --git a/src/gas/validation.rs b/src/gas/validation.rs index 604906c..5f68dcc 100644 --- a/src/gas/validation.rs +++ b/src/gas/validation.rs @@ -11,9 +11,13 @@ use super::MeteredBlock; use crate::rules::Set as RuleSet; use crate::rules::Rules; +use crate::std::vec::Vec; use parity_wasm::elements::{FuncBody, Instruction}; -use std::collections::HashMap; +#[cfg(features = "std")] +use crate::std::collections::HashMap as Map; +#[cfg(not(features = "std"))] +use crate::std::collections::BTreeMap as Map; /// An ID for a node in a ControlFlowGraph. type NodeId = usize; @@ -288,7 +292,7 @@ fn validate_graph_gas_costs(graph: &ControlFlowGraph) -> bool { node_id: NodeId, mut total_actual: u32, mut total_charged: u32, - loop_costs: &mut HashMap, + loop_costs: &mut Map, ) -> bool { let node = graph.get_node(node_id); @@ -325,7 +329,7 @@ fn validate_graph_gas_costs(graph: &ControlFlowGraph) -> bool { } // Recursively explore all paths through the execution graph starting from the entry node. - visit(graph, 0, 0, 0, &mut HashMap::new()) + visit(graph, 0, 0, 0, &mut Map::new()) } /// Validate that the metered blocks are correct with respect to the function body by exhaustively diff --git a/src/graph.rs b/src/graph.rs index 956cc7f..41c4665 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -4,7 +4,7 @@ use parity_wasm::elements; use super::ref_list::{RefList, EntryRef}; -use std::{ +use crate::std::{ vec::Vec, borrow::ToOwned, string::String, diff --git a/src/lib.rs b/src/lib.rs index 081d99f..8b42ccd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,7 +83,7 @@ impl TargetRuntime { #[cfg(not(feature = "std"))] mod std { - pub use alloc::{borrow, boxed, string, vec}; + pub use ::alloc::{borrow, boxed, string, vec}; pub use core::*; pub mod rc { @@ -94,3 +94,9 @@ mod std { pub use alloc::collections::{BTreeMap, BTreeSet}; } } + + +#[cfg(feature = "std")] +mod std { + pub use std::*; +} diff --git a/src/logger.rs b/src/logger.rs index 222ad50..8993eba 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -1,4 +1,4 @@ -use std::env; +use crate::std::env; use log::LevelFilter; use env_logger::Builder; use lazy_static::lazy_static; diff --git a/src/optimizer.rs b/src/optimizer.rs index a123cd6..86fc8b0 100644 --- a/src/optimizer.rs +++ b/src/optimizer.rs @@ -1,9 +1,9 @@ #[cfg(features = "std")] -use std::collections::{HashSet as Set}; +use crate::std::collections::{HashSet as Set}; #[cfg(not(features = "std"))] -use std::collections::{BTreeSet as Set}; -use std::vec::Vec; -use std::mem; +use crate::std::collections::{BTreeSet as Set}; +use crate::std::vec::Vec; +use crate::std::mem; use parity_wasm::elements; diff --git a/src/pack.rs b/src/pack.rs index 0816b5f..becda22 100644 --- a/src/pack.rs +++ b/src/pack.rs @@ -1,6 +1,6 @@ -use std::fmt; -use std::vec::Vec; -use std::borrow::ToOwned; +use crate::std::fmt; +use crate::std::vec::Vec; +use crate::std::borrow::ToOwned; use parity_wasm::elements::{ self, Section, DataSection, Instruction, DataSegment, InitExpr, Internal, External, diff --git a/src/ref_list.rs b/src/ref_list.rs index 376486d..1925d8a 100644 --- a/src/ref_list.rs +++ b/src/ref_list.rs @@ -1,9 +1,9 @@ #![warn(missing_docs)] -use std::rc::Rc; -use std::cell::RefCell; -use std::vec::Vec; -use std::slice; +use crate::std::rc::Rc; +use crate::std::cell::RefCell; +use crate::std::vec::Vec; +use crate::std::slice; #[derive(Debug)] enum EntryOrigin { @@ -50,7 +50,7 @@ impl Entry { } } -impl ::std::ops::Deref for Entry { +impl crate::std::ops::Deref for Entry { type Target = T; fn deref(&self) -> &T { @@ -58,7 +58,7 @@ impl ::std::ops::Deref for Entry { } } -impl ::std::ops::DerefMut for Entry { +impl crate::std::ops::DerefMut for Entry { fn deref_mut(&mut self) -> &mut T { &mut self.val } @@ -82,14 +82,14 @@ impl From> for EntryRef { impl EntryRef { /// Read the reference data. - pub fn read(&self) -> ::std::cell::Ref> { + pub fn read(&self) -> crate::std::cell::Ref> { self.0.borrow() } /// Try to modify internal content of the referenced object. /// /// May panic if it is already borrowed. - pub fn write(&self) -> ::std::cell::RefMut> { + pub fn write(&self) -> crate::std::cell::RefMut> { self.0.borrow_mut() } diff --git a/src/rules.rs b/src/rules.rs index 0cefabf..2256a6c 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -1,9 +1,10 @@ #[cfg(features = "std")] -use std::collections::{HashMap as Map}; +use crate::std::collections::HashMap as Map; #[cfg(not(features = "std"))] -use std::collections::{BTreeMap as Map}; +use crate::std::collections::BTreeMap as Map; -use std::num::NonZeroU32; +use crate::std::num::NonZeroU32; +use crate::std::str::FromStr; use parity_wasm::elements; @@ -68,7 +69,7 @@ pub enum InstructionType { GrowMemory, } -impl ::std::str::FromStr for InstructionType { +impl FromStr for InstructionType { type Err = UnknownInstruction; fn from_str(s: &str) -> Result { diff --git a/src/stack_height/max_height.rs b/src/stack_height/max_height.rs index 23c7ea1..4849092 100644 --- a/src/stack_height/max_height.rs +++ b/src/stack_height/max_height.rs @@ -1,4 +1,4 @@ -use std::vec::Vec; +use crate::std::vec::Vec; use parity_wasm::elements::{self, BlockType, Type}; use super::{resolve_func_type, Error}; diff --git a/src/stack_height/mod.rs b/src/stack_height/mod.rs index 737d84a..d619f9e 100644 --- a/src/stack_height/mod.rs +++ b/src/stack_height/mod.rs @@ -49,8 +49,8 @@ //! between the frames. //! - upon entry into the function entire stack frame is allocated. -use std::string::String; -use std::vec::Vec; +use crate::std::string::String; +use crate::std::vec::Vec; use parity_wasm::elements::{self, Type}; use parity_wasm::builder; diff --git a/src/stack_height/thunk.rs b/src/stack_height/thunk.rs index aaa02ee..11a377d 100644 --- a/src/stack_height/thunk.rs +++ b/src/stack_height/thunk.rs @@ -1,8 +1,8 @@ #[cfg(features = "std")] -use std::collections::{HashMap as Map}; +use crate::std::collections::{HashMap as Map}; #[cfg(not(features = "std"))] -use std::collections::{BTreeMap as Map}; -use std::vec::Vec; +use crate::std::collections::{BTreeMap as Map}; +use crate::std::vec::Vec; use parity_wasm::elements::{self, FunctionType, Internal}; use parity_wasm::builder; diff --git a/src/symbols.rs b/src/symbols.rs index 60b6ef1..8586e65 100644 --- a/src/symbols.rs +++ b/src/symbols.rs @@ -1,8 +1,8 @@ #[cfg(features = "std")] -use std::collections::{HashSet as Set}; +use crate::std::collections::{HashSet as Set}; #[cfg(not(features = "std"))] -use std::collections::{BTreeSet as Set}; -use std::vec::Vec; +use crate::std::collections::{BTreeSet as Set}; +use crate::std::vec::Vec; use parity_wasm::elements; From 2430b186337d9006d21718a2333650aa78981828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Thu, 22 Oct 2020 12:27:31 +0200 Subject: [PATCH 6/6] Make feature "std" a requirement for the "cli" feature --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 0346577..80755bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,7 @@ binaryen = "0.8" default = ["std"] std = ["parity-wasm/std", "log/std", "byteorder/std"] cli = [ + "std", "glob", "clap", "env_logger",