Skip to content

Commit 62e70e7

Browse files
committed
xtask: hint if qemu not installed
1 parent 18a8a20 commit 62e70e7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

xtask/src/main.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ extern crate clap;
44
use clap::Parser;
55
use os_xtask_utils::{BinUtil, Cargo, CommandExt, Qemu};
66
use std::{
7-
fs,
7+
fs, io,
88
path::{Path, PathBuf},
9+
process,
910
};
1011

1112
#[derive(Parser)]
@@ -176,7 +177,7 @@ impl QemuArgs {
176177
if let Some(p) = &self.qemu_dir {
177178
Qemu::search_at(p);
178179
}
179-
Qemu::system(self.build.arch())
180+
let status = Qemu::system(self.build.arch())
180181
.args(["-machine", "virt"])
181182
.arg("-bios")
182183
.arg(self.build.dir().join("rustsbi-qemu.bin"))
@@ -188,7 +189,17 @@ impl QemuArgs {
188189
.optional(&self.gdb, |qemu, gdb| {
189190
qemu.args(["-S", "-gdb", &format!("tcp::{gdb}")]);
190191
})
191-
.invoke();
192+
.as_mut()
193+
.status();
194+
if let Err(e) = status {
195+
if e.kind() == io::ErrorKind::NotFound {
196+
println!("xtask: QEMU command not found. Does your system have QEMU installed and environment variable configured?");
197+
println!("xtask: error: {}", e);
198+
} else {
199+
println!("xtask: error: {}", e);
200+
}
201+
process::exit(1);
202+
}
192203
}
193204
}
194205

0 commit comments

Comments
 (0)