Skip to content

Commit ef05e9c

Browse files
committed
Fix docs.rs build by setting env variables on dummy builds too
1 parent 27f52cd commit ef05e9c

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

build.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ fn main() {
88
block_on((uefi_main(), bios_main()).join());
99
}
1010

11-
#[cfg(not(docsrs_dummy_build))]
1211
#[cfg(feature = "bios")]
1312
async fn bios_main() {
1413
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
@@ -17,6 +16,7 @@ async fn bios_main() {
1716
// BIOS crates don't have enough dependencies to utilize all cores on modern
1817
// CPUs. So by running the build commands in parallel, we increase the number
1918
// of utilized cores.)
19+
#[cfg(not(docsrs_dummy_build))]
2020
let (bios_boot_sector_path, bios_stage_2_path, bios_stage_3_path, bios_stage_4_path) = (
2121
build_bios_boot_sector(&out_dir),
2222
build_bios_stage_2(&out_dir),
@@ -25,6 +25,14 @@ async fn bios_main() {
2525
)
2626
.join()
2727
.await;
28+
// dummy implementations because docsrs builds have no network access
29+
#[cfg(docsrs_dummy_build)]
30+
let (bios_boot_sector_path, bios_stage_2_path, bios_stage_3_path, bios_stage_4_path) = (
31+
PathBuf::new(),
32+
PathBuf::new(),
33+
PathBuf::new(),
34+
PathBuf::new(),
35+
);
2836
println!(
2937
"cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}",
3038
bios_boot_sector_path.display()
@@ -43,11 +51,16 @@ async fn bios_main() {
4351
);
4452
}
4553

46-
#[cfg(not(docsrs_dummy_build))]
4754
#[cfg(feature = "uefi")]
4855
async fn uefi_main() {
4956
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
57+
58+
#[cfg(not(docsrs_dummy_build))]
5059
let uefi_path = build_uefi_bootloader(&out_dir).await;
60+
// dummy implementation because docsrs builds have no network access
61+
#[cfg(docsrs_dummy_build)]
62+
let uefi_path = PathBuf::new();
63+
5164
println!(
5265
"cargo:rustc-env=UEFI_BOOTLOADER_PATH={}",
5366
uefi_path.display()
@@ -295,9 +308,3 @@ async fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf {
295308
}
296309
flat_binary_path
297310
}
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

Comments
 (0)