@@ -38,20 +38,28 @@ members = ["kernel"]
3838``` rust
3939// build.rs
4040
41+ use std :: path :: Path ;
42+
4143fn main () {
4244 // set by cargo, build scripts should use this directory for output files
4345 let out_dir = std :: env :: var_os (" OUT_DIR" ). unwrap ();
46+ let out_dir_path = Path :: new (& out_dir );
4447 // set by cargo's artifact dependency feature, see
4548 // https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#artifact-dependencies
46- let kernel = std :: env :: var_os (" CARGO_BIN_FILE_KERNEL_kernel" );
49+ let kernel = std :: env :: var_os (" CARGO_BIN_FILE_KERNEL_kernel" ). unwrap ();
50+ let kernel_path = Path :: new (& kernel );
4751
4852 // create an UEFI disk image (optional)
49- let uefi_path = out_dir . join (" uefi.img" );
50- bootloader :: UefiBoot :: new (& kernel ). create_disk_image (uefi_path ). unwrap ();
53+ let uefi_path = out_dir_path . join (" uefi.img" );
54+ bootloader :: UefiBoot :: new (& kernel_path )
55+ . create_disk_image (& uefi_path )
56+ . unwrap ();
5157
52- // create a BIOS disk image (optional)
53- let out_bios_path = out_dir . join (" bios.img" );
54- bootloader :: BiosBoot :: new (& kernel ). create_disk_image (uefi_path ). unwrap ();
58+ // create a BIOS disk image
59+ let bios_path = out_dir_path . join (" bios.img" );
60+ bootloader :: BiosBoot :: new (& kernel_path )
61+ . create_disk_image (& bios_path )
62+ . unwrap ();
5563
5664 // pass the disk image paths as env variables to the `main.rs`
5765 println! (" cargo:rustc-env=UEFI_PATH={}" , uefi_path . display ());
@@ -77,8 +85,8 @@ fn main() {
7785 } else {
7886 cmd . arg (" -drive" ). arg (format! (" format=raw,file={bios_path}" ));
7987 }
80- let mut child = cmd . spawn ()? ;
81- child . wait ()? ;
88+ let mut child = cmd . spawn (). unwrap () ;
89+ child . wait (). unwrap () ;
8290}
8391```
8492
0 commit comments