[package]
name = "arceos-guestmonolithickernel"
version = "0.4.5"
edition = "2024"
authors = ["Lei Shi <shi_lei@massclouds.com>", "Yu Chen <yuchen@tsinghua.edu.cn>"]
description = "ArceOS Guest Monolithic Kernel (Hypervisor): runs a guest monolithic OS kernel with user-space process support (task management, syscall handling, pflash passthrough) — RISC-V H-extension, ARM AArch64 EL2, and AMD SVM"
homepage = "https://github.com/arceos-org/app-guestmonolithickernel"
repository = "https://github.com/arceos-org/app-guestmonolithickernel"
license = "GPL-3.0-or-later OR Apache-2.0 OR MulanPSL-2.0"
keywords = ["arceos", "hypervisor", "riscv", "aarch64", "x86_64"]
categories = ["os", "no-std"]
include = [
    "src/**",
    "build.rs",
    "configs/**",
    "payload/gkernel/src/**",
    "payload/gkernel/configs/**",
    "payload/gkernel/linker-*.ld",
    "xtask/src/**",
    ".cargo/config.toml",
    "rust-toolchain.toml",
    "README.md",
    "LICENSE*",
]

[features]
default = []
axstd = ["dep:axstd"]
guest-kernel = ["axstd", "axstd/paging", "dep:axhal", "axstd/alloc", "dep:axmm"]
hypervisor = [
    "axstd", "dep:axfeat", "dep:axfs", "dep:axio",
    "dep:axmm", "axhal/uspace", "dep:axsync", "dep:axtask", "dep:axlog",
    "dep:axerrno", "dep:memory_addr",
    "dep:memoffset",
]
xtask = ["dep:clap", "dep:fatfs"]

[[bin]]
name = "xtask"
path = "xtask/src/main.rs"
required-features = ["xtask"]

[[bin]]
name = "gkernel"
path = "payload/gkernel/src/main.rs"
required-features = ["guest-kernel"]

[dependencies]
# ─── ArceOS crates (common, all architectures) ───
axstd = { version = "0.2.2-preview.1", features = ["defplat", "alloc", "paging", "multitask", "sched-cfs"], optional = true }
axfeat = { version = "0.2.2-preview.1", features = ["fs", "fs-fat"], optional = true }
axfs = { version = "0.2.2-preview.1", features = ["fat"], optional = true }
axio = { version = "0.3.0-pre.1", optional = true }
axmm = { version = "0.2.2-preview.1", features = ["copy"], optional = true }
axhal = { version = "0.2.2-preview.3", optional = true }
axsync = { version = "0.2.2-preview.1", optional = true }
axtask = { version = "0.2.2-preview.3", optional = true }
axlog = { version = "0.2.2-preview.1", optional = true }
axerrno = { version = "0.1", optional = true }
memory_addr = { version = "0.4", optional = true }
memoffset = { version = ">=0.6.5", features = ["unstable_const"], optional = true }

# ─── Xtask dependencies ───
clap = { version = "4", features = ["derive"], optional = true }
fatfs = { version = "0.3.6", optional = true }

# ─── Non-x86_64: enable axhal uspace for real guest user-space execution ───
# On x86_64 SVM/TCG, axhal uspace triggers a crash during axtask init in the guest.
[target.'cfg(not(target_arch = "x86_64"))'.dependencies]
axhal = { version = "0.2.2-preview.3", features = ["uspace"], optional = true }

# ─── RISC-V specific (only compiled when target_arch = riscv64) ───
[target.'cfg(target_arch = "riscv64")'.dependencies]
sbi-spec = { version = "0.0.6", features = ["legacy"] }
riscv = { version = "0.11" }
sbi-rt = { version = "0.0.2", features = ["integer-impls", "legacy"] }
tock-registers = { version = "0.8.1" }

[profile.release]
panic = "abort"

[profile.dev]
panic = "abort"
