Skip to content

Commit 5cef254

Browse files
ci: let cargo fmt --all --check OK
1 parent 891c350 commit 5cef254

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

xtask/src/main.rs

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
use std::{
2+
path::{Path, PathBuf},
3+
process::{self, Command},
4+
};
5+
16
use clap::{Parser, Subcommand};
2-
use std::path::{Path, PathBuf};
3-
use std::process::{self, Command};
47

58
/// StarryOS multi-architecture build & test tool
69
#[derive(Parser)]
@@ -50,9 +53,9 @@ enum Cmd {
5053
/// Map a short architecture name to its Rust bare-metal target triple.
5154
fn arch_target(arch: &str) -> &'static str {
5255
match arch {
53-
"riscv64" => "riscv64gc-unknown-none-elf",
54-
"aarch64" => "aarch64-unknown-none-softfloat",
55-
"x86_64" => "x86_64-unknown-none",
56+
"riscv64" => "riscv64gc-unknown-none-elf",
57+
"aarch64" => "aarch64-unknown-none-softfloat",
58+
"x86_64" => "x86_64-unknown-none",
5659
"loongarch64" => "loongarch64-unknown-none",
5760
_ => unreachable!("validate_arch should have caught this"),
5861
}
@@ -75,19 +78,16 @@ fn project_root() -> PathBuf {
7578
/// Build a `make` Command pre-loaded with common arguments.
7679
fn make_cmd(root: &Path, arch: &str) -> Command {
7780
let mut cmd = Command::new("make");
78-
cmd.current_dir(root)
79-
.arg(format!("ARCH={arch}"));
81+
cmd.current_dir(root).arg(format!("ARCH={arch}"));
8082
cmd
8183
}
8284

8385
/// Execute a Command and exit with its exit code on failure.
8486
fn run(mut cmd: Command) {
85-
let status = cmd
86-
.status()
87-
.unwrap_or_else(|e| {
88-
eprintln!("xtask: failed to spawn process: {e}");
89-
process::exit(1);
90-
});
87+
let status = cmd.status().unwrap_or_else(|e| {
88+
eprintln!("xtask: failed to spawn process: {e}");
89+
process::exit(1);
90+
});
9191
if !status.success() {
9292
process::exit(status.code().unwrap_or(1));
9393
}
@@ -113,7 +113,10 @@ fn do_run(root: &Path, arch: &str) {
113113
if is_wsl() {
114114
cmd.arg("ACCEL=n");
115115
}
116-
println!("==> make ARCH={arch} run{}", if is_wsl() { " ACCEL=n" } else { "" });
116+
println!(
117+
"==> make ARCH={arch} run{}",
118+
if is_wsl() { " ACCEL=n" } else { "" }
119+
);
117120
run(cmd);
118121
}
119122

@@ -133,8 +136,10 @@ fn do_publish(root: &Path, arch: &str) {
133136
"publish",
134137
"--dry-run",
135138
"--allow-dirty",
136-
"--target", target,
137-
"--features", "qemu",
139+
"--target",
140+
target,
141+
"--features",
142+
"qemu",
138143
])
139144
.status()
140145
.unwrap_or_else(|e| {
@@ -154,9 +159,7 @@ fn do_test(root: &Path, arch: &str) {
154159
}
155160
println!("==> python3 scripts/ci-test.py {arch}");
156161
let mut cmd = Command::new("python3");
157-
cmd.current_dir(root)
158-
.arg(&script)
159-
.arg(arch);
162+
cmd.current_dir(root).arg(&script).arg(arch);
160163
run(cmd);
161164
}
162165

@@ -173,11 +176,11 @@ fn main() {
173176
});
174177

175178
match &cli.command {
176-
Cmd::Rootfs { arch } => do_rootfs(&root, arch),
177-
Cmd::Build { arch } => do_build(&root, arch),
178-
Cmd::Run { arch } => do_run(&root, arch),
179-
Cmd::Test { arch } => do_test(&root, arch),
180-
Cmd::Publish { arch } => do_publish(&root, arch),
179+
Cmd::Rootfs { arch } => do_rootfs(&root, arch),
180+
Cmd::Build { arch } => do_build(&root, arch),
181+
Cmd::Run { arch } => do_run(&root, arch),
182+
Cmd::Test { arch } => do_test(&root, arch),
183+
Cmd::Publish { arch } => do_publish(&root, arch),
181184
}
182185
}
183186

0 commit comments

Comments
 (0)