@@ -21,7 +21,6 @@ async fn bios_main() {
2121 // BIOS crates don't have enough dependencies to utilize all cores on modern
2222 // CPUs. So by running the build commands in parallel, we increase the number
2323 // of utilized cores.)
24- #[ cfg( not( docsrs_dummy_build) ) ]
2524 let ( bios_boot_sector_path, bios_stage_2_path, bios_stage_3_path, bios_stage_4_path) = (
2625 build_bios_boot_sector ( & out_dir) ,
2726 build_bios_stage_2 ( & out_dir) ,
@@ -30,14 +29,6 @@ async fn bios_main() {
3029 )
3130 . join ( )
3231 . 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- ) ;
4132 println ! (
4233 "cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}" ,
4334 bios_boot_sector_path. display( )
@@ -60,11 +51,7 @@ async fn bios_main() {
6051async fn uefi_main ( ) {
6152 let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
6253
63- #[ cfg( not( docsrs_dummy_build) ) ]
6454 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 ( ) ;
6855
6956 println ! (
7057 "cargo:rustc-env=UEFI_BOOTLOADER_PATH={}" ,
@@ -109,6 +96,26 @@ async fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
10996 }
11097}
11198
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+
112119#[ cfg( not( docsrs_dummy_build) ) ]
113120#[ cfg( feature = "bios" ) ]
114121async fn build_bios_boot_sector ( out_dir : & Path ) -> PathBuf {
@@ -153,6 +160,26 @@ async fn build_bios_boot_sector(out_dir: &Path) -> PathBuf {
153160 convert_elf_to_bin ( elf_path) . await
154161}
155162
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+
156183#[ cfg( not( docsrs_dummy_build) ) ]
157184#[ cfg( feature = "bios" ) ]
158185async fn build_bios_stage_2 ( out_dir : & Path ) -> PathBuf {
@@ -199,6 +226,26 @@ async fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
199226 convert_elf_to_bin ( elf_path) . await
200227}
201228
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+
202249#[ cfg( not( docsrs_dummy_build) ) ]
203250#[ cfg( feature = "bios" ) ]
204251async fn build_bios_stage_3 ( out_dir : & Path ) -> PathBuf {
@@ -241,6 +288,26 @@ async fn build_bios_stage_3(out_dir: &Path) -> PathBuf {
241288 convert_elf_to_bin ( elf_path) . await
242289}
243290
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+
244311#[ cfg( not( docsrs_dummy_build) ) ]
245312#[ cfg( feature = "bios" ) ]
246313async fn build_bios_stage_4 ( out_dir : & Path ) -> PathBuf {
@@ -284,6 +351,26 @@ async fn build_bios_stage_4(out_dir: &Path) -> PathBuf {
284351 convert_elf_to_bin ( elf_path) . await
285352}
286353
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+
287374#[ cfg( not( docsrs_dummy_build) ) ]
288375#[ cfg( feature = "bios" ) ]
289376async fn convert_elf_to_bin ( elf_path : PathBuf ) -> PathBuf {
0 commit comments