mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-07-03 08:21:39 +00:00
Refactor executables to separate crates
This commit is contained in:
42
Cargo.toml
42
Cargo.toml
@ -8,37 +8,25 @@ description = "Collection of command-line utilities and corresponding Rust api f
|
||||
keywords = ["wasm", "webassembly", "pwasm"]
|
||||
|
||||
[dependencies]
|
||||
parity-wasm = "0.27"
|
||||
log = "0.3"
|
||||
env_logger = "0.4"
|
||||
lazy_static = "0.2"
|
||||
clap = "2.24"
|
||||
glob = "0.2"
|
||||
byteorder = "1"
|
||||
parity-wasm = { git = "https://github.com/paritytech/parity-wasm", default-features = false }
|
||||
log = { version = "0.4", default-features = false }
|
||||
byteorder = { version = "1", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
tempdir = "0.3"
|
||||
wabt = "0.2"
|
||||
diff = "0.1.11"
|
||||
|
||||
[lib]
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["parity-wasm/std", "log/std", "byteorder/std"]
|
||||
|
||||
[[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"
|
||||
[workspace]
|
||||
members = [
|
||||
"./logger",
|
||||
"./build",
|
||||
"./ext",
|
||||
"./gas",
|
||||
"./prune",
|
||||
"./stack_height",
|
||||
]
|
||||
|
19
build/Cargo.toml
Normal file
19
build/Cargo.toml
Normal file
@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "pwasm-utils-build"
|
||||
version = "0.1.5"
|
||||
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"]
|
||||
|
||||
[[bin]]
|
||||
name = "wasm-build"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
parity-wasm = { git = "https://github.com/paritytech/parity-wasm" }
|
||||
pwasm-utils = { path = ".." }
|
||||
pwasm-utils-logger = { path = "../logger" }
|
||||
glob = "0.2"
|
||||
clap = "2.24"
|
@ -4,6 +4,7 @@ extern crate glob;
|
||||
extern crate pwasm_utils as utils;
|
||||
extern crate clap;
|
||||
extern crate parity_wasm;
|
||||
extern crate logger;
|
||||
|
||||
mod source;
|
||||
|
||||
@ -95,7 +96,7 @@ fn has_ctor(module: &elements::Module) -> bool {
|
||||
}
|
||||
|
||||
fn do_main() -> Result<(), Error> {
|
||||
utils::init_log();
|
||||
logger::init_log();
|
||||
|
||||
let matches = App::new("wasm-build")
|
||||
.arg(Arg::with_name("target")
|
17
ext/Cargo.toml
Normal file
17
ext/Cargo.toml
Normal file
@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "pwasm-utils-ext"
|
||||
version = "0.1.5"
|
||||
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"]
|
||||
|
||||
[[bin]]
|
||||
name = "wasm-ext"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
parity-wasm = { git = "https://github.com/paritytech/parity-wasm" }
|
||||
pwasm-utils = { path = ".." }
|
||||
pwasm-utils-logger = { path = "../logger" }
|
@ -1,11 +1,12 @@
|
||||
extern crate parity_wasm;
|
||||
extern crate pwasm_utils as utils;
|
||||
extern crate logger;
|
||||
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
|
||||
utils::init_log();
|
||||
logger::init_log();
|
||||
|
||||
let args = env::args().collect::<Vec<_>>();
|
||||
if args.len() != 3 {
|
17
gas/Cargo.toml
Normal file
17
gas/Cargo.toml
Normal file
@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "pwasm-utils-gas"
|
||||
version = "0.1.5"
|
||||
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"]
|
||||
|
||||
[[bin]]
|
||||
name = "wasm-gas"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
parity-wasm = { git = "https://github.com/paritytech/parity-wasm" }
|
||||
pwasm-utils = { path = ".." }
|
||||
pwasm-utils-logger = { path = "../logger" }
|
@ -1,11 +1,11 @@
|
||||
extern crate parity_wasm;
|
||||
extern crate pwasm_utils as utils;
|
||||
extern crate logger;
|
||||
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
|
||||
utils::init_log();
|
||||
logger::init_log();
|
||||
|
||||
let args = env::args().collect::<Vec<_>>();
|
||||
if args.len() != 3 {
|
16
logger/Cargo.toml
Normal file
16
logger/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "pwasm-utils-logger"
|
||||
version = "0.1.5"
|
||||
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"]
|
||||
|
||||
[lib]
|
||||
name = "logger"
|
||||
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
env_logger = "0.5"
|
||||
lazy_static = "1.0"
|
27
logger/src/lib.rs
Normal file
27
logger/src/lib.rs
Normal file
@ -0,0 +1,27 @@
|
||||
#[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;
|
||||
|
||||
lazy_static! {
|
||||
static ref LOG_DUMMY: bool = {
|
||||
let mut builder = Builder::new();
|
||||
builder.filter(None, LevelFilter::Info);
|
||||
|
||||
if let Ok(log) = env::var("RUST_LOG") {
|
||||
builder.parse(&log);
|
||||
}
|
||||
|
||||
builder.init();
|
||||
trace!("logger initialized");
|
||||
true
|
||||
};
|
||||
}
|
||||
|
||||
/// Intialize log with default settings
|
||||
pub fn init_log() {
|
||||
let _ = *LOG_DUMMY;
|
||||
}
|
18
prune/Cargo.toml
Normal file
18
prune/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "pwasm-utils-prune"
|
||||
version = "0.1.5"
|
||||
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"]
|
||||
|
||||
[[bin]]
|
||||
name = "wasm-prune"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
parity-wasm = { git = "https://github.com/paritytech/parity-wasm" }
|
||||
pwasm-utils = { path = ".." }
|
||||
pwasm-utils-logger = { path = "../logger" }
|
||||
clap = "2.24"
|
@ -1,11 +1,12 @@
|
||||
extern crate parity_wasm;
|
||||
extern crate pwasm_utils as utils;
|
||||
extern crate logger;
|
||||
extern crate clap;
|
||||
|
||||
use clap::{App, Arg};
|
||||
|
||||
fn main() {
|
||||
utils::init_log();
|
||||
logger::init_log();
|
||||
|
||||
let matches = App::new("wasm-opt")
|
||||
.arg(Arg::with_name("input")
|
@ -1,8 +1,6 @@
|
||||
extern crate parity_wasm;
|
||||
extern crate env_logger;
|
||||
extern crate byteorder;
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
|
||||
pub static CREATE_SYMBOL: &'static str = "deploy";
|
||||
pub static CALL_SYMBOL: &'static str = "call";
|
||||
@ -13,7 +11,6 @@ pub mod rules;
|
||||
mod optimizer;
|
||||
mod gas;
|
||||
mod symbols;
|
||||
mod logger;
|
||||
mod ext;
|
||||
mod pack;
|
||||
mod runtime_type;
|
||||
@ -22,7 +19,6 @@ pub mod stack_height;
|
||||
|
||||
pub use optimizer::{optimize, Error as OptimizerError};
|
||||
pub use gas::inject_gas_counter;
|
||||
pub use logger::init_log;
|
||||
pub use ext::{externalize, externalize_mem, underscore_funcs, ununderscore_funcs, shrink_unknown_stack};
|
||||
pub use pack::{pack_instance, Error as PackingError};
|
||||
pub use runtime_type::inject_runtime_type;
|
||||
|
@ -1,26 +0,0 @@
|
||||
extern crate log;
|
||||
|
||||
use std::env;
|
||||
use log::LogLevelFilter;
|
||||
use env_logger::LogBuilder;
|
||||
|
||||
lazy_static! {
|
||||
static ref LOG_DUMMY: bool = {
|
||||
let mut builder = LogBuilder::new();
|
||||
builder.filter(None, LogLevelFilter::Info);
|
||||
|
||||
if let Ok(log) = env::var("RUST_LOG") {
|
||||
builder.parse(&log);
|
||||
}
|
||||
|
||||
if let Ok(_) = builder.init() {
|
||||
trace!("logger initialized");
|
||||
}
|
||||
true
|
||||
};
|
||||
}
|
||||
|
||||
/// Intialize log with default settings
|
||||
pub fn init_log() {
|
||||
let _ = *LOG_DUMMY;
|
||||
}
|
17
stack_height/Cargo.toml
Normal file
17
stack_height/Cargo.toml
Normal file
@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "pwasm-utils-stack-height"
|
||||
version = "0.1.5"
|
||||
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"]
|
||||
|
||||
[[bin]]
|
||||
name = "wasm-stack-height"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
parity-wasm = { git = "https://github.com/paritytech/parity-wasm" }
|
||||
pwasm-utils = { path = ".." }
|
||||
pwasm-utils-logger = { path = "../logger" }
|
@ -1,11 +1,12 @@
|
||||
extern crate pwasm_utils as utils;
|
||||
extern crate parity_wasm;
|
||||
extern crate logger;
|
||||
|
||||
use std::env;
|
||||
use utils::stack_height;
|
||||
|
||||
fn main() {
|
||||
utils::init_log();
|
||||
logger::init_log();
|
||||
|
||||
let args = env::args().collect::<Vec<_>>();
|
||||
if args.len() != 3 {
|
Reference in New Issue
Block a user