1
0
Fork 0
forked from AbleOS/ableos
ableos_time/repbuild/src/main.rs

94 lines
2.9 KiB
Rust
Raw Normal View History

2021-11-16 22:52:17 -06:00
use clap::Parser;
2021-11-16 00:09:27 -06:00
2021-11-16 22:52:17 -06:00
#[derive(clap::Parser, Debug)]
#[clap(version = clap::crate_version!(), author = clap::crate_authors!("\n"))]
/// Hello Remember this is a feature
2021-11-16 00:09:27 -06:00
enum Command {
Run {
2021-11-16 22:52:17 -06:00
#[clap(long, short)]
2021-11-16 00:09:27 -06:00
debug: bool,
2021-11-16 22:52:17 -06:00
#[clap(long, short, arg_enum)]
machine: Option<MachineType>,
2021-11-16 00:09:27 -06:00
},
2021-11-21 02:13:50 -06:00
Doc {
#[clap(long, short, arg_enum)]
machine: Option<MachineType>,
},
2021-11-16 00:09:27 -06:00
}
2021-11-16 22:52:17 -06:00
#[derive(clap::ArgEnum, Debug, Clone)]
enum MachineType {
X86,
RISCV,
ARM,
2021-11-16 00:09:27 -06:00
}
fn main() -> anyhow::Result<()> {
2021-11-16 22:52:17 -06:00
let args = Command::parse();
2021-11-16 00:09:27 -06:00
match args {
2021-11-16 22:52:17 -06:00
Command::Run { debug, machine } => {
let _dir = xshell::pushd("./ableos");
2021-11-16 00:09:27 -06:00
2021-11-16 22:52:17 -06:00
let _debug_log: &[&str] = match debug {
2021-11-16 00:09:27 -06:00
true => &["-D", "debug.log"],
false => &[],
};
2021-11-16 22:52:17 -06:00
match machine.unwrap_or(MachineType::X86) {
MachineType::X86 => {
xshell::cmd!("cargo run --release").run()?;
}
MachineType::ARM => {
xshell::cmd!("cargo build --release --target=json_targets/aarch64-ableos.json")
.run()?;
#[rustfmt::skip]
xshell::cmd!(
"qemu-system-aarch64
-machine virt
-m 1024M
-cpu cortex-a53
-kernel target/aarch64-ableos/release/ableos
-device virtio-keyboard
"
).run()?;
2021-11-16 22:52:17 -06:00
}
MachineType::RISCV => {
xshell::cmd!("cargo build --release --target=riscv64gc-unknown-none-elf")
.run()?;
#[rustfmt::skip]
xshell::cmd!(
"qemu-system-riscv64
-machine virt
-cpu rv64
-smp 8
-m 128M
-bios src/arch/riscv/firmwear/opensbi-riscv64-generic-fw_jump.bin
-kernel target/riscv64gc-unknown-none-elf/release/ableos"
).run()?;
2021-11-16 22:52:17 -06:00
}
}
2021-11-16 00:09:27 -06:00
}
2021-11-21 02:13:50 -06:00
Command::Doc { machine } => {
let _dir = xshell::pushd("./ableos");
match machine.unwrap_or(MachineType::X86) {
MachineType::X86 => {
xshell::cmd!("cargo doc --open").run()?;
}
MachineType::ARM => {
xshell::cmd!("cargo doc --open --target=json_targets/aarch64-ableos.json")
.run()?;
}
MachineType::RISCV => {
xshell::cmd!("cargo doc --open --target=riscv64gc-unknown-none-elf").run()?;
}
}
}
2021-11-16 00:09:27 -06:00
}
Ok(())
}