Replace WebAssembly feature CLI options with --wasm-features.
This commit hides the existing WebAssembly feature CLI options (e.g. `--enable-simd`) and adds a `--wasm-features` flag that enables multiple (or all) WebAssembly features. Features can be disabled by prefixing the value with `-`, e.g. `--wasm-features=-simd`.
This commit is contained in:
@@ -12,6 +12,31 @@ use structopt::{
|
||||
use target_lexicon::Triple;
|
||||
use wasmtime::{Config, Engine, Module};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref AFTER_HELP: String = {
|
||||
format!(
|
||||
"By default, no CPU features or presets will be enabled for the compilation.\n\
|
||||
\n\
|
||||
{}\
|
||||
\n\
|
||||
Usage examples:\n\
|
||||
\n\
|
||||
Compiling a WebAssembly module for the current platform:\n\
|
||||
\n \
|
||||
wasmtime compile example.wasm
|
||||
\n\
|
||||
Specifying the output file:\n\
|
||||
\n \
|
||||
wasmtime compile -o output.cwasm input.wasm\n\
|
||||
\n\
|
||||
Compiling for a specific platform (Linux) and CPU preset (Skylake):\n\
|
||||
\n \
|
||||
wasmtime compile --target x86_64-unknown-linux --skylake foo.wasm\n",
|
||||
crate::WASM_FEATURES.as_str()
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
/// Compiles a WebAssembly module.
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(
|
||||
@@ -22,23 +47,7 @@ use wasmtime::{Config, Engine, Module};
|
||||
group = ArgGroup::with_name("preset-x64"),
|
||||
group = ArgGroup::with_name("aarch64").multiple(true).conflicts_with_all(&["x64", "preset-x64"]),
|
||||
group = ArgGroup::with_name("preset-aarch64").conflicts_with_all(&["x64", "preset-x64"]),
|
||||
after_help = "By default, no CPU flags will be enabled for the compilation.\n\
|
||||
\n\
|
||||
Use the various preset and CPU flag options for the environment being targeted.\n\
|
||||
\n\
|
||||
Usage examples:\n\
|
||||
\n\
|
||||
Compiling a WebAssembly module for the current platform:\n\
|
||||
\n \
|
||||
wasmtime compile example.wasm
|
||||
\n\
|
||||
Specifying the output file:\n\
|
||||
\n \
|
||||
wasmtime compile -o output.cwasm input.wasm\n\
|
||||
\n\
|
||||
Compiling for a specific platform (Linux) and CPU preset (Skylake):\n\
|
||||
\n \
|
||||
wasmtime compile --target x86_64-unknown-linux --skylake foo.wasm\n"
|
||||
after_help = AFTER_HELP.as_str()
|
||||
)]
|
||||
pub struct CompileCommand {
|
||||
#[structopt(flatten)]
|
||||
|
||||
@@ -68,9 +68,15 @@ fn parse_preloads(s: &str) -> Result<(String, PathBuf)> {
|
||||
Ok((parts[0].into(), parts[1].into()))
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref AFTER_HELP: String = {
|
||||
crate::WASM_FEATURES.to_string()
|
||||
};
|
||||
}
|
||||
|
||||
/// Runs a WebAssembly module
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(name = "run", setting = AppSettings::TrailingVarArg)]
|
||||
#[structopt(name = "run", setting = AppSettings::TrailingVarArg, after_help = AFTER_HELP.as_str())]
|
||||
pub struct RunCommand {
|
||||
#[structopt(flatten)]
|
||||
common: CommonOptions,
|
||||
|
||||
@@ -11,9 +11,17 @@ use std::{
|
||||
use structopt::{clap::AppSettings, StructOpt};
|
||||
use target_lexicon::Triple;
|
||||
|
||||
/// The after help text for the `wasm2obj` command.
|
||||
pub const WASM2OBJ_AFTER_HELP: &str = "The translation is dependent on the environment chosen.\n\
|
||||
The default is a dummy environment that produces placeholder values.";
|
||||
lazy_static::lazy_static! {
|
||||
static ref AFTER_HELP: String = {
|
||||
format!(
|
||||
"The translation is dependent on the environment chosen.\n\
|
||||
The default is a dummy environment that produces placeholder values.\n\
|
||||
\n\
|
||||
{}",
|
||||
crate::WASM_FEATURES.as_str()
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
/// Translates a WebAssembly module to native object file
|
||||
#[derive(StructOpt)]
|
||||
@@ -21,7 +29,7 @@ pub const WASM2OBJ_AFTER_HELP: &str = "The translation is dependent on the envir
|
||||
name = "wasm2obj",
|
||||
version = env!("CARGO_PKG_VERSION"),
|
||||
setting = AppSettings::ColoredHelp,
|
||||
after_help = WASM2OBJ_AFTER_HELP,
|
||||
after_help = AFTER_HELP.as_str(),
|
||||
)]
|
||||
pub struct WasmToObjCommand {
|
||||
#[structopt(flatten)]
|
||||
|
||||
@@ -7,12 +7,19 @@ use structopt::{clap::AppSettings, StructOpt};
|
||||
use wasmtime::{Engine, Store};
|
||||
use wasmtime_wast::WastContext;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref AFTER_HELP: String = {
|
||||
crate::WASM_FEATURES.to_string()
|
||||
};
|
||||
}
|
||||
|
||||
/// Runs a WebAssembly test script file
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(
|
||||
name = "wast",
|
||||
version = env!("CARGO_PKG_VERSION"),
|
||||
setting = AppSettings::ColoredHelp,
|
||||
after_help = AFTER_HELP.as_str(),
|
||||
)]
|
||||
pub struct WastCommand {
|
||||
#[structopt(flatten)]
|
||||
|
||||
Reference in New Issue
Block a user