diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58816d1b..43a57e33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,10 @@ jobs: - uses: r7kamura/rust-problem-matchers@v1.1.0 - name: "Run `cargo check`" run: cargo check --all-targets --all + - name: "Check docs.rs build" + run: cargo check + env: + RUSTFLAGS: "--cfg docsrs_dummy_build" test: name: Test @@ -109,7 +113,7 @@ jobs: run: cargo semver-checks check-release typos: - name: Check spelling - runs-on: ubuntu-latest - steps: - - uses: crate-ci/typos@v1.0.4 + name: Check spelling + runs-on: ubuntu-latest + steps: + - uses: crate-ci/typos@v1.0.4 diff --git a/build.rs b/build.rs index 275fbdea..d40373d4 100644 --- a/build.rs +++ b/build.rs @@ -5,10 +5,14 @@ use std::path::{Path, PathBuf}; const BOOTLOADER_VERSION: &str = env!("CARGO_PKG_VERSION"); fn main() { + #[cfg(not(feature = "uefi"))] + async fn uefi_main() {} + #[cfg(not(feature = "bios"))] + async fn bios_main() {} + block_on((uefi_main(), bios_main()).join()); } -#[cfg(not(docsrs_dummy_build))] #[cfg(feature = "bios")] async fn bios_main() { let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); @@ -17,6 +21,7 @@ async fn bios_main() { // BIOS crates don't have enough dependencies to utilize all cores on modern // CPUs. So by running the build commands in parallel, we increase the number // of utilized cores.) + #[cfg(not(docsrs_dummy_build))] let (bios_boot_sector_path, bios_stage_2_path, bios_stage_3_path, bios_stage_4_path) = ( build_bios_boot_sector(&out_dir), build_bios_stage_2(&out_dir), @@ -25,6 +30,14 @@ async fn bios_main() { ) .join() .await; + // dummy implementations because docsrs builds have no network access + #[cfg(docsrs_dummy_build)] + let (bios_boot_sector_path, bios_stage_2_path, bios_stage_3_path, bios_stage_4_path) = ( + PathBuf::new(), + PathBuf::new(), + PathBuf::new(), + PathBuf::new(), + ); println!( "cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}", bios_boot_sector_path.display() @@ -43,11 +56,16 @@ async fn bios_main() { ); } -#[cfg(not(docsrs_dummy_build))] #[cfg(feature = "uefi")] async fn uefi_main() { let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); + + #[cfg(not(docsrs_dummy_build))] let uefi_path = build_uefi_bootloader(&out_dir).await; + // dummy implementation because docsrs builds have no network access + #[cfg(docsrs_dummy_build)] + let uefi_path = PathBuf::new(); + println!( "cargo:rustc-env=UEFI_BOOTLOADER_PATH={}", uefi_path.display() @@ -295,9 +313,3 @@ async fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf { } flat_binary_path } - -// dummy implementations because docsrs builds have no network access -#[cfg(any(not(feature = "bios"), docsrs_dummy_build))] -async fn bios_main() {} -#[cfg(any(not(feature = "uefi"), docsrs_dummy_build))] -async fn uefi_main() {}