build: check features in main instead of conditional definition
@@ -8,12 +8,17 @@ const BOOTLOADER_VERSION: &str = env!("CARGO_PKG_VERSION");
fn main() {
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
+ #[cfg(feature = "uefi")]
+ {
let uefi_path = build_uefi_bootloader(&out_dir);
println!(
"cargo:rustc-env=UEFI_BOOTLOADER_PATH={}",
uefi_path.display()
);
+ }
+ #[cfg(feature = "bios")]
+ {
let bios_boot_sector_path = build_bios_boot_sector(&out_dir);
println!(
"cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}",
@@ -37,6 +42,7 @@ fn main() {
bios_stage_4_path.display()
);
}
+}
#[cfg(not(docsrs_dummy_build))]
#[cfg(feature = "uefi")]
@@ -270,23 +276,23 @@ fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf {
// dummy implementations because docsrs builds have no network access
-#[cfg(any(docsrs_dummy_build, not(feature = "uefi")))]
+#[cfg(docsrs_dummy_build)]
fn build_uefi_bootloader(_out_dir: &Path) -> PathBuf {
PathBuf::new()
}
-#[cfg(any(docsrs_dummy_build, not(feature = "bios")))]
+#[cfg(docsrs_dummy_build)]
fn build_bios_boot_sector(_out_dir: &Path) -> PathBuf {
PathBuf::new()
}
-#[cfg(any(docsrs_dummy_build, not(feature = "bios")))]
+#[cfg(docsrs_dummy_build)]
fn build_bios_stage_2(_out_dir: &Path) -> PathBuf {
PathBuf::new()
}
-#[cfg(any(docsrs_dummy_build, not(feature = "bios")))]
+#[cfg(docsrs_dummy_build)]
fn build_bios_stage_3(_out_dir: &Path) -> PathBuf {
PathBuf::new()
}
-#[cfg(any(docsrs_dummy_build, not(feature = "bios")))]
+#[cfg(docsrs_dummy_build)]
fn build_bios_stage_4(_out_dir: &Path) -> PathBuf {
PathBuf::new()
}
