Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ kernel-x86_64.elf: $(X86ASM) FORCE
python3 scripts/embed_debug_info.py $@

x86_64_boot.img: kernel-x86_64.elf
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk -- --kernel $< --output $@
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk --no-default-features --features bios -- --kernel $< --output $@
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This target now relies on BootType's CLI default to select BIOS (since --boot-type bios is not passed). To make the build resilient to future changes in the Rust-side defaulting logic (or feature defaults), consider passing --boot-type bios explicitly here, similar to the UEFI target.

Suggested change
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk --no-default-features --features bios -- --kernel $< --output $@
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk --no-default-features --features bios -- --kernel $< --output $@ --boot-type bios

Copilot uses AI. Check for mistakes.

x86_64_uefi.img: kernel-x86_64.elf
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk -- --kernel $< --output $@ --pxe x86_64_uefi_pxe_boot --boot-type uefi
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk --no-default-features --features uefi -- --kernel $< --output $@ --pxe x86_64_uefi_pxe_boot --boot-type uefi

$(X86ASM): FORCE
$(MAKE) -C $@
Expand Down
1 change: 0 additions & 1 deletion mdbook/book.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[book]
authors = ["Yuuki Takano"]
language = "en"
multilingual = false
src = "src"
title = "Awkernel"

Expand Down
7 changes: 6 additions & 1 deletion x86bootdisk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["bios", "uefi"]
bios = ["bootloader/bios"]
uefi = ["bootloader/uefi"]
Comment on lines +8 to +11
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description suggests isolating BIOS vs UEFI via Cargo features to avoid problematic build paths, but default = ["bios", "uefi"] still enables (and compiles) both by default. If the intent is to avoid BIOS-related build failures unless explicitly requested, consider making the default feature set [] or ['uefi'] and requiring callers (e.g., the Makefile) to opt into bios explicitly.

Copilot uses AI. Check for mistakes.

[dependencies]
bootloader = "0.11"
bootloader = { version = "0.11", default-features = false }
ovmf-prebuilt = "0.2"
clap = { version = "4.2", features = ["derive"] }
home = "0.5"
27 changes: 25 additions & 2 deletions x86bootdisk/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
use bootloader::{BiosBoot, UefiBoot};
use clap::Parser;
use ovmf_prebuilt::{Prebuilt, Source};
use std::{fs::File, io::Write, path::Path};

#[cfg(not(any(feature = "bios", feature = "uefi")))]
compile_error!("At least one of the `bios` or `uefi` features must be enabled.");

#[cfg(feature = "bios")]
use bootloader::BiosBoot;
#[cfg(feature = "uefi")]
use bootloader::UefiBoot;

Comment on lines +8 to +12
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new feature-gated enum variants and Default impl, building this crate with --no-default-features and without selecting either bios or uefi will fail with confusing compiler errors (e.g., missing Default::default impl items / empty BootType). Consider adding an explicit #[cfg(not(any(feature = "bios", feature = "uefi")))] compile_error!(...) guard so misconfigured builds fail with a clear message.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a compile_error! guard in commit d69ffdc so that builds with --no-default-features and neither bios nor uefi selected will fail with a clear message:

#[cfg(not(any(feature = "bios", feature = "uefi")))]
compile_error!("At least one of the `bios` or `uefi` features must be enabled.");

#[derive(Debug, clap::ValueEnum, Clone)]
enum BootType {
#[cfg(feature = "uefi")]
Uefi,
#[cfg(feature = "bios")]
Bios,
}

impl Default for BootType {
#[cfg(feature = "bios")]
fn default() -> Self {
Self::Bios
}

#[cfg(all(not(feature = "bios"), feature = "uefi"))]
fn default() -> Self {
Self::Uefi
}
}

/// Simple program to greet a person
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
Expand All @@ -26,7 +47,7 @@ struct Args {
pxe: String,

/// uefi or bios.
#[arg(value_enum, long, default_value_t = BootType::Bios)]
#[arg(value_enum, long, default_value_t = BootType::default())]
boot_type: BootType,
}

Expand All @@ -38,6 +59,7 @@ fn main() {
let pxe_path = Path::new(&args.pxe);

match args.boot_type {
#[cfg(feature = "uefi")]
BootType::Uefi => {
let uefi = UefiBoot::new(kernel_path);
uefi.create_disk_image(output_path).unwrap();
Expand All @@ -61,6 +83,7 @@ fn main() {
output_path.display()
)
}
#[cfg(feature = "bios")]
BootType::Bios => {
BiosBoot::new(kernel_path)
.create_disk_image(output_path)
Expand Down