@@ -38,20 +38,28 @@ members = ["kernel"]
38
38
``` rust
39
39
// build.rs
40
40
41
+ use std :: path :: Path ;
42
+
41
43
fn main () {
42
44
// set by cargo, build scripts should use this directory for output files
43
45
let out_dir = std :: env :: var_os (" OUT_DIR" ). unwrap ();
46
+ let out_dir_path = Path :: new (& out_dir );
44
47
// set by cargo's artifact dependency feature, see
45
48
// 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 );
47
51
48
52
// 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 ();
51
57
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 ();
55
63
56
64
// pass the disk image paths as env variables to the `main.rs`
57
65
println! (" cargo:rustc-env=UEFI_PATH={}" , uefi_path . display ());
@@ -77,8 +85,8 @@ fn main() {
77
85
} else {
78
86
cmd . arg (" -drive" ). arg (format! (" format=raw,file={bios_path}" ));
79
87
}
80
- let mut child = cmd . spawn ()? ;
81
- child . wait ()? ;
88
+ let mut child = cmd . spawn (). unwrap () ;
89
+ child . wait (). unwrap () ;
82
90
}
83
91
```
84
92
0 commit comments