Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cargo features to build only UEFI or BIOS bootloader #287

Closed
phil-opp opened this issue Nov 27, 2022 · 3 comments · Fixed by #304
Closed

Add cargo features to build only UEFI or BIOS bootloader #287

phil-opp opened this issue Nov 27, 2022 · 3 comments · Fixed by #304
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@phil-opp
Copy link
Member

Some projects only need one build standard. So we should allow to build only the UEFI or the BIOS bootloader to make it possible to reduce compile times. To achieve this, we could add new uefi and bios cargo features, which are both enabled by default

Proposed by @AviiNL on gitter.

@phil-opp phil-opp added enhancement New feature or request good first issue Good for newcomers labels Nov 27, 2022
@AlexJMohr
Copy link
Contributor

AlexJMohr commented Dec 29, 2022

Anyone working on this? I'd like to make an attempt with some guidance.

Obviously Cargo.toml needs something like this:

[features]
default = ["bios", "uefi"]
bios = []
uefi = []

And I was thinking I'd add add this to src/lib.rs

#[cfg(feature = "bios")]
mod bios; // src/bios/mod.rs
#[cfg(feature = "bios")]
pub use bios::BiosBoot;
#[cfg(feature = "uefi")]
mod uefi; // src/uefi/mod.rs
#[cfg(feature = "uefi")]
pub use uefi::UefiBoot;

Move gpt.rs to uefi/gpt.rs, move mbr.rs to bios/mbr.rs

@phil-opp
Copy link
Member Author

phil-opp commented Jan 2, 2023

Thanks, your approach looks good! The second step is then to update the build.rs, where we implement a hacky workaround for building the dependencies (until artifact dependencies are stable in cargo). I think it should be enough to add a #[cfg(feature = "uefi")] { ... } block around the build_uefi_bootloader call and a #[cfg(feature = "bios")] { ... } block around the build_bios_* calls in the main function. I'm happy to help you with the details, just ping me if you have any questions.

@jasoncouture
Copy link
Contributor

See jasoncouture#1 ( #313 ) and let me know what you think @AlexJMohr

phil-opp added a commit that referenced this issue Jan 9, 2023
 Add bios and uefi cargo features (closes #287)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
3 participants