Make wasmer optional for cli

This commit is contained in:
Brendan Hansknecht 2021-11-06 10:34:22 -07:00
parent 69f6ffadab
commit 0b3c95ca97
2 changed files with 10 additions and 3 deletions

View file

@ -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"

View file

@ -411,6 +411,7 @@ fn roc_run(cmd: &mut Command) -> io::Result<i32> {
}
}
#[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,