@@ -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");
@@ -26,7 +26,7 @@ pub async fn new_json(executor: Arc<Background>) -> Result<PluginLspAdapter> {
.map(|output| output.stdout)
})?
.init(PluginBinary::Precompiled(include_bytes!(
- "../../../../plugins/bin/json_language.wasm.pre"
+ "../../../../plugins/bin/json_language.wasm.epoch.pre"
)))
.await?;