Skip to content

Commit 5cd1b1d

Browse files
authored
Update Wasmtime and Wizer (#1090)
1 parent ca67657 commit 5cd1b1d

File tree

19 files changed

+736
-523
lines changed

19 files changed

+736
-523
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ license = "Apache-2.0 WITH LLVM-exception"
2424
[workspace.dependencies]
2525
brotli = "8.0.2"
2626
clap = { version = "4.5.53", features = ["derive"] }
27-
wizer = "10.0.0"
28-
wasmtime = "36"
29-
wasmtime-wasi = "36"
27+
wasmtime = "39"
28+
wasmtime-wasi = "39"
29+
wasmtime-wizer = "39"
3030
wasm-opt = "0.116.1"
3131
anyhow = "1.0"
3232
javy = { path = "crates/javy", version = "6.0.1-alpha.1" }
3333
tempfile = "3.23.0"
34+
tokio = "1"
3435
uuid = { version = "1.18", features = ["v4"] }
3536
serde = { version = "1.0", default-features = false }
3637
serde_json = "1.0"

crates/cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ anyhow = { workspace = true }
1515
wasmtime = { workspace = true }
1616
walrus = { workspace = true }
1717
tempfile = { workspace = true }
18+
tokio = { workspace = true, features = ["macros"] }
1819
clap = { workspace = true }
1920
serde = { workspace = true, default-features = false }
2021
serde_json = { workspace = true }
@@ -32,3 +33,4 @@ wit-component = "0.242.0"
3233
anyhow = { workspace = true }
3334
javy-plugin-processing = { path = "../plugin-processing" }
3435
tempfile = { workspace = true }
36+
tokio = { workspace = true, features = ["macros"] }

crates/cli/build.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ use std::path::{Path, PathBuf};
44

55
use anyhow::Result;
66

7-
fn main() -> Result<()> {
7+
#[tokio::main]
8+
async fn main() -> Result<()> {
89
if let Ok("cargo-clippy") = env::var("CARGO_CFG_FEATURE").as_ref().map(String::as_str) {
910
stub_plugin_for_clippy()
1011
} else {
11-
copy_plugin()
12+
copy_plugin().await
1213
}
1314
}
1415

@@ -27,7 +28,7 @@ fn stub_plugin_for_clippy() -> Result<()> {
2728
}
2829

2930
// Copy the plugin binary build from the `plugin` crate
30-
fn copy_plugin() -> Result<()> {
31+
async fn copy_plugin() -> Result<()> {
3132
let cargo_manifest_dir = env::var("CARGO_MANIFEST_DIR")?;
3233
let module_path = PathBuf::from(&cargo_manifest_dir)
3334
.parent()
@@ -38,7 +39,8 @@ fn copy_plugin() -> Result<()> {
3839
let plugin_path = module_path.join("plugin.wasm");
3940
let plugin_wizened_path = module_path.join("plugin_wizened.wasm");
4041

41-
let initialized_plugin = javy_plugin_processing::initialize_plugin(&fs::read(&plugin_path)?)?;
42+
let initialized_plugin =
43+
javy_plugin_processing::initialize_plugin(&fs::read(&plugin_path)?).await?;
4244
fs::write(&plugin_wizened_path, &initialized_plugin)?;
4345

4446
println!("cargo:rerun-if-changed={}", plugin_path.to_str().unwrap());

crates/cli/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use std::fs;
1515
use std::fs::File;
1616
use std::io::Write;
1717

18-
fn main() -> Result<()> {
18+
#[tokio::main]
19+
async fn main() -> Result<()> {
1920
let args = Cli::parse();
2021

2122
match &args.command {
@@ -54,7 +55,7 @@ fn main() -> Result<()> {
5455
generator.linking(LinkingKind::Static);
5556
};
5657

57-
let wasm = generator.generate(&js)?;
58+
let wasm = generator.generate(&js).await?;
5859

5960
fs::write(&opts.output, wasm)?;
6061
Ok(())
@@ -63,7 +64,7 @@ fn main() -> Result<()> {
6364
let plugin_bytes = fs::read(&opts.plugin)?;
6465

6566
let uninitialized_plugin = UninitializedPlugin::new(&plugin_bytes)?;
66-
let initialized_plugin_bytes = uninitialized_plugin.initialize()?;
67+
let initialized_plugin_bytes = uninitialized_plugin.initialize().await?;
6768

6869
let mut out: Box<dyn Write> = match opts.out.as_ref() {
6970
Some(path) => Box::new(File::create(path)?),

crates/cli/src/plugin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ impl<'a> UninitializedPlugin<'a> {
4848
}
4949

5050
/// Initializes the plugin.
51-
pub(crate) fn initialize(&self) -> Result<Vec<u8>> {
52-
javy_plugin_processing::initialize_plugin(self.bytes)
51+
pub(crate) async fn initialize(&self) -> Result<Vec<u8>> {
52+
javy_plugin_processing::initialize_plugin(self.bytes).await
5353
}
5454

5555
fn validate(plugin_bytes: &'a [u8]) -> Result<()> {

crates/cli/tests/integration_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ fn test_source_code_omitted(builder: &mut Builder) -> Result<()> {
391391
fn test_init_plugin() -> Result<()> {
392392
let engine = Engine::default();
393393
let mut linker = Linker::new(&engine);
394-
wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, |s| s)?;
394+
wasmtime_wasi::p1::add_to_linker_sync(&mut linker, |s| s)?;
395395
let wasi = WasiCtxBuilder::new().build_p1();
396396
let mut store = Store::new(&engine, wasi);
397397

crates/codegen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
### Changed
12+
13+
- The `generate` method on `Generator` is now async.
14+
1115
## [3.0.0] - 2025-11-12
1216

1317
### Changed

crates/codegen/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "javy-codegen"
3-
version = "3.0.1-alpha.1"
3+
version = "4.0.0-alpha.1"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true
@@ -13,11 +13,11 @@ categories = ["wasm"]
1313
plugin_internal = []
1414

1515
[dependencies]
16-
wizer = { workspace = true }
1716
anyhow = { workspace = true }
1817
brotli = { workspace = true }
1918
wasmtime = { workspace = true }
2019
wasmtime-wasi = { workspace = true }
20+
wasmtime-wizer = { workspace = true, features = ["wasmtime"] }
2121
walrus = { workspace = true }
2222
swc_core = { version = "49.0.0", features = [
2323
"common_sourcemap",
@@ -32,4 +32,5 @@ wasmparser = { workspace = true }
3232

3333
[dev-dependencies]
3434
insta = "1.44.3"
35+
tokio = { workspace = true, features = ["macros"] }
3536
wasmprinter = "0.242.0"

crates/codegen/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Example usage:
1717
use std::path::Path;
1818
use javy_codegen::{Generator, LinkingKind, Plugin, JS};
1919

20-
fn main() {
20+
#[tokio::main]
21+
async fn main() {
2122
// Load your target Javascript.
2223
let js = JS::from_file(Path::new("example.js"));
2324

@@ -30,6 +31,6 @@ fn main() {
3031
generator.linking(LinkingKind::Static);
3132

3233
// Generate your Wasm module.
33-
let wasm = generator.generate(&js)?;
34+
let wasm = generator.generate(&js).await?;
3435
}
3536
```

0 commit comments

Comments
 (0)