mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-20 04:56:32 +00:00
Make OSDK wrapped commands unified and fix make docs
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
132d36bf20
commit
160cb9cdb5
14
Makefile
14
Makefile
@ -144,10 +144,14 @@ ktest: initramfs $(CARGO_OSDK)
|
|||||||
(cd $$dir && cargo osdk test) || exit 1; \
|
(cd $$dir && cargo osdk test) || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
||||||
.PHONY: docs
|
docs: $(CARGO_OSDK)
|
||||||
docs:
|
@for dir in $(NON_OSDK_CRATES); do \
|
||||||
@cargo doc # Build Rust docs
|
(cd $$dir && cargo doc --no-deps) || exit 1; \
|
||||||
@echo "" # Add a blank line
|
done
|
||||||
|
@for dir in $(OSDK_CRATES); do \
|
||||||
|
(cd $$dir && cargo osdk doc --no-deps) || exit 1; \
|
||||||
|
done
|
||||||
|
@echo "" # Add a blank line
|
||||||
@cd docs && mdbook build # Build mdBook
|
@cd docs && mdbook build # Build mdBook
|
||||||
|
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
@ -169,7 +173,7 @@ check: $(CARGO_OSDK)
|
|||||||
(cd $$dir && cargo clippy -- -D warnings) || exit 1; \
|
(cd $$dir && cargo clippy -- -D warnings) || exit 1; \
|
||||||
done
|
done
|
||||||
@for dir in $(OSDK_CRATES); do \
|
@for dir in $(OSDK_CRATES); do \
|
||||||
(cd $$dir && cargo osdk clippy) || exit 1; \
|
(cd $$dir && cargo osdk clippy -- -- -D warnings) || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
@ -6,8 +6,8 @@ use clap::{crate_version, Args, Parser};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
execute_build_command, execute_check_command, execute_clippy_command, execute_new_command,
|
execute_build_command, execute_forwarded_command, execute_new_command, execute_run_command,
|
||||||
execute_run_command, execute_test_command,
|
execute_test_command,
|
||||||
},
|
},
|
||||||
config_manager::{
|
config_manager::{
|
||||||
boot::{BootLoader, BootProtocol},
|
boot::{BootLoader, BootProtocol},
|
||||||
@ -37,8 +37,9 @@ pub fn main() {
|
|||||||
let test_config = TestConfig::parse(test_args);
|
let test_config = TestConfig::parse(test_args);
|
||||||
execute_test_command(&test_config);
|
execute_test_command(&test_config);
|
||||||
}
|
}
|
||||||
OsdkSubcommand::Check => execute_check_command(),
|
OsdkSubcommand::Check(args) => execute_forwarded_command("check", &args.args),
|
||||||
OsdkSubcommand::Clippy => execute_clippy_command(),
|
OsdkSubcommand::Clippy(args) => execute_forwarded_command("clippy", &args.args),
|
||||||
|
OsdkSubcommand::Doc(args) => execute_forwarded_command("doc", &args.args),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +69,22 @@ pub enum OsdkSubcommand {
|
|||||||
Run(RunArgs),
|
Run(RunArgs),
|
||||||
#[command(about = "Execute kernel mode unit test by starting a VMM")]
|
#[command(about = "Execute kernel mode unit test by starting a VMM")]
|
||||||
Test(TestArgs),
|
Test(TestArgs),
|
||||||
#[command(about = "Analyze the current package and report errors")]
|
#[command(about = "Check a local package and all of its dependencies for errors")]
|
||||||
Check,
|
Check(ForwardedArguments),
|
||||||
#[command(about = "Check the current package and catch common mistakes")]
|
#[command(about = "Checks a package to catch common mistakes and improve your Rust code")]
|
||||||
Clippy,
|
Clippy(ForwardedArguments),
|
||||||
|
#[command(about = "Build a package's documentation")]
|
||||||
|
Doc(ForwardedArguments),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
pub struct ForwardedArguments {
|
||||||
|
#[arg(
|
||||||
|
help = "The full set of Cargo arguments",
|
||||||
|
trailing_var_arg = true,
|
||||||
|
allow_hyphen_values = true
|
||||||
|
)]
|
||||||
|
pub args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
@ -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 _);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 _);
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,14 +3,25 @@
|
|||||||
//! This module contains subcommands of cargo-osdk.
|
//! This module contains subcommands of cargo-osdk.
|
||||||
|
|
||||||
mod build;
|
mod build;
|
||||||
mod check;
|
|
||||||
mod clippy;
|
|
||||||
mod new;
|
mod new;
|
||||||
mod run;
|
mod run;
|
||||||
mod test;
|
mod test;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
build::execute_build_command, check::execute_check_command, clippy::execute_clippy_command,
|
build::execute_build_command, new::execute_new_command, run::execute_run_command,
|
||||||
new::execute_new_command, run::execute_run_command, test::execute_test_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));
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user