#![cfg_attr(not(any(windows, unix)), no_std)]
#![cfg(any(windows, unix))]
use clap::{Args, Parser, Subcommand};
use crate::{arceos::ArceOS, axloader::Axloader, axvisor::Axvisor, starry::Starry};
pub mod arceos;
pub mod axloader;
pub mod axvisor;
mod backtrace;
mod board;
mod build;
mod clippy;
mod config;
pub mod context;
mod firmware;
pub mod image;
mod rootfs;
mod spin_lint;
pub mod starry;
mod support;
mod sync_lint;
mod test;
#[derive(Parser)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Args, Clone, Debug, PartialEq, Eq)]
pub(crate) struct ClippyArgs {
#[arg(long)]
pub(crate) all: bool,
#[arg(long = "package", value_name = "PACKAGE")]
pub(crate) packages: Vec<String>,
#[arg(long, value_name = "REF")]
pub(crate) since: Option<String>,
}
#[derive(Args, Clone, Debug, PartialEq, Eq)]
pub(crate) struct SyncLintArgs {
#[arg(long, value_name = "REF")]
pub(crate) since: Option<String>,
}
#[derive(Subcommand)]
enum Commands {
Test,
Clippy(ClippyArgs),
SyncLint(SyncLintArgs),
SpinLint,
Board {
#[command(subcommand)]
command: board::Command,
},
Config {
#[command(subcommand)]
command: config::Command,
},
Backtrace {
#[command(subcommand)]
command: backtrace::Command,
},
Image(image::ImageArgs),
Axvisor {
#[command(subcommand)]
command: axvisor::Command,
},
Axloader {
#[command(subcommand)]
command: axloader::Command,
},
Arceos {
#[command(subcommand)]
command: arceos::Command,
},
Starry {
#[command(subcommand)]
command: starry::Command,
},
}
pub async fn run() -> anyhow::Result<()> {
let cli = Cli::parse();
run_root_cli(cli).await
}
async fn run_root_cli(cli: Cli) -> anyhow::Result<()> {
match cli.command {
Commands::Test => test::std::run_std_test_command(),
Commands::Clippy(args) => {
ensure_aic8800_firmware().await?;
clippy::run_workspace_clippy_command(&args)
}
Commands::SyncLint(args) => sync_lint::run_sync_lint_command(&args),
Commands::SpinLint => spin_lint::run_spin_lint_command(),
Commands::Board { command } => board::execute(command).await,
Commands::Config { command } => config::execute(command),
Commands::Backtrace { command } => backtrace::execute(command),
Commands::Image(args) => image::run(args).await,
Commands::Axvisor { command } => Axvisor::new()?.execute(command).await,
Commands::Axloader { command } => Axloader::new()?.execute(command).await,
Commands::Arceos { command } => ArceOS::new()?.execute(command).await,
Commands::Starry { command } => {
ensure_aic8800_firmware().await?;
Starry::new()?.execute(command).await
}
}
}
async fn ensure_aic8800_firmware() -> anyhow::Result<()> {
let workspace_root = context::workspace_root_path()?;
firmware::ensure_aic8800_firmware(&workspace_root).await
}