Skip to content

Commit 6743ca4

Browse files
committed
refactor(xtask): update command-ext for qemu
Signed-off-by: YdrMaster <ydrml@hotmail.com>
1 parent b89eb2a commit 6743ca4

File tree

3 files changed

+10
-27
lines changed

3 files changed

+10
-27
lines changed

Cargo.lock

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xtask/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ publish = false
1111
[dependencies]
1212
clap = { version = "~3.1", features = ["derive"] }
1313
lazy_static = "1.4"
14-
command-ext = { git = "https://github.com/YdrMaster/command-ext.git", rev = "a8a48c0" }
14+
command-ext = { git = "https://github.com/YdrMaster/command-ext.git", rev = "f25befb" }

xtask/src/main.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
extern crate clap;
33

44
use clap::Parser;
5-
use command_ext::{BinUtil, Cargo, CommandExt, Ext};
5+
use command_ext::{BinUtil, Cargo, CommandExt, Qemu};
66
use std::{
7-
ffi::OsString,
87
fs,
98
path::{Path, PathBuf},
109
};
@@ -168,32 +167,13 @@ struct QemuArgs {
168167
}
169168

170169
impl QemuArgs {
171-
fn find_qemu(&self) -> OsString {
172-
let name = if cfg!(target_os = "windows") {
173-
format!("qemu-system-{}.exe", self.build.arch())
174-
} else {
175-
format!("qemu-system-{}", self.build.arch())
176-
};
177-
if let Some(path) = &self.qemu_dir {
178-
let target = PathBuf::from(path).join(&name);
179-
if target.is_file() {
180-
return target.into_os_string();
181-
}
182-
}
183-
#[cfg(target_os = "windows")]
184-
{
185-
let target = PathBuf::from(r"C:\Program Files\qemu").join(&name);
186-
if target.is_file() {
187-
return target.into_os_string();
188-
}
189-
}
190-
OsString::from(name)
191-
}
192-
193170
fn run(mut self) {
194171
self.build.kernel.get_or_insert_with(|| "test".into());
195172
self.build.make();
196-
Ext::new(self.find_qemu())
173+
if let Some(p) = &self.qemu_dir {
174+
Qemu::search_at(p);
175+
}
176+
Qemu::system(self.build.arch())
197177
.args(&["-machine", "virt"])
198178
.arg("-bios")
199179
.arg(self.build.dir().join("rustsbi-qemu.bin"))

0 commit comments

Comments
 (0)