xtask/tasks/
build_igvm.rsuse crate::Xtask;
use clap::Parser;
use clap::builder::PossibleValue;
use std::fmt;
use std::path::PathBuf;
#[derive(clap::ValueEnum, Copy, Clone, PartialEq, Eq, Debug)]
enum KernelPackageKind {
Lkg,
Dev,
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum BuildIgvmArch {
X86_64,
Aarch64,
}
impl BuildIgvmArch {
pub fn host() -> Self {
if cfg!(target_arch = "x86_64") {
BuildIgvmArch::X86_64
}
else if cfg!(target_arch = "aarch64") {
BuildIgvmArch::Aarch64
} else {
panic!("Unsupported host architecture")
}
}
pub fn as_str(&self) -> &'static str {
match self {
BuildIgvmArch::X86_64 => "x86_64",
BuildIgvmArch::Aarch64 => "aarch64",
}
}
}
impl fmt::Display for BuildIgvmArch {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad(self.as_str())
}
}
impl clap::ValueEnum for BuildIgvmArch {
fn value_variants<'a>() -> &'a [Self] {
&[BuildIgvmArch::X86_64, BuildIgvmArch::Aarch64]
}
fn to_possible_value(&self) -> Option<PossibleValue> {
match self {
BuildIgvmArch::X86_64 => Some(PossibleValue::new("x86_64").aliases(["x86-64", "x64"])),
BuildIgvmArch::Aarch64 => Some(PossibleValue::new("aarch64").aliases(["arm64"])),
}
}
}
#[derive(Debug, Parser)]
pub struct BuildIgvm {
#[clap(long)]
verbose: bool,
#[clap(long)]
release: bool,
#[clap(short = 'p', long, requires("release"))]
perf: bool,
#[clap(long)]
debuginfo: bool,
#[clap(long)]
underhill: Option<PathBuf>,
#[clap(long)]
boot_shim: Option<PathBuf>,
#[clap(long)]
profiler: Option<PathBuf>,
#[clap(long)]
uefi: Option<PathBuf>,
#[clap(long)]
sidecar: bool,
#[clap(long, requires = "sidecar")]
sidecar_path: Option<PathBuf>,
#[clap(short = 'm', long)]
manifest: Option<PathBuf>,
#[clap(long)]
layer: Vec<String>,
#[clap(long)]
directory: Vec<String>,
#[clap(short = 'o', long)]
output_name: Option<PathBuf>,
#[clap(short = 'k', long)]
#[clap(value_enum, default_value_t=KernelPackageKind::Lkg)]
kernel_kind: KernelPackageKind,
#[clap(long)]
kernel: Option<PathBuf>,
#[clap(long)]
kernel_modules: Option<PathBuf>,
#[clap(short = 'a', long)]
#[clap(default_value_t=BuildIgvmArch::host())]
arch: BuildIgvmArch,
#[clap(long)]
extra_features: Vec<String>,
#[clap(long)]
vtl0_kernel: Option<PathBuf>,
}
impl Xtask for BuildIgvm {
#[rustfmt::skip]
fn run(self, _ctx: crate::XtaskCtx) -> anyhow::Result<()> {
let _ = self;
log::warn!("NOTE: `cargo xtask build-igvm` has been deleted!");
log::warn!("");
log::warn!("Please switch over to using `cargo xflowey build-igvm` instead.");
log::warn!("");
log::warn!(" NOTE: The new `xflowey build-igvm` CLI is INCOMPATIBLE with `xtask build-igvm`!");
log::warn!("");
log::warn!(" This new CLI is designed to be more consistent, user-friendly, and better-documented than the legacy `xtask build-igvm` CLI.");
log::warn!(" Please read the docs at `cargo xflowey build-igvm --help` to learn more");
log::warn!("");
log::warn!(" NOTE: The new `xflowey build-igvm` command has DIFFERENT output filenames and directories!");
log::warn!("");
log::warn!(" Old: `target/x86_64-unknown-linux-musl/debug/underhill-cvm.bin`");
log::warn!(" New: `flowey-out/artifacts/build-igvm/x64-cvm/openhcl-cvm-x64.bin`");
log::warn!("");
anyhow::bail!("`cargo xtask build-igvm` has been deleted!");
}
}