@@ -5,10 +5,14 @@ use std::path::{Path, PathBuf};
55const BOOTLOADER_VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
66
77fn main ( ) {
8+ #[ cfg( not( feature = "uefi" ) ) ]
9+ async fn uefi_main ( ) { }
10+ #[ cfg( not( feature = "bios" ) ) ]
11+ async fn bios_main ( ) { }
12+
813 block_on ( ( uefi_main ( ) , bios_main ( ) ) . join ( ) ) ;
914}
1015
11- #[ cfg( not( docsrs_dummy_build) ) ]
1216#[ cfg( feature = "bios" ) ]
1317async fn bios_main ( ) {
1418 let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
@@ -17,6 +21,7 @@ async fn bios_main() {
1721 // BIOS crates don't have enough dependencies to utilize all cores on modern
1822 // CPUs. So by running the build commands in parallel, we increase the number
1923 // of utilized cores.)
24+ #[ cfg( not( docsrs_dummy_build) ) ]
2025 let ( bios_boot_sector_path, bios_stage_2_path, bios_stage_3_path, bios_stage_4_path) = (
2126 build_bios_boot_sector ( & out_dir) ,
2227 build_bios_stage_2 ( & out_dir) ,
@@ -25,6 +30,14 @@ async fn bios_main() {
2530 )
2631 . join ( )
2732 . 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+ ) ;
2841 println ! (
2942 "cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}" ,
3043 bios_boot_sector_path. display( )
@@ -43,11 +56,16 @@ async fn bios_main() {
4356 ) ;
4457}
4558
46- #[ cfg( not( docsrs_dummy_build) ) ]
4759#[ cfg( feature = "uefi" ) ]
4860async fn uefi_main ( ) {
4961 let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
62+
63+ #[ cfg( not( docsrs_dummy_build) ) ]
5064 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+
5169 println ! (
5270 "cargo:rustc-env=UEFI_BOOTLOADER_PATH={}" ,
5371 uefi_path. display( )
@@ -295,9 +313,3 @@ async fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf {
295313 }
296314 flat_binary_path
297315}
298-
299- // dummy implementations because docsrs builds have no network access
300- #[ cfg( any( not( feature = "bios" ) , docsrs_dummy_build) ) ]
301- async fn bios_main ( ) { }
302- #[ cfg( any( not( feature = "uefi" ) , docsrs_dummy_build) ) ]
303- async fn uefi_main ( ) { }
0 commit comments