Fix Create Disk Image Example
The example code didn't compile. This patch fixes that.
@@ -38,20 +38,28 @@ members = ["kernel"]
```rust
// build.rs
+use std::path::Path;
+
fn main() {
// set by cargo, build scripts should use this directory for output files
let out_dir = std::env::var_os("OUT_DIR").unwrap();
+ let out_dir_path = Path::new(&out_dir);
// set by cargo's artifact dependency feature, see
// https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#artifact-dependencies
- let kernel = std::env::var_os("CARGO_BIN_FILE_KERNEL_kernel");
+ let kernel = std::env::var_os("CARGO_BIN_FILE_KERNEL_kernel").unwrap();
+ let kernel_path = Path::new(&kernel);
// create an UEFI disk image (optional)
- let uefi_path = out_dir.join("uefi.img");
- bootloader::UefiBoot::new(&kernel).create_disk_image(uefi_path).unwrap();
+ let uefi_path = out_dir_path.join("uefi.img");
+ bootloader::UefiBoot::new(&kernel_path)
+ .create_disk_image(&uefi_path)
+ .unwrap();
- // create a BIOS disk image (optional)
- let out_bios_path = out_dir.join("bios.img");
- bootloader::BiosBoot::new(&kernel).create_disk_image(uefi_path).unwrap();
+ // create a BIOS disk image
+ let bios_path = out_dir_path.join("bios.img");
+ bootloader::BiosBoot::new(&kernel_path)
+ .create_disk_image(&bios_path)
+ .unwrap();
// pass the disk image paths as env variables to the `main.rs`
println!("cargo:rustc-env=UEFI_PATH={}", uefi_path.display());
@@ -77,8 +85,8 @@ fn main() {
} else {
cmd.arg("-drive").arg(format!("format=raw,file={bios_path}"));
}
- let mut child = cmd.spawn()?;
- child.wait()?;
+ let mut child = cmd.spawn().unwrap();
+ child.wait().unwrap();
}
```
