clif-util: Make the -t flag work with the wasm subcommand (#1105)

* clif-util: Make the `-t` flag work with the `wasm` subcommand

The presence of the flag was checked in the code, so it was essentially already
supported, but it was not properly configured when constructing
the CLI arguments parser.

* clif-util: also enable the `-c` flag for the `wasm` subcommand

Similar to the parent commit, this functionality is already supported, just a
mix up of the CLI parser construction made it not show up.
This commit is contained in:
Nick Fitzgerald
2019-10-02 15:41:43 -07:00
committed by GitHub
parent 10be3e4ba8
commit b3cf7f911b

View File

@@ -119,6 +119,18 @@ fn add_enable_multi_value<'a>() -> clap::Arg<'a, 'a> {
.help("Enable WASM's multi-value support") .help("Enable WASM's multi-value support")
} }
fn add_just_decode_flag<'a>() -> clap::Arg<'a, 'a> {
Arg::with_name("just-decode")
.short("t")
.help("Just decode into Cranelift IR")
}
fn add_check_translation_flag<'a>() -> clap::Arg<'a, 'a> {
Arg::with_name("check-translation")
.short("c")
.help("Just checks the correctness of Cranelift IR translated from WebAssembly")
}
/// Returns a vector of clap value options and changes these options into a vector of strings /// Returns a vector of clap value options and changes these options into a vector of strings
fn get_vec(argument_vec: Option<clap::Values>) -> Vec<String> { fn get_vec(argument_vec: Option<clap::Values>) -> Vec<String> {
let mut ret_vec: Vec<String> = Vec::new(); let mut ret_vec: Vec<String> = Vec::new();
@@ -151,6 +163,8 @@ fn add_wasm_or_compile<'a>(cmd: &str) -> clap::App<'a, 'a> {
.arg(add_debug_flag()) .arg(add_debug_flag())
.arg(add_enable_simd_flag()) .arg(add_enable_simd_flag())
.arg(add_enable_multi_value()) .arg(add_enable_multi_value())
.arg(add_just_decode_flag())
.arg(add_check_translation_flag())
} }
fn handle_debug_flag(debug: bool) { fn handle_debug_flag(debug: bool) {
@@ -191,17 +205,7 @@ fn main() {
.arg(add_input_file_arg()) .arg(add_input_file_arg())
.arg(add_debug_flag()), .arg(add_debug_flag()),
) )
.subcommand( .subcommand(add_wasm_or_compile("compile"))
add_wasm_or_compile("compile")
.arg(
Arg::with_name("just-decode")
.short("t")
.help("Just decode WebAssembly to Cranelift IR"),
)
.arg(Arg::with_name("check-translation").short("c").help(
"Just checks the correctness of Cranelift IR translated from WebAssembly",
)),
)
.subcommand( .subcommand(
add_wasm_or_compile("wasm").arg( add_wasm_or_compile("wasm").arg(
Arg::with_name("value-ranges") Arg::with_name("value-ranges")