mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 01:43:22 +00:00
39 lines
1.2 KiB
Rust
39 lines
1.2 KiB
Rust
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
use std::process;
|
|
|
|
use crate::error_msg;
|
|
use crate::utils::get_cargo_metadata;
|
|
use crate::{commands::utils::create_target_json, error::Errno};
|
|
|
|
use super::utils::{cargo, COMMON_CARGO_ARGS};
|
|
|
|
pub fn execute_clippy_command() {
|
|
let target_json_path = {
|
|
let metadata = get_cargo_metadata(None::<&str>, None::<&[&str]>);
|
|
let target_directory = metadata.get("target_directory").unwrap().as_str().unwrap();
|
|
create_target_json(target_directory)
|
|
};
|
|
|
|
let mut command = cargo();
|
|
command.arg("clippy").arg("-h");
|
|
info!("[Running] cargo clippy -h");
|
|
let output = command.output().unwrap();
|
|
if !output.status.success() {
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
eprintln!("{}", &stderr);
|
|
error_msg!("Cargo clippy failed");
|
|
process::exit(Errno::ExecuteCommand as _);
|
|
}
|
|
|
|
let mut command = cargo();
|
|
command.arg("clippy").arg("--target").arg(target_json_path);
|
|
command.args(COMMON_CARGO_ARGS);
|
|
command.args(["--", "-D", "warnings"]);
|
|
let status = command.status().unwrap();
|
|
if !status.success() {
|
|
error_msg!("Cargo clippy failed");
|
|
process::exit(Errno::ExecuteCommand as _);
|
|
}
|
|
}
|