Make OSDK wrapped commands unified and fix make docs

This commit is contained in:
Zhang Junyang
2024-03-06 17:05:54 +08:00
committed by Tate, Hongliang Tian
parent 132d36bf20
commit 160cb9cdb5
5 changed files with 45 additions and 75 deletions

View File

@ -1,20 +0,0 @@
// SPDX-License-Identifier: MPL-2.0
use std::process;
use super::util::{cargo, COMMON_CARGO_ARGS};
use crate::{error::Errno, error_msg};
pub fn execute_check_command() {
let mut command = cargo();
command
.arg("check")
.arg("--target")
.arg("x86_64-unknown-none");
command.args(COMMON_CARGO_ARGS);
let status = command.status().unwrap();
if !status.success() {
error_msg!("Check failed");
process::exit(Errno::ExecuteCommand as _);
}
}

View File

@ -1,38 +0,0 @@
// SPDX-License-Identifier: MPL-2.0
use std::process;
use super::util::{cargo, COMMON_CARGO_ARGS};
use crate::{error::Errno, error_msg};
pub fn execute_clippy_command() {
let mut command = cargo();
command
.arg("clippy")
.arg("-h")
.arg("--target")
.arg("x86_64-unknown-none")
.args(COMMON_CARGO_ARGS);
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("x86_64-unknown-none")
.args(COMMON_CARGO_ARGS);
// TODO: Add support for custom clippy args using OSDK commandline rather than hardcode it.
command.args(["--", "-D", "warnings"]);
let status = command.status().unwrap();
if !status.success() {
error_msg!("Cargo clippy failed");
process::exit(Errno::ExecuteCommand as _);
}
}

View File

@ -3,14 +3,25 @@
//! This module contains subcommands of cargo-osdk.
mod build;
mod check;
mod clippy;
mod new;
mod run;
mod test;
mod util;
pub use self::{
build::execute_build_command, check::execute_check_command, clippy::execute_clippy_command,
new::execute_new_command, run::execute_run_command, test::execute_test_command,
build::execute_build_command, new::execute_new_command, run::execute_run_command,
test::execute_test_command,
};
/// Execute the forwarded cargo command with args containing the subcommand and its arguments.
pub fn execute_forwarded_command(subcommand: &str, args: &Vec<String>) -> ! {
let mut cargo = util::cargo();
cargo
.arg(subcommand)
.args(util::COMMON_CARGO_ARGS)
.arg("--target")
.arg("x86_64-unknown-none")
.args(args);
let status = cargo.status().expect("Failed to execute cargo");
std::process::exit(status.code().unwrap_or(1));
}