diff --git a/crates/plugin_runtime/build.rs b/crates/plugin_runtime/build.rs index d1b1b58411..b323bdc34e 100644 --- a/crates/plugin_runtime/build.rs +++ b/crates/plugin_runtime/build.rs @@ -43,7 +43,8 @@ fn main() { assert!(build_successful); // Find all compiled binaries - let engine = create_default_engine(); + let epoch_engine = create_epoch_engine(); + let fuel_engine = create_fuel_engine(); let binaries = std::fs::read_dir(base.join("target/wasm32-wasi").join(profile_target)) .expect("Could not find compiled plugins in target"); @@ -61,26 +62,35 @@ fn main() { if let Some(path) = is_wasm() { let out_path = base.join("bin").join(path.file_name().unwrap()); std::fs::copy(&path, &out_path).expect("Could not copy compiled plugin to bin"); - precompile(&out_path, &engine); + precompile(&out_path, &epoch_engine, "epoch"); + precompile(&out_path, &fuel_engine, "fuel"); } } } -/// Creates a default engine for compiling Wasm. -fn create_default_engine() -> Engine { +fn create_epoch_engine() -> Engine { let mut config = Config::default(); config.async_support(true); + config.epoch_interruption(true); Engine::new(&config).expect("Could not create engine") } -fn precompile(path: &Path, engine: &Engine) { +fn create_fuel_engine() -> Engine { + let mut config = Config::default(); + config.async_support(true); + config.consume_fuel(true); + Engine::new(&config).expect("Could not create engine") +} + +fn precompile(path: &Path, engine: &Engine, engine_name: &str) { let bytes = std::fs::read(path).expect("Could not read wasm module"); let compiled = engine .precompile_module(&bytes) .expect("Could not precompile module"); let out_path = path.parent().unwrap().join(&format!( - "{}.pre", - path.file_name().unwrap().to_string_lossy() + "{}.{}.pre", + path.file_name().unwrap().to_string_lossy(), + engine_name, )); let mut out_file = std::fs::File::create(out_path) .expect("Could not create output file for precompiled module"); diff --git a/crates/zed/src/languages/language_plugin.rs b/crates/zed/src/languages/language_plugin.rs index 6f4bdab78e..690e6d385c 100644 --- a/crates/zed/src/languages/language_plugin.rs +++ b/crates/zed/src/languages/language_plugin.rs @@ -26,7 +26,7 @@ pub async fn new_json(executor: Arc) -> Result { .map(|output| output.stdout) })? .init(PluginBinary::Precompiled(include_bytes!( - "../../../../plugins/bin/json_language.wasm.pre" + "../../../../plugins/bin/json_language.wasm.epoch.pre" ))) .await?;