summaryrefslogtreecommitdiff
path: root/crates/cli/bin.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/cli/bin.rs')
-rw-r--r--crates/cli/bin.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/cli/bin.rs b/crates/cli/bin.rs
index a067ca8..f8b0e1e 100644
--- a/crates/cli/bin.rs
+++ b/crates/cli/bin.rs
@@ -5,6 +5,8 @@ use color_eyre::eyre::Result;
use log::info;
use tinywasm::{self, Module, WasmValue};
mod util;
+
+#[cfg(feature = "wat")]
mod wat;
#[derive(FromArgs)]
@@ -75,11 +77,18 @@ fn main() -> Result<()> {
TinyWasmSubcommand::Run(Run { wasm_file, engine }) => {
let path = cwd.join(wasm_file.clone());
let module = match wasm_file.ends_with(".wat") {
+ #[cfg(feature = "wat")]
true => {
let wat = std::fs::read_to_string(path)?;
let wasm = wat::wat2wasm(&wat);
tinywasm::Module::parse_bytes(&wasm)?
}
+ #[cfg(not(feature = "wat"))]
+ true => {
+ return Err(color_eyre::eyre::eyre!(
+ "wat support is not enabled, please enable it with --features wat"
+ ))
+ }
false => tinywasm::Module::parse_file(path)?,
};