Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ostool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 9 additions & 2 deletions ostool/src/bin/cargo-osrun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ struct RunnerArgs {
#[arg(long)]
no_run: bool,

#[arg(long)]
debug: bool,

/// Sub-commands
#[command(subcommand)]
command: Option<SubCommands>,
Expand Down Expand Up @@ -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`.");
Expand Down Expand Up @@ -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()?;
}
Expand Down
8 changes: 8 additions & 0 deletions ostool/src/build/cargo_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -165,6 +169,10 @@ impl<'a> CargoBuilder<'a> {
cmd.arg(arg);
}

if self.is_run() && self.ctx.debug {
cmd.arg("--debug");
}

Comment on lines +172 to +175
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --debug flag is not a valid cargo command-line option. Cargo builds in debug mode by default and only accepts --release to build in release mode. The logic at lines 163-165 already handles this correctly by only adding --release when debug mode is disabled. Adding --debug here will cause cargo to fail with an "unrecognized option" error.

Suggested change
if self.is_run() && self.ctx.debug {
cmd.arg("--debug");
}

Copilot uses AI. Check for mistakes.
Ok(cmd)
}

Expand Down