Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ wasmtime-jit = { path = "wasmtime-jit" }
wasmtime-obj = { path = "wasmtime-obj" }
wasmtime-wast = { path = "wasmtime-wast" }
wasmtime-wasi = { path = "wasmtime-wasi" }
wasmtime-wasi-c = { path = "wasmtime-wasi-c", optional = true }
wasi-common = { git = "https://github.com/CraneStation/wasi-common" }
docopt = "1.0.1"
serde = "1.0.75"
Expand All @@ -43,10 +44,8 @@ wabt = "0.7"
libc = "0.2.50"
errno = "0.2.4"

[target.'cfg(unix)'.dependencies]
wasmtime-wasi-c = { path = "wasmtime-wasi-c" }

[workspace]

[features]
lightbeam = ["wasmtime-environ/lightbeam", "wasmtime-jit/lightbeam"]
wasi-c = ["wasmtime-wasi-c"]
22 changes: 11 additions & 11 deletions src/wasmtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use wasmtime_jit::{ActionOutcome, Context};
use wasmtime_wasi::instantiate_wasi;
use wasmtime_wast::instantiate_spectest;

#[cfg(unix)]
#[cfg(feature = "wasi-c")]
use wasmtime_wasi_c::instantiate_wasi_c;

static LOG_FILENAME_PREFIX: &str = "wasmtime.dbg.";
Expand All @@ -66,16 +66,16 @@ including calling the start function if one is present. Additional functions
given with --invoke are then called.

Usage:
wasmtime [-odg] [--wasi-common] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
wasmtime [-odg] [--wasi-common] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> <file> [<arg>...]
wasmtime [-odg] [--wasi-c] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
wasmtime [-odg] [--wasi-c] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> <file> [<arg>...]
wasmtime --help | --version

Options:
--invoke=<fn> name of function to run
-o, --optimize runs optimization passes on the translated functions
-g generate debug information
-d, --debug enable debug output on stderr/stdout
--wasi-common enable the wasi-common implementation of WASI
--wasi-c enable the wasi-c implementation of WASI
--preload=<wasm> load an additional wasm module before loading the main module
--env=<env> pass an environment variable (\"key=value\") to the program
--dir=<dir> grant access to the given host directory
Expand All @@ -97,7 +97,7 @@ struct Args {
flag_env: Vec<String>,
flag_dir: Vec<String>,
flag_mapdir: Vec<String>,
flag_wasi_common: bool,
flag_wasi_c: bool,
}

fn read_to_end(path: PathBuf) -> Result<Vec<u8>, io::Error> {
Expand Down Expand Up @@ -235,17 +235,17 @@ fn main() {
let argv = compute_argv(&args.arg_file, &args.arg_arg);
let environ = compute_environ(&args.flag_env);

let wasi = if args.flag_wasi_common {
instantiate_wasi("", global_exports, &preopen_dirs, &argv, &environ)
} else {
#[cfg(unix)]
let wasi = if args.flag_wasi_c {
#[cfg(feature = "wasi-c")]
{
instantiate_wasi_c("", global_exports, &preopen_dirs, &argv, &environ)
}
#[cfg(not(unix))]
#[cfg(not(feature = "wasi-c"))]
{
unimplemented!("wasmtime-wasi-c requires a *nix")
panic!("wasi-c feature not enabled at build time")
}
} else {
instantiate_wasi("", global_exports, &preopen_dirs, &argv, &environ)
}
.expect("instantiating wasi");

Expand Down