Skip to content

Commit 101eb43

Browse files
committed
Fix cargo bootimage for Windows
File names end with `.exe` on Windows.
1 parent 50af2d5 commit 101eb43

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- Fix `cargo bootimage` on Windows (there was a bug in the argument parsing)
2+
13
# 0.7.2
24

35
- New features for `bootimage runner`

src/args.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ use std::{env, mem};
66

77
pub(crate) fn parse_args() -> Result<Command, ErrorMessage> {
88
let mut args = env::args();
9-
let executable_name = args.next().ok_or("no first argument (executable name)")?;
9+
let is_cargo_bootimage = {
10+
let executable_name = args.next().ok_or("no first argument (executable name)")?;
11+
let file_stem = Path::new(&executable_name).file_stem().and_then(|s| s.to_str());
12+
file_stem == Some("cargo-bootimage")
13+
};
1014
let first = args.next();
1115
match first.as_ref().map(|s| s.as_str()) {
1216
Some("build") => parse_build_args(args),
13-
Some("bootimage") if executable_name.ends_with("cargo-bootimage") => parse_build_args(args)
17+
Some("bootimage") if is_cargo_bootimage => parse_build_args(args)
1418
.map(|cmd| match cmd {
1519
Command::BuildHelp => Command::CargoBootimageHelp,
1620
cmd => cmd,

0 commit comments

Comments
 (0)