Skip to content

Commit b3cf7f9

Browse files
authored
clif-util: Make the -t flag work with the wasm subcommand (bytecodealliance#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.
1 parent 10be3e4 commit b3cf7f9

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

cranelift/src/clif-util.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ fn add_enable_multi_value<'a>() -> clap::Arg<'a, 'a> {
119119
.help("Enable WASM's multi-value support")
120120
}
121121

122+
fn add_just_decode_flag<'a>() -> clap::Arg<'a, 'a> {
123+
Arg::with_name("just-decode")
124+
.short("t")
125+
.help("Just decode into Cranelift IR")
126+
}
127+
128+
fn add_check_translation_flag<'a>() -> clap::Arg<'a, 'a> {
129+
Arg::with_name("check-translation")
130+
.short("c")
131+
.help("Just checks the correctness of Cranelift IR translated from WebAssembly")
132+
}
133+
122134
/// Returns a vector of clap value options and changes these options into a vector of strings
123135
fn get_vec(argument_vec: Option<clap::Values>) -> Vec<String> {
124136
let mut ret_vec: Vec<String> = Vec::new();
@@ -151,6 +163,8 @@ fn add_wasm_or_compile<'a>(cmd: &str) -> clap::App<'a, 'a> {
151163
.arg(add_debug_flag())
152164
.arg(add_enable_simd_flag())
153165
.arg(add_enable_multi_value())
166+
.arg(add_just_decode_flag())
167+
.arg(add_check_translation_flag())
154168
}
155169

156170
fn handle_debug_flag(debug: bool) {
@@ -191,17 +205,7 @@ fn main() {
191205
.arg(add_input_file_arg())
192206
.arg(add_debug_flag()),
193207
)
194-
.subcommand(
195-
add_wasm_or_compile("compile")
196-
.arg(
197-
Arg::with_name("just-decode")
198-
.short("t")
199-
.help("Just decode WebAssembly to Cranelift IR"),
200-
)
201-
.arg(Arg::with_name("check-translation").short("c").help(
202-
"Just checks the correctness of Cranelift IR translated from WebAssembly",
203-
)),
204-
)
208+
.subcommand(add_wasm_or_compile("compile"))
205209
.subcommand(
206210
add_wasm_or_compile("wasm").arg(
207211
Arg::with_name("value-ranges")

0 commit comments

Comments
 (0)