@@ -21,7 +21,6 @@ async fn bios_main() {
21
21
// BIOS crates don't have enough dependencies to utilize all cores on modern
22
22
// CPUs. So by running the build commands in parallel, we increase the number
23
23
// of utilized cores.)
24
- #[ cfg( not( docsrs_dummy_build) ) ]
25
24
let ( bios_boot_sector_path, bios_stage_2_path, bios_stage_3_path, bios_stage_4_path) = (
26
25
build_bios_boot_sector ( & out_dir) ,
27
26
build_bios_stage_2 ( & out_dir) ,
@@ -30,14 +29,6 @@ async fn bios_main() {
30
29
)
31
30
. join ( )
32
31
. await ;
33
- // dummy implementations because docsrs builds have no network access
34
- #[ cfg( docsrs_dummy_build) ]
35
- let ( bios_boot_sector_path, bios_stage_2_path, bios_stage_3_path, bios_stage_4_path) = (
36
- PathBuf :: new ( ) ,
37
- PathBuf :: new ( ) ,
38
- PathBuf :: new ( ) ,
39
- PathBuf :: new ( ) ,
40
- ) ;
41
32
println ! (
42
33
"cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}" ,
43
34
bios_boot_sector_path. display( )
@@ -60,11 +51,7 @@ async fn bios_main() {
60
51
async fn uefi_main ( ) {
61
52
let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
62
53
63
- #[ cfg( not( docsrs_dummy_build) ) ]
64
54
let uefi_path = build_uefi_bootloader ( & out_dir) . await ;
65
- // dummy implementation because docsrs builds have no network access
66
- #[ cfg( docsrs_dummy_build) ]
67
- let uefi_path = PathBuf :: new ( ) ;
68
55
69
56
println ! (
70
57
"cargo:rustc-env=UEFI_BOOTLOADER_PATH={}" ,
@@ -109,6 +96,26 @@ async fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
109
96
}
110
97
}
111
98
99
+ // dummy implementation because docsrs builds have no network access.
100
+ // This will put an empty file in out_dir and return its path.
101
+ #[ cfg( docsrs_dummy_build) ]
102
+ #[ cfg( feature = "uefi" ) ]
103
+ async fn build_uefi_bootloader ( out_dir : & Path ) -> PathBuf {
104
+ use std:: fs:: File ;
105
+
106
+ let path = out_dir. join ( "bootloader-dummy-bootloader-uefi" ) ;
107
+
108
+ if File :: create ( & path) . is_err ( ) {
109
+ panic ! ( "Failed to create dummy uefi bootloader" ) ;
110
+ }
111
+ assert ! (
112
+ path. exists( ) ,
113
+ "uefi bootloader dummy file does not exist after file creation"
114
+ ) ;
115
+
116
+ path
117
+ }
118
+
112
119
#[ cfg( not( docsrs_dummy_build) ) ]
113
120
#[ cfg( feature = "bios" ) ]
114
121
async fn build_bios_boot_sector ( out_dir : & Path ) -> PathBuf {
@@ -153,6 +160,26 @@ async fn build_bios_boot_sector(out_dir: &Path) -> PathBuf {
153
160
convert_elf_to_bin ( elf_path) . await
154
161
}
155
162
163
+ // dummy implementation because docsrs builds have no network access.
164
+ // This will put an empty file in out_dir and return its path.
165
+ #[ cfg( docsrs_dummy_build) ]
166
+ #[ cfg( feature = "bios" ) ]
167
+ async fn build_bios_boot_sector ( out_dir : & Path ) -> PathBuf {
168
+ use std:: fs:: File ;
169
+
170
+ let path = out_dir. join ( "bootloader-dummy-bios-boot-sector" ) ;
171
+
172
+ if File :: create ( & path) . is_err ( ) {
173
+ panic ! ( "Failed to create dummy bios boot sector" ) ;
174
+ }
175
+ assert ! (
176
+ path. exists( ) ,
177
+ "bios boot sector dummy file does not exist after file creation"
178
+ ) ;
179
+
180
+ path
181
+ }
182
+
156
183
#[ cfg( not( docsrs_dummy_build) ) ]
157
184
#[ cfg( feature = "bios" ) ]
158
185
async fn build_bios_stage_2 ( out_dir : & Path ) -> PathBuf {
@@ -199,6 +226,26 @@ async fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
199
226
convert_elf_to_bin ( elf_path) . await
200
227
}
201
228
229
+ // dummy implementation because docsrs builds have no network access.
230
+ // This will put an empty file in out_dir and return its path.
231
+ #[ cfg( docsrs_dummy_build) ]
232
+ #[ cfg( feature = "bios" ) ]
233
+ async fn build_bios_stage_2 ( out_dir : & Path ) -> PathBuf {
234
+ use std:: fs:: File ;
235
+
236
+ let path = out_dir. join ( "bootloader-dummy-bios-stage-2" ) ;
237
+
238
+ if File :: create ( & path) . is_err ( ) {
239
+ panic ! ( "Failed to create dummy bios second stage" ) ;
240
+ }
241
+ assert ! (
242
+ path. exists( ) ,
243
+ "bios second stage dummy file does not exist after file creation"
244
+ ) ;
245
+
246
+ path
247
+ }
248
+
202
249
#[ cfg( not( docsrs_dummy_build) ) ]
203
250
#[ cfg( feature = "bios" ) ]
204
251
async fn build_bios_stage_3 ( out_dir : & Path ) -> PathBuf {
@@ -241,6 +288,26 @@ async fn build_bios_stage_3(out_dir: &Path) -> PathBuf {
241
288
convert_elf_to_bin ( elf_path) . await
242
289
}
243
290
291
+ // dummy implementation because docsrs builds have no network access.
292
+ // This will put an empty file in out_dir and return its path.
293
+ #[ cfg( docsrs_dummy_build) ]
294
+ #[ cfg( feature = "bios" ) ]
295
+ async fn build_bios_stage_3 ( out_dir : & Path ) -> PathBuf {
296
+ use std:: fs:: File ;
297
+
298
+ let path = out_dir. join ( "bootloader-dummy-bios-stage-3" ) ;
299
+
300
+ if File :: create ( & path) . is_err ( ) {
301
+ panic ! ( "Failed to create dummy bios stage-3" ) ;
302
+ }
303
+ assert ! (
304
+ path. exists( ) ,
305
+ "bios stage-3 dummy file does not exist after file creation"
306
+ ) ;
307
+
308
+ path
309
+ }
310
+
244
311
#[ cfg( not( docsrs_dummy_build) ) ]
245
312
#[ cfg( feature = "bios" ) ]
246
313
async fn build_bios_stage_4 ( out_dir : & Path ) -> PathBuf {
@@ -284,6 +351,26 @@ async fn build_bios_stage_4(out_dir: &Path) -> PathBuf {
284
351
convert_elf_to_bin ( elf_path) . await
285
352
}
286
353
354
+ // dummy implementation because docsrs builds have no network access.
355
+ // This will put an empty file in out_dir and return its path.
356
+ #[ cfg( docsrs_dummy_build) ]
357
+ #[ cfg( feature = "bios" ) ]
358
+ async fn build_bios_stage_4 ( out_dir : & Path ) -> PathBuf {
359
+ use std:: fs:: File ;
360
+
361
+ let path = out_dir. join ( "bootloader-dummy-bios-stage-4" ) ;
362
+
363
+ if File :: create ( & path) . is_err ( ) {
364
+ panic ! ( "Failed to create dummy bios stage-4" ) ;
365
+ }
366
+ assert ! (
367
+ path. exists( ) ,
368
+ "bios stage-4 dummy file does not exist after file creation"
369
+ ) ;
370
+
371
+ path
372
+ }
373
+
287
374
#[ cfg( not( docsrs_dummy_build) ) ]
288
375
#[ cfg( feature = "bios" ) ]
289
376
async fn convert_elf_to_bin ( elf_path : PathBuf ) -> PathBuf {
0 commit comments