-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
27 lines (21 loc) · 958 Bytes
/
Copy pathbuild.rs
File metadata and controls
27 lines (21 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::path::PathBuf;
fn main() {
let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let root_dir = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap());
// Compile init
let init_path = root_dir.join("userspace");
println!("cargo::rerun-if-changed={}", init_path.display());
let mut make_cmd = std::process::Command::new("make");
make_cmd.current_dir(&init_path);
make_cmd.spawn().unwrap().wait().unwrap();
let ramdisk = init_path.clone().join("ramdisk.tar");
// Compile kernel
let kernel = PathBuf::from(std::env::var_os("CARGO_BIN_FILE_KERNEL_kernel").unwrap());
let uefi_path = out_dir.join("uefi.img");
bootloader::UefiBoot::new(&kernel)
.set_ramdisk(ramdisk.as_path())
.create_disk_image(&uefi_path)
.unwrap();
println!("cargo:rustc-env=UEFI_PATH={}", uefi_path.display());
println!("cargo:rustc-env=ELF_PATH={}", kernel.display());
}