@@ -6,29 +6,37 @@ use std::{
6
6
const BOOTLOADER_VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
7
7
8
8
fn main ( ) {
9
- let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
10
-
11
9
#[ cfg( feature = "uefi" ) ]
12
- {
13
- let uefi_path = build_uefi_bootloader ( & out_dir) ;
14
- println ! (
15
- "cargo:rustc-env=UEFI_BOOTLOADER_PATH={}" ,
16
- uefi_path. display( )
17
- ) ;
18
- }
19
-
10
+ uefi_main ( ) ;
20
11
#[ cfg( feature = "bios" ) ]
21
- {
22
- let bios_boot_sector_path = build_bios_boot_sector ( & out_dir) ;
23
- println ! (
24
- "cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}" ,
25
- bios_boot_sector_path. display( )
26
- ) ;
27
- let bios_stage_2_path = build_bios_stage_2 ( & out_dir) ;
28
- println ! (
29
- "cargo:rustc-env=BIOS_STAGE_2_PATH={}" ,
30
- bios_stage_2_path. display( )
31
- ) ;
12
+ bios_main ( ) ;
13
+ }
14
+
15
+ #[ cfg( not( docsrs_dummy_build) ) ]
16
+ #[ cfg( feature = "uefi" ) ]
17
+ fn uefi_main ( ) {
18
+ let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
19
+ let uefi_path = build_uefi_bootloader ( & out_dir) ;
20
+ println ! (
21
+ "cargo:rustc-env=UEFI_BOOTLOADER_PATH={}" ,
22
+ uefi_path. display( )
23
+ ) ;
24
+ }
25
+
26
+ #[ cfg( not( docsrs_dummy_build) ) ]
27
+ #[ cfg( feature = "bios" ) ]
28
+ fn bios_main ( ) {
29
+ let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
30
+ let bios_boot_sector_path = build_bios_boot_sector ( & out_dir) ;
31
+ println ! (
32
+ "cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}" ,
33
+ bios_boot_sector_path. display( )
34
+ ) ;
35
+ let bios_stage_2_path = build_bios_stage_2 ( & out_dir) ;
36
+ println ! (
37
+ "cargo:rustc-env=BIOS_STAGE_2_PATH={}" ,
38
+ bios_stage_2_path. display( )
39
+ ) ;
32
40
33
41
let bios_stage_3_path = build_bios_stage_3 ( & out_dir) ;
34
42
println ! (
@@ -41,10 +49,8 @@ fn main() {
41
49
"cargo:rustc-env=BIOS_STAGE_4_PATH={}" ,
42
50
bios_stage_4_path. display( )
43
51
) ;
44
- }
45
52
}
46
53
47
- #[ cfg( not( docsrs_dummy_build) ) ]
48
54
#[ cfg( feature = "uefi" ) ]
49
55
fn build_uefi_bootloader ( out_dir : & Path ) -> PathBuf {
50
56
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
@@ -79,7 +85,6 @@ fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
79
85
}
80
86
}
81
87
82
- #[ cfg( not( docsrs_dummy_build) ) ]
83
88
#[ cfg( feature = "bios" ) ]
84
89
fn build_bios_boot_sector ( out_dir : & Path ) -> PathBuf {
85
90
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
@@ -122,7 +127,6 @@ fn build_bios_boot_sector(out_dir: &Path) -> PathBuf {
122
127
convert_elf_to_bin ( elf_path)
123
128
}
124
129
125
- #[ cfg( not( docsrs_dummy_build) ) ]
126
130
#[ cfg( feature = "bios" ) ]
127
131
fn build_bios_stage_2 ( out_dir : & Path ) -> PathBuf {
128
132
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
@@ -163,7 +167,6 @@ fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
163
167
convert_elf_to_bin ( elf_path)
164
168
}
165
169
166
- #[ cfg( not( docsrs_dummy_build) ) ]
167
170
#[ cfg( feature = "bios" ) ]
168
171
fn build_bios_stage_3 ( out_dir : & Path ) -> PathBuf {
169
172
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
@@ -204,7 +207,6 @@ fn build_bios_stage_3(out_dir: &Path) -> PathBuf {
204
207
convert_elf_to_bin ( elf_path)
205
208
}
206
209
207
- #[ cfg( not( docsrs_dummy_build) ) ]
208
210
#[ cfg( feature = "bios" ) ]
209
211
fn build_bios_stage_4 ( out_dir : & Path ) -> PathBuf {
210
212
let cargo = std:: env:: var ( "CARGO" ) . unwrap_or_else ( |_| "cargo" . into ( ) ) ;
@@ -277,22 +279,9 @@ fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf {
277
279
// dummy implementations because docsrs builds have no network access
278
280
279
281
#[ cfg( docsrs_dummy_build) ]
280
- fn build_uefi_bootloader ( _out_dir : & Path ) -> PathBuf {
281
- PathBuf :: new ( )
282
- }
283
- #[ cfg( docsrs_dummy_build) ]
284
- fn build_bios_boot_sector ( _out_dir : & Path ) -> PathBuf {
285
- PathBuf :: new ( )
286
- }
287
- #[ cfg( docsrs_dummy_build) ]
288
- fn build_bios_stage_2 ( _out_dir : & Path ) -> PathBuf {
289
- PathBuf :: new ( )
290
- }
291
- #[ cfg( docsrs_dummy_build) ]
292
- fn build_bios_stage_3 ( _out_dir : & Path ) -> PathBuf {
293
- PathBuf :: new ( )
294
- }
282
+ #[ cfg( feature = "uefi" ) ]
283
+ fn uefi_main ( ) { }
284
+
295
285
#[ cfg( docsrs_dummy_build) ]
296
- fn build_bios_stage_4 ( _out_dir : & Path ) -> PathBuf {
297
- PathBuf :: new ( )
298
- }
286
+ #[ cfg( feature = "bios" ) ]
287
+ fn bios_main ( ) { }
0 commit comments