summaryrefslogtreecommitdiff
path: root/x/build.rs
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-09-05 19:01:32 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-09-05 19:01:32 +0800
commit365b581ca5c37305f9583cf08d0c25c4426f47e2 (patch)
tree4a77be797bc192a5919728a7337937407075c119 /x/build.rs
parentb4d9a57f193c64bca188a76e4f711cc168da9737 (diff)
migrate: limine -> bootloader_api
Diffstat (limited to 'x/build.rs')
-rw-r--r--x/build.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/x/build.rs b/x/build.rs
new file mode 100644
index 0000000..37200d3
--- /dev/null
+++ b/x/build.rs
@@ -0,0 +1,25 @@
+use std::path::PathBuf;
+
+fn main() {
+ // set by cargo, build scripts should use this directory for output files
+ let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
+ // set by cargo's artifact dependency feature, see
+ // https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#artifact-dependencies
+ let kernel = PathBuf::from(std::env::var_os("CARGO_BIN_FILE_KERNEL_kernel").unwrap());
+
+ // create an UEFI disk image (optional)
+ let uefi_path = out_dir.join("uefi.img");
+ bootloader::UefiBoot::new(&kernel)
+ .create_disk_image(&uefi_path)
+ .unwrap();
+
+ // create a BIOS disk image
+ let bios_path = out_dir.join("bios.img");
+ bootloader::BiosBoot::new(&kernel)
+ .create_disk_image(&bios_path)
+ .unwrap();
+
+ // pass the disk image paths as env variables to the
+ println!("cargo:rustc-env=UEFI_PATH={}", uefi_path.display());
+ println!("cargo:rustc-env=BIOS_PATH={}", bios_path.display());
+}