diff --git a/Cargo.lock b/Cargo.lock index 2a572fe..58cbc87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1859,7 +1859,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "ostool" -version = "0.8.5" +version = "0.8.6" dependencies = [ "anyhow", "byte-unit", diff --git a/ostool/Cargo.toml b/ostool/Cargo.toml index 3a8acd6..59de964 100644 --- a/ostool/Cargo.toml +++ b/ostool/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0" name = "ostool" readme = "../README.md" repository = "https://github.com/ZR233/ostool" -version = "0.8.5" +version = "0.8.6" [[bin]] name = "ostool" diff --git a/ostool/src/bin/cargo-osrun.rs b/ostool/src/bin/cargo-osrun.rs index b21de6e..90e1879 100644 --- a/ostool/src/bin/cargo-osrun.rs +++ b/ostool/src/bin/cargo-osrun.rs @@ -42,6 +42,9 @@ struct RunnerArgs { #[arg(long)] no_run: bool, + #[arg(long)] + debug: bool, + /// Sub-commands #[command(subcommand)] command: Option, @@ -82,7 +85,11 @@ async fn main() -> anyhow::Result<()> { let args = RunnerArgs::parse(); - debug!("Parsed arguments: {:?}", args); + debug!("Parsed arguments: {:#?}", args); + + if args.no_run { + exit(0); + } if env::var("CARGO").is_err() { eprintln!("This binary may only be called via `cargo ndk-runner`."); @@ -114,7 +121,7 @@ async fn main() -> anyhow::Result<()> { app.set_elf_path(args.elf).await; app.objcopy_elf()?; - app.debug = args.no_run; + app.debug = args.debug; if args.to_bin { app.objcopy_output_bin()?; } diff --git a/ostool/src/build/cargo_builder.rs b/ostool/src/build/cargo_builder.rs index 108ca8b..1fa90ac 100644 --- a/ostool/src/build/cargo_builder.rs +++ b/ostool/src/build/cargo_builder.rs @@ -42,6 +42,10 @@ impl<'a> CargoBuilder<'a> { } } + pub fn is_run(&self) -> bool { + self.command == "run" + } + pub fn debug(self, debug: bool) -> Self { self.ctx.debug = debug; self @@ -165,6 +169,10 @@ impl<'a> CargoBuilder<'a> { cmd.arg(arg); } + if self.is_run() && self.ctx.debug { + cmd.arg("--debug"); + } + Ok(cmd) }