Skip to content

Commit d953307

Browse files
authored
Extract json-from-wast to its own crate (#2247)
* Extract `json-from-wast` subcommand to its own crate Polish it up a bit for publication to crates.io to get used externally as well, for example in Rust projects that want to consume the AST produced here. * Refine the AST of json-from-wast This mostly doesn't change the JSON representation or how things are serialized, but this does change the Rust-level representation to make it easier to consume from a Rust crate (less stringly-typed). A few minor adjustments were made and additionally new structures are supported (e.g. component model types) * Undo some `dbg!` * Undo some `gc.rs` changes * Fix MSRV compat * Add to publish list * Remove readme directive
1 parent 40fe970 commit d953307

File tree

9 files changed

+1180
-706
lines changed

9 files changed

+1180
-706
lines changed

Cargo.lock

Lines changed: 15 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ wit-component = { version = "0.235.0", path = "crates/wit-component" }
156156
wit-encoder = { version = "0.235.0", path = "crates/wit-encoder" }
157157
wit-parser = { version = "0.235.0", path = "crates/wit-parser" }
158158
wit-smith = { version = "0.235.0", path = "crates/wit-smith" }
159+
json-from-wast = { version = "0.235.0", path = "crates/json-from-wast" }
159160

160161
[dependencies]
161162
anyhow = { workspace = true }
@@ -220,6 +221,9 @@ gimli = { workspace = true, optional = true }
220221
# Dependencies of `wast`
221222
pretty_assertions = { workspace = true, optional = true }
222223

224+
# Dependencies of `json-from-wast`
225+
json-from-wast = { workspace = true, optional = true }
226+
223227
[target.'cfg(not(target_family = "wasm"))'.dependencies]
224228
is_executable = { version = "1.0.1", optional = true }
225229

@@ -291,7 +295,7 @@ metadata = ['wasm-metadata', 'dep:serde_json']
291295
wit-smith = ['dep:wit-smith', 'arbitrary']
292296
addr2line = ['dep:addr2line', 'dep:gimli']
293297
completion = ['dep:clap_complete']
294-
json-from-wast = ['dep:serde_derive', 'dep:serde_json', 'dep:wast', 'dep:serde']
298+
json-from-wast = ['dep:json-from-wast', 'dep:wast', 'dep:serde_json']
295299
wast = [
296300
'dep:wast',
297301
'wasm-encoder/wasmparser',

ci/publish.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const CRATES_TO_PUBLISH: &[&str] = &[
3131
"wit-encoder",
3232
"wasm-compose",
3333
"wit-smith",
34+
"json-from-wast",
3435
"wasm-wave",
3536
"wasm-tools",
3637
];

crates/json-from-wast/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "json-from-wast"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/json-from-wast"
7+
homepage = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/json-from-wast"
8+
documentation = "https://docs.rs/json-from-wast"
9+
description = """
10+
Conversion from `*.wast` files to JSON.
11+
"""
12+
rust-version.workspace = true
13+
14+
[lints]
15+
workspace = true
16+
17+
[dependencies]
18+
anyhow = { workspace = true }
19+
serde = { workspace = true, features = ['derive'] }
20+
serde_derive = { workspace = true }
21+
wast = { workspace = true, features = ['wasm-module', 'dwarf', 'component-model'] }

0 commit comments

Comments
 (0)