Browse Source

Plumb through 3dslink args for run + test commands

pull/26/head
Ian Chamberlain 2 years ago
parent
commit
dd8ae47296
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 43
      src/command.rs
  2. 11
      src/lib.rs
  3. 4
      src/main.rs

43
src/command.rs

@ -186,6 +186,49 @@ impl RemainingArgs {
} }
} }
impl Run {
/// Get the args to pass to `3dslink` based on these options.
pub fn get_3dslink_args(&self) -> Vec<String> {
let mut args = Vec::new();
if let Some(address) = self.address {
args.extend(["--address".to_string(), address.to_string()]);
}
if let Some(argv0) = &self.argv0 {
args.extend(["--arg0".to_string(), argv0.clone()]);
}
if let Some(retries) = self.retries {
args.extend(["--retries".to_string(), retries.to_string()]);
}
if self.server {
args.push("--server".to_string());
}
let exe_args = self.cargo_args.exe_args();
if !exe_args.is_empty() {
// For some reason 3dslink seems to want 2 instances of `--`, one
// in front of all of the args like this...
args.extend(["--args".to_string(), "--".to_string()]);
let mut escaped = false;
for arg in exe_args.iter().cloned() {
if arg.starts_with('-') && !escaped {
// And one before the first `-` arg that is passed in.
args.extend(["--".to_string(), arg]);
escaped = true;
} else {
args.push(arg);
}
}
}
args
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

11
src/lib.rs

@ -97,7 +97,7 @@ pub fn make_cargo_build_command(cmd: &CargoCmd, message_format: &Option<String>)
.stdin(Stdio::inherit()) .stdin(Stdio::inherit())
.stderr(Stdio::inherit()); .stderr(Stdio::inherit());
dbg!(command) command
} }
/// Finds the sysroot path of the current toolchain /// Finds the sysroot path of the current toolchain
@ -285,9 +285,16 @@ pub fn build_3dsx(config: &CTRConfig) {
/// Link the generated 3dsx to a 3ds to execute and test using `3dslink`. /// Link the generated 3dsx to a 3ds to execute and test using `3dslink`.
/// This will fail if `3dslink` is not within the running directory or in a directory found in $PATH /// This will fail if `3dslink` is not within the running directory or in a directory found in $PATH
pub fn link(config: &CTRConfig) { pub fn link(config: &CTRConfig, cmd: &CargoCmd) {
let run_args = match cmd {
CargoCmd::Run(run) => run,
CargoCmd::Test(test) => &test.run_args,
_ => unreachable!(),
};
let mut process = Command::new("3dslink") let mut process = Command::new("3dslink")
.arg(config.path_3dsx()) .arg(config.path_3dsx())
.args(run_args.get_3dslink_args())
.stdin(Stdio::inherit()) .stdin(Stdio::inherit())
.stdout(Stdio::inherit()) .stdout(Stdio::inherit())
.stderr(Stdio::inherit()) .stderr(Stdio::inherit())

4
src/main.rs

@ -38,9 +38,7 @@ fn main() {
build_3dsx(&app_conf); build_3dsx(&app_conf);
if input.cmd.should_link_to_device() { if input.cmd.should_link_to_device() {
// TODO plumb in exe_args and various 3dslink args
eprintln!("Running 3dslink"); eprintln!("Running 3dslink");
link(&app_conf); link(&app_conf, &input.cmd);
} }
} }

Loading…
Cancel
Save