commit
d7c8e0fb43
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -103,10 +103,7 @@ jobs:
|
|||||||
./y.sh test --release --clean --build-sysroot ${{ matrix.commands }}
|
./y.sh test --release --clean --build-sysroot ${{ matrix.commands }}
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: |
|
run: ./y.sh fmt --check
|
||||||
cargo fmt -- --check
|
|
||||||
cd build_system
|
|
||||||
cargo fmt -- --check
|
|
||||||
|
|
||||||
- name: clippy
|
- name: clippy
|
||||||
run: |
|
run: |
|
||||||
|
35
build_system/src/fmt.rs
Normal file
35
build_system/src/fmt.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use crate::utils::run_command_with_output;
|
||||||
|
use std::ffi::OsStr;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
fn show_usage() {
|
||||||
|
println!(
|
||||||
|
r#"
|
||||||
|
`fmt` command help:
|
||||||
|
|
||||||
|
--check : Pass `--check` argument to `cargo fmt` commands
|
||||||
|
--help : Show this help"#
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run() -> Result<(), String> {
|
||||||
|
let mut check = false;
|
||||||
|
// We skip binary name and the `info` command.
|
||||||
|
let mut args = std::env::args().skip(2);
|
||||||
|
while let Some(arg) = args.next() {
|
||||||
|
match arg.as_str() {
|
||||||
|
"--help" => {
|
||||||
|
show_usage();
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
"--check" => check = true,
|
||||||
|
_ => return Err(format!("Unknown option {}", arg)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let cmd: &[&dyn AsRef<OsStr>] =
|
||||||
|
if check { &[&"cargo", &"fmt", &"--check"] } else { &[&"cargo", &"fmt"] };
|
||||||
|
|
||||||
|
run_command_with_output(cmd, Some(&Path::new(".")))?;
|
||||||
|
run_command_with_output(cmd, Some(&Path::new("build_system")))
|
||||||
|
}
|
@ -5,6 +5,7 @@
|
|||||||
mod clean;
|
mod clean;
|
||||||
mod clone_gcc;
|
mod clone_gcc;
|
||||||
mod config;
|
mod config;
|
||||||
|
mod fmt;
|
||||||
mod info;
|
mod info;
|
||||||
mod prepare;
|
mod prepare;
|
||||||
mod rust_tools;
|
mod rust_tools;
|
||||||
@ -41,7 +42,8 @@ fn usage() {
|
|||||||
build : Compiles the project.
|
build : Compiles the project.
|
||||||
test : Runs tests for the project.
|
test : Runs tests for the project.
|
||||||
info : Displays information about the build environment and project configuration.
|
info : Displays information about the build environment and project configuration.
|
||||||
clone-gcc : Clones the GCC compiler from a specified source."
|
clone-gcc : Clones the GCC compiler from a specified source.
|
||||||
|
fmt : Runs rustfmt"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +56,7 @@ pub enum Command {
|
|||||||
Rustc,
|
Rustc,
|
||||||
Test,
|
Test,
|
||||||
Info,
|
Info,
|
||||||
|
Fmt,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -70,6 +73,7 @@ fn main() {
|
|||||||
Some("test") => Command::Test,
|
Some("test") => Command::Test,
|
||||||
Some("info") => Command::Info,
|
Some("info") => Command::Info,
|
||||||
Some("clone-gcc") => Command::CloneGcc,
|
Some("clone-gcc") => Command::CloneGcc,
|
||||||
|
Some("fmt") => Command::Fmt,
|
||||||
Some("--help") => {
|
Some("--help") => {
|
||||||
usage();
|
usage();
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
@ -91,6 +95,7 @@ fn main() {
|
|||||||
Command::Test => test::run(),
|
Command::Test => test::run(),
|
||||||
Command::Info => info::run(),
|
Command::Info => info::run(),
|
||||||
Command::CloneGcc => clone_gcc::run(),
|
Command::CloneGcc => clone_gcc::run(),
|
||||||
|
Command::Fmt => fmt::run(),
|
||||||
} {
|
} {
|
||||||
eprintln!("Command failed to run: {e}");
|
eprintln!("Command failed to run: {e}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user