Unify pwasm-utils and pwasm-utils-cli packet

This commit is contained in:
Alexander Theißen
2020-10-21 20:24:49 +02:00
parent af761da031
commit f05f43b883
17 changed files with 72 additions and 93 deletions
+47 -4
View File
@@ -1,6 +1,7 @@
[package]
name = "pwasm-utils"
version = "0.15.0"
edition = "2018"
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Sergey Pepyakin <s.pepyakin@gmail.com>"]
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",
]
-51
View File
@@ -1,51 +0,0 @@
[package]
name = "pwasm-utils-cli"
version = "0.15.0"
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Sergey Pepyakin <s.pepyakin@gmail.com>"]
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"
-11
View File
@@ -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
```
+2 -2
View File
@@ -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!())
+2 -2
View File
@@ -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")
+2 -2
View File
@@ -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::<Vec<_>>();
if args.len() != 3 {
+2 -2
View File
@@ -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::<Vec<_>>();
if args.len() != 3 {
+2 -2
View File
@@ -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();
+2 -2
View File
@@ -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();
+2 -2
View File
@@ -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::<Vec<_>>();
if args.len() != 3 {
-2
View File
@@ -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)]
+2 -1
View File
@@ -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]) {
+2 -2
View File
@@ -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]>
+2 -2
View File
@@ -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;
+2
View File
@@ -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;
+2 -5
View File
@@ -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;
}
+1 -1
View File
@@ -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 {