forked from AbleOS/ableos
Repbuild now can build kernel on non-POSIX systems and run on non-Linux systems.
This commit is contained in:
parent
b802732acf
commit
7d21956b0a
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -388,18 +388,6 @@ version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nix"
|
|
||||||
version = "0.26.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"static_assertions",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.45"
|
version = "0.1.45"
|
||||||
|
@ -492,7 +480,6 @@ dependencies = [
|
||||||
"error-stack",
|
"error-stack",
|
||||||
"fatfs",
|
"fatfs",
|
||||||
"log",
|
"log",
|
||||||
"nix",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -580,12 +567,6 @@ dependencies = [
|
||||||
"lock_api",
|
"lock_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "static_assertions"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "supports-color"
|
name = "supports-color"
|
||||||
version = "1.3.1"
|
version = "1.3.1"
|
||||||
|
|
|
@ -8,8 +8,3 @@ env_logger = "0.10"
|
||||||
error-stack = "0.2"
|
error-stack = "0.2"
|
||||||
fatfs = "0.3"
|
fatfs = "0.3"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
[dependencies.nix]
|
|
||||||
version = "0.26"
|
|
||||||
default-features = false
|
|
||||||
features = ["fs"]
|
|
||||||
|
|
|
@ -24,8 +24,7 @@ fn main() -> Result<(), Error> {
|
||||||
run()
|
run()
|
||||||
}
|
}
|
||||||
Some("help" | "h") => {
|
Some("help" | "h") => {
|
||||||
println!(
|
println!(concat!(
|
||||||
concat!(
|
|
||||||
"AbleOS RepBuild\n",
|
"AbleOS RepBuild\n",
|
||||||
"Subcommands:\n",
|
"Subcommands:\n",
|
||||||
" build (b): Build a bootable disk image\n",
|
" build (b): Build a bootable disk image\n",
|
||||||
|
@ -33,8 +32,7 @@ fn main() -> Result<(), Error> {
|
||||||
" run (r): Build and run AbleOS in QEMU\n\n",
|
" run (r): Build and run AbleOS in QEMU\n\n",
|
||||||
"Options for build and run:\n",
|
"Options for build and run:\n",
|
||||||
" -r: build in release mode",
|
" -r: build in release mode",
|
||||||
),
|
),);
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => Err(report!(Error::InvalidSubCom)),
|
_ => Err(report!(Error::InvalidSubCom)),
|
||||||
|
@ -62,19 +60,7 @@ fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
|
||||||
.create(true)
|
.create(true)
|
||||||
.open(path)?;
|
.open(path)?;
|
||||||
|
|
||||||
{
|
img.set_len(1024 * 1024 * 64)?;
|
||||||
#[cfg(unix)]
|
|
||||||
nix::fcntl::fallocate(
|
|
||||||
img.as_raw_fd(),
|
|
||||||
FallocateFlags::from_bits(0).unwrap(),
|
|
||||||
0,
|
|
||||||
1024 * 1024 * 64,
|
|
||||||
)
|
|
||||||
.map_err(|e| std::io::Error::from_raw_os_error(e as i32))?;
|
|
||||||
|
|
||||||
#[cfg(not(any(unix)))]
|
|
||||||
compile_error!("unsupported platform");
|
|
||||||
}
|
|
||||||
|
|
||||||
fatfs::format_volume(&mut img, FormatVolumeOptions::new())?;
|
fatfs::format_volume(&mut img, FormatVolumeOptions::new())?;
|
||||||
|
|
||||||
|
@ -122,19 +108,23 @@ fn build(release: bool) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run() -> Result<(), Error> {
|
fn run() -> Result<(), Error> {
|
||||||
|
let mut com = Command::new("qemu-system-x86_64");
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
let args = [
|
com.args([
|
||||||
"-bios", "/usr/share/OVMF/OVMF_CODE.fd",
|
"-bios", "/usr/share/OVMF/OVMF_CODE.fd",
|
||||||
"-enable-kvm",
|
|
||||||
"-cpu", "host",
|
|
||||||
"-drive", "file=target/disk.img,format=raw",
|
"-drive", "file=target/disk.img,format=raw",
|
||||||
"-m", "4G",
|
"-m", "4G",
|
||||||
"-serial", "stdio",
|
"-serial", "stdio",
|
||||||
"-smp", "cores=2",
|
"-smp", "cores=2",
|
||||||
];
|
]);
|
||||||
|
|
||||||
match Command::new("qemu-system-x86_64")
|
#[cfg(target_os = "linux")]
|
||||||
.args(args)
|
{
|
||||||
|
com.args(["-enable-kvm", "-cpu", "host"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
match com
|
||||||
.status()
|
.status()
|
||||||
.into_report()
|
.into_report()
|
||||||
.change_context(Error::ProcessSpawn)?
|
.change_context(Error::ProcessSpawn)?
|
||||||
|
|
Loading…
Reference in a new issue