Skip to content

Commit cc09d3d

Browse files
committed
Simplify path construction in disk image example
1 parent 34875f6 commit cc09d3d

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

docs/create-disk-image.md

+6-12
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,18 @@ use std::path::Path;
4242

4343
fn main() {
4444
// set by cargo, build scripts should use this directory for output files
45-
let out_dir = std::env::var_os("OUT_DIR").unwrap();
46-
let out_dir_path = Path::new(&out_dir);
45+
let out_dir = Path::new(&std::env::var_os("OUT_DIR").unwrap());
4746
// set by cargo's artifact dependency feature, see
4847
// https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#artifact-dependencies
49-
let kernel = std::env::var_os("CARGO_BIN_FILE_KERNEL_kernel").unwrap();
50-
let kernel_path = Path::new(&kernel);
48+
let kernel = Path::new(&std::env::var_os("CARGO_BIN_FILE_KERNEL_kernel").unwrap());
5149

5250
// create an UEFI disk image (optional)
53-
let uefi_path = out_dir_path.join("uefi.img");
54-
bootloader::UefiBoot::new(&kernel_path)
55-
.create_disk_image(&uefi_path)
56-
.unwrap();
51+
let uefi_path = out_dir.join("uefi.img");
52+
bootloader::UefiBoot::new(&kernel).create_disk_image(&uefi_path).unwrap();
5753

5854
// 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();
55+
let bios_path = out_dir.join("bios.img");
56+
bootloader::BiosBoot::new(&kernel).create_disk_image(&bios_path).unwrap();
6357

6458
// pass the disk image paths as env variables to the `main.rs`
6559
println!("cargo:rustc-env=UEFI_PATH={}", uefi_path.display());

0 commit comments

Comments
 (0)