Support passing arguments to fx run
Needed in particular for -c virtcon.disable, which will be needed
shortly when the software framebuffer API changes.
Change-Id: I71c61542ab490f4e538b1b8e33db8da9820a9ce2
diff --git a/src/device.rs b/src/device.rs
index 71e28f9..41cad81 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -228,7 +228,8 @@
}
pub fn start_emulator(
- with_graphics: bool, with_networking: bool, target_options: &TargetOptions,
+ verbose: bool, with_graphics: bool, with_networking: bool, params: &[&str],
+ target_options: &TargetOptions,
) -> Result<(), Error> {
let fuchsia_dir = fuchsia_dir(target_options)?;
let fx_script = fx_path(target_options)?;
@@ -240,10 +241,15 @@
args.push("-g");
}
- println!("fx_script = {:?}", fx_script);
+ if verbose {
+ println!("fx_script = {:?}", fx_script);
+ println!("args = {:?}", args);
+ println!("params = {:?}", params);
+ }
let child = Command::new(fx_script)
.args(&args)
+ .args(params)
.stdout(Stdio::null())
.stderr(Stdio::null())
.current_dir(&fuchsia_dir)
diff --git a/src/lib.rs b/src/lib.rs
index ab4b322..0c3406d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -485,6 +485,9 @@
static DISABLE_CROSS_ENV: &str = "disable-cross-env";
+static NO_NET: &str = "no-net";
+static FX_RUN_PARAMS: &str = "fx-run-params";
+
#[doc(hidden)]
pub fn run() -> Result<(), Error> {
let matches = App::new("fargo")
@@ -622,8 +625,12 @@
.short("g")
.help("Start a simulator with graphics enabled"),
)
- .arg(Arg::with_name("no_net"))
- .help("Don't set up networking."),
+ .arg(
+ Arg::with_name(NO_NET)
+ .long(NO_NET)
+ .help("Don't set up networking."),
+ )
+ .arg(Arg::with_name(FX_RUN_PARAMS).index(1).multiple(true)),
)
.subcommand(SubCommand::with_name("stop").about("Stop all Fuchsia emulators"))
.subcommand(
@@ -638,8 +645,12 @@
.short("g")
.help("Start a simulator with graphics enabled"),
)
- .arg(Arg::with_name("no_net"))
- .help("Don't set up networking."),
+ .arg(
+ Arg::with_name(NO_NET)
+ .long(NO_NET)
+ .help("Don't set up networking."),
+ )
+ .arg(Arg::with_name(FX_RUN_PARAMS).index(1).multiple(true)),
)
.subcommand(
SubCommand::with_name("ssh").about("Open a shell on Fuchsia device or emulator"),
@@ -823,9 +834,16 @@
);
}
+ let fx_run_params = start_matches
+ .values_of(FX_RUN_PARAMS)
+ .map(|x| x.collect())
+ .unwrap_or_else(|| vec![]);
+
return start_emulator(
+ verbose,
start_matches.is_present("graphics"),
- !start_matches.is_present("no_net"),
+ !start_matches.is_present(NO_NET),
+ &fx_run_params,
&target_options,
);
}
@@ -841,9 +859,16 @@
if let Some(restart_matches) = matches.subcommand_matches("restart") {
stop_emulator()?;
+ let fx_run_params = restart_matches
+ .values_of(FX_RUN_PARAMS)
+ .map(|x| x.collect())
+ .unwrap_or_else(|| vec![]);
+
return start_emulator(
+ verbose,
restart_matches.is_present("graphics"),
- !restart_matches.is_present("no_net"),
+ !restart_matches.is_present(NO_NET),
+ &fx_run_params,
&target_options,
);
}