diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 7bc23b19da..bf397be499 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -17,7 +17,7 @@ bench = false [features] default = ["target-aarch64", "target-x86_64", "target-wasm32", "llvm", "editor"] -wasm32-cli-run = ["target-wasm32"] +wasm32-cli-run = ["target-wasm32", "run-wasm32"] i386-cli-run = ["target-x86"] # This is a separate feature because when we generate docs on Netlify, @@ -25,6 +25,7 @@ i386-cli-run = ["target-x86"] llvm = ["inkwell", "roc_gen_llvm", "roc_build/llvm"] editor = ["roc_editor"] +run-wasm32 = ["wasmer", "wasmer-wasi"] # Compiling for a different platform than the host can cause linker errors. target-arm = ["roc_build/target-arm"] @@ -77,8 +78,8 @@ inkwell = { path = "../vendor/inkwell", optional = true } target-lexicon = "0.12.2" tempfile = "3.1.0" -wasmer = { version = "2.0.0", default-features = false, features = ["default-singlepass", "default-universal"]} -wasmer-wasi = "2.0.0" +wasmer = { version = "2.0.0", optional = true, default-features = false, features = ["default-singlepass", "default-universal"]} +wasmer-wasi = { version = "2.0.0", optional = true} [dev-dependencies] pretty_assertions = "1.0" diff --git a/cli/src/lib.rs b/cli/src/lib.rs index cd0aa13762..3c0bf5381a 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -411,6 +411,7 @@ fn roc_run(cmd: &mut Command) -> io::Result { } } +#[cfg(feature = "run-wasm32")] fn run_with_wasmer(wasm_path: &std::path::Path, args: &[String]) { use wasmer::{Instance, Module, Store}; @@ -441,6 +442,11 @@ fn run_with_wasmer(wasm_path: &std::path::Path, args: &[String]) { } } +#[cfg(not(feature = "run-wasm32"))] +fn run_with_wasmer(_wasm_path: &std::path::Path, _args: &[String]) { + println!("Running wasm files not support"); +} + enum Backend { Host, X86_32,