Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
dhil committed Oct 11, 2022
2 parents 3b5ca9d + 3fe7b1d commit 199220c
Show file tree
Hide file tree
Showing 126 changed files with 2,488 additions and 2,765 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ jobs:
- run: cargo check --no-default-features --features mutate
- run: cargo check --no-default-features --features dump
- run: cargo check --no-default-features --features objdump
- run: cargo check --no-default-features --features strip
- run: cargo check --no-default-features --features compose

doc:
runs-on: ubuntu-latest
Expand Down
78 changes: 56 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "wasm-tools"
version = "1.0.10"
version = "1.0.12"
authors = ["The Wasmtime Project Developers"]
edition = "2021"
edition.workspace = true
description = "CLI tools for interoperating with WebAssembly files"
license = "Apache-2.0 WITH LLVM-exception"
documentation = "https://github.com/bytecodealliance/wasm-tools"
Expand All @@ -13,49 +13,83 @@ readme = "README.md"
exclude = ['tests/wabt', 'tests/testsuite', 'publish.rs']

[workspace]
members = ['crates/c-api', 'fuzz', 'crates/wasm-encoder', 'crates/fuzz-stats', 'crates/wasm-mutate-stats']
members = [
'crates/c-api',
'crates/fuzz-stats',
'crates/wasm-mutate-stats',
'fuzz',
]

[workspace.package]
edition = '2021'

[workspace.dependencies]
anyhow = "1.0.58"
arbitrary = "1.1.0"
clap = { version = "4.0.0", features = ["derive"] }
criterion = "0.3.3"
env_logger = "0.9"
indexmap = "1.9.1"
leb128 = "0.2.4"
libfuzzer-sys = "0.4.0"
log = "0.4.17"
num_cpus = "1.13"
rand = { version = "0.8.4", features = ["small_rng"] }
rayon = "1.3"
serde = { version = "1.0.137", features = ["derive"] }
wasmtime = "1.0.0"

wasm-encoder = { version = "0.18.0", path = "crates/wasm-encoder"}
wasm-compose = { version = "0.1.3", path = "crates/wasm-compose"}
wasm-mutate = { version = "0.2.4", path = "crates/wasm-mutate" }
wasm-shrink = { version = "0.1.6", path = "crates/wasm-shrink" }
wasm-smith = { version = "0.11.2", path = "crates/wasm-smith" }
wasmparser = { version = "0.92.0", path = "crates/wasmparser" }
wasmparser-dump = { version = "0.1.4", path = "crates/dump" }
wasmprinter = { version = "0.2.36", path = "crates/wasmprinter" }
wast = { version = "47.0.1", path = "crates/wast" }
wat = { version = "1.0.44", path = "crates/wat" }

[dependencies]
anyhow = "1.0"
anyhow = { workspace = true }
env_logger = { workspace = true }
atty = "0.2"
env_logger = "0.9"
log = "0.4"
clap = { version = "3.1.8", features = ['derive'] }
log = { workspace = true }
clap = { workspace = true }
tempfile = "3.2.0"
wat = { path = "crates/wat", version = '1.0.48' }
wat = { workspace = true }

# Dependencies of `validate`
wasmparser = { path = "crates/wasmparser", optional = true, version = '0.90.0' }
rayon = { version = "1.0", optional = true }
wasmparser = { workspace = true, optional = true }
rayon = { workspace = true, optional = true }

# Dependencies of `print`
wasmprinter = { path = "crates/wasmprinter", version = '0.2.39' }
wasmprinter = { workspace = true }

# Dependencies of `smith`
arbitrary = { version = "1.0.0", optional = true }
serde = { version = "1", features = ['derive'], optional = true }
arbitrary = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
serde_json = { version = "1", optional = true }
wasm-smith = { path = "crates/wasm-smith", features = ["_internal_cli"], optional = true, version = '0.11.4' }
wasm-smith = { workspace = true, features = ["_internal_cli"], optional = true }

# Dependencies of `shrink`
wasm-shrink = { path = "crates/wasm-shrink", features = ["clap"], optional = true, version = '0.1.9' }
wasm-shrink = { workspace = true, features = ["clap"], optional = true }
is_executable = { version = "1.0.1", optional = true }

# Dependencies of `mutate`
wasm-mutate = { path = "crates/wasm-mutate", features = ["clap"], optional = true, version = '0.2.7' }
wasm-mutate = { workspace = true, features = ["clap"], optional = true }

# Dependencies of `dump`
wasmparser-dump = { path = "crates/dump", optional = true, version = '0.1.7' }
wasmparser-dump = { workspace = true, optional = true }

# Dependencies of `strip`
wasm-encoder = { path = "crates/wasm-encoder", optional = true, version = '0.16.0' }
wasm-encoder = { workspace = true, optional = true }
regex = { version = "1.6.0", optional = true }

# Dependencies of `compose`
wasm-compose = { path = "crates/wasm-compose", optional = true, version = '0.1.0', features = ['cli'] }
wasm-compose = { workspace = true, optional = true, features = ['cli'] }

[dev-dependencies]
anyhow = "1.0"
getopts = "0.2"
serde_json = "1.0"
tempfile = "3.1"
diff = "0.1"
Expand Down Expand Up @@ -83,5 +117,5 @@ shrink = ['wasm-shrink', 'is_executable']
mutate = ['wasm-mutate']
dump = ['wasmparser-dump']
objdump = ['wasmparser']
strip = ['wasm-encoder']
strip = ['wasm-encoder', 'wasmparser', 'regex']
compose = ['wasm-compose']
20 changes: 10 additions & 10 deletions crates/c-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "wasm-tools-c-api"
authors = ["Addison Hart <tgr@tgrcode.com>"]
categories = ["development-tools", "development-tools::testing", "wasm"]
description = "C API to expose wasm-tools"
edition = "2021"
edition.workspace = true
license = "Apache-2.0 WITH LLVM-exception"
readme = "./README.md"
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/c-api"
Expand All @@ -18,12 +18,12 @@ test = false
doctest = false

[dependencies]
arbitrary = { version = "1.1.0", features = ["derive"] }
wasmparser-dump = { version = "0.1.4", path = "../dump" }
wasm-mutate = { version = "0.2.4", path = "../wasm-mutate" }
wasm-shrink = { version = "0.1.6", path = "../wasm-shrink" }
wasm-smith = { version = "0.11.2", path = "../wasm-smith" }
wasmparser = { version = "0.90.0", path = "../wasmparser" }
wasmprinter = { version = "0.2.36", path = "../wasmprinter" }
wast = { version = "46.0.0", path = "../wast" }
wat = { version = "1.0.44", path = "../wat" }
arbitrary = { workspace = true, features = ["derive"] }
wasmparser-dump = { workspace = true }
wasm-mutate = { workspace = true }
wasm-shrink = { workspace = true }
wasm-smith = { workspace = true }
wasmparser = { workspace = true }
wasmprinter = { workspace = true }
wast = { workspace = true }
wat = { workspace = true }
8 changes: 4 additions & 4 deletions crates/dump/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "wasmparser-dump"
version = "0.1.7"
version = "0.1.9"
authors = ["The Wasmtime Project Developers"]
edition = "2021"
edition.workspace = true
license = "Apache-2.0 WITH LLVM-exception"
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/dump"
description = "Utility to dump debug information about the wasm binary format"

[dependencies]
anyhow = "1"
wasmparser = { path = "../wasmparser", version = "0.90.0" }
anyhow = { workspace = true }
wasmparser = { workspace = true }
14 changes: 7 additions & 7 deletions crates/fuzz-stats/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "fuzz-stats"
version = "0.1.0"
edition = "2021"
edition.workspace = true
publish = false

[dependencies]
anyhow = "1.0"
arbitrary = "1.0"
num_cpus = "1.13"
rand = "0.8"
wasm-smith = { path = '../wasm-smith' }
wasmtime = "0.38.1"
anyhow = { workspace = true }
arbitrary = { workspace = true }
num_cpus = { workspace = true }
rand = { workspace = true }
wasm-smith = { workspace = true }
wasmtime = { workspace = true }

[lib]
doctest = false
Expand Down
22 changes: 11 additions & 11 deletions crates/wasm-compose/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "wasm-compose"
version = "0.1.1"
edition = "2021"
version = "0.1.3"
edition.workspace = true
authors = ["Peter Huene <peter@huene.dev>"]
license = "Apache-2.0 WITH LLVM-exception"
readme = "README.md"
Expand All @@ -11,16 +11,16 @@ documentation = "https://docs.rs/wasm-compose"
description = "A library for composing WebAssembly components."

[dependencies]
wat = { version = "1.0.48", path = "../wat" }
wasm-encoder = { version = "0.16.0", path = "../wasm-encoder" }
wasmparser = { version = "0.90.0", path = "../wasmparser" }
indexmap = { version = "1.9.1", features = ["serde"] }
anyhow = "1.0.58"
serde = { version = "1.0.137", features = ["derive"] }
wat = { workspace = true }
wasm-encoder = { workspace = true }
wasmparser = { workspace = true }
indexmap = { workspace = true, features = ["serde"] }
anyhow = { workspace = true }
serde = { workspace = true }
petgraph = "0.6.2"
log = "0.4.17"
log = { workspace = true }
serde_yaml = "0.8.26"
clap = { version = "3.2.7", features = ["derive"], optional = true }
clap = { workspace = true, optional = true }

[features]
default = []
Expand All @@ -29,4 +29,4 @@ cli = ["clap"]
[dev-dependencies]
glob = "0.3.0"
pretty_assertions = "1.2.1"
wasmprinter = { version = "0.2.39", path = "../wasmprinter" }
wasmprinter = { workspace = true }
2 changes: 1 addition & 1 deletion crates/wasm-compose/example/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
publish = false

[dependencies]
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", default_features = false }
wit-bindgen-guest-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", default_features = false }

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm-compose/example/middleware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false

[dependencies]
flate2 = "1.0.24"
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", default_features = false }
wit-bindgen-guest-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", default_features = false }

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm-compose/example/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ async-std = { version = "1.12.0", features = ["attributes"] }
clap = { version = "3.2.16", features = ["derive"] }
driftwood = "0.0.6"
tide = "0.16.0"
wasmtime = { version = "0.41.0", features = ["component-model"], git = "https://github.com/bytecodealliance/wasmtime", rev = "1ce9e8aa5f32a8dad42f02c8fd84514a641c4a5c" }
wasmtime = { features = ["component-model"], git = "https://github.com/bytecodealliance/wasmtime", rev = "e45577e097b064797def3554468cffa5fdd443d3" }

[workspace]
4 changes: 2 additions & 2 deletions crates/wasm-compose/example/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ impl ServerApp {
// Instantiate the service component and get its `execute` export
let instance = linker.instantiate(&mut store, &state.component)?;
let execute = instance
.get_typed_func::<(ServiceRequest,), ServiceResult, _>(&mut store, "execute")?;
.get_typed_func::<(ServiceRequest,), (ServiceResult,), _ >(&mut store, "execute")?;

// Call the `execute` export with the request and translate the response
execute
.call(&mut store, (ServiceRequest::new(req).await?,))?
.map_err(Into::into)
.0.map_err(Into::into)
.and_then(TryInto::try_into)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm-compose/example/service.wit
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ enum error {
bad-request,
}

execute: func(req: request) -> expected<response, error>
execute: func(req: request) -> result<response, error>
2 changes: 1 addition & 1 deletion crates/wasm-compose/example/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
publish = false

[dependencies]
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", default_features = false }
wit-bindgen-guest-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", default_features = false }

[lib]
crate-type = ["cdylib"]
Expand Down
5 changes: 5 additions & 0 deletions crates/wasm-compose/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct WasmComposeCommand {
#[clap(long)]
pub skip_validation: bool,

/// Do not allow instance imports in the composed output component.
#[clap(long = "no-imports")]
pub disallow_imports: bool,

/// The path to the root component to compose.
#[clap(value_name = "COMPONENT")]
pub component: PathBuf,
Expand Down Expand Up @@ -91,6 +95,7 @@ impl WasmComposeCommand {

config.search_paths.extend(self.paths.iter().cloned());
config.skip_validation |= self.skip_validation;
config.disallow_imports |= self.disallow_imports;
Ok(config)
}
}
14 changes: 10 additions & 4 deletions crates/wasm-compose/src/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Component {
import_name: Option<String>,
) -> Result<Self> {
let path = path.into();
log::debug!("parsing WebAssembly component `{}`", path.display());
log::info!("parsing WebAssembly component `{}`", path.display());

let bytes = wat::parse_file(&path).with_context(|| {
format!("failed to parse component `{path}`", path = path.display())
Expand Down Expand Up @@ -518,7 +518,7 @@ impl<'a> InstantiationGraphBuilder<'a> {
}

// Otherwise, search the paths for a valid component with the same name
log::debug!("searching for a component with name `{name}`");
log::info!("searching for a component with name `{name}`");
for dir in std::iter::once(&self.config.dir).chain(self.config.search_paths.iter()) {
if let Some(component) = Self::parse_component(index, dir, name)? {
return Ok(Some(component));
Expand All @@ -537,7 +537,7 @@ impl<'a> InstantiationGraphBuilder<'a> {
for ext in ["wasm", "wat"] {
path.set_extension(ext);
if !path.is_file() {
log::debug!("component `{path}` does not exist", path = path.display());
log::info!("component `{path}` does not exist", path = path.display());
continue;
}

Expand Down Expand Up @@ -572,6 +572,12 @@ impl<'a> InstantiationGraphBuilder<'a> {
Instance::Instantiation { component }
}
None => {
if self.config.disallow_imports {
bail!(
"a dependency named `{component_name}` could not be found and instance imports are not allowed",
);
}

log::warn!("instance `{name}` will be imported because a dependency named `{component_name}` could not be found");
Instance::Import([import.unwrap()].into())
}
Expand Down Expand Up @@ -684,7 +690,7 @@ impl<'a> InstantiationGraphBuilder<'a> {
fn process_dependency(&mut self, dependency: Dependency) -> Result<(InstanceIndex, bool)> {
let name = self.config.dependency_name(&dependency.instance);

log::debug!(
log::info!(
"processing dependency `{name}` from instance `{dependent}` to instance `{instance}`",
dependent = self
.graph
Expand Down
9 changes: 8 additions & 1 deletion crates/wasm-compose/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ pub struct Config {
#[serde(default)]
pub skip_validation: bool,

/// Whether or not to disallow instance imports in the output component.
///
/// Enabling this option will cause an error if a dependency cannot be
/// located.
#[serde(default)]
pub disallow_imports: bool,

/// The explicit, transitive dependencies of the root component.
#[serde(default, deserialize_with = "de::index_map")]
pub dependencies: IndexMap<String, Dependency>,
Expand All @@ -110,7 +117,7 @@ impl Config {
pub fn from_file(path: impl Into<PathBuf>) -> Result<Self> {
let path = path.into();

log::debug!("reading configuration file `{}`", path.display());
log::info!("reading configuration file `{}`", path.display());

let config = fs::read_to_string(&path)
.with_context(|| format!("failed to read configuration file `{}`", path.display()))?;
Expand Down
Loading

0 comments on commit 199220c

Please sign in to comment.