Skip to content
Merged
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
15 changes: 12 additions & 3 deletions uefi/src/helpers/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,25 @@ pub fn disable() {
/// cloud-hypervisor.
///
/// More info: <https://phip1611.de/blog/how-to-use-qemus-debugcon-feature/>
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(all(
any(target_arch = "x86", target_arch = "x86_64"),
feature = "log-debugcon"
))]
#[derive(Copy, Clone, Debug)]
struct DebugconWriter;

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(all(
any(target_arch = "x86", target_arch = "x86_64"),
feature = "log-debugcon"
))]
impl DebugconWriter {
const IO_PORT: u16 = 0xe9;
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(all(
any(target_arch = "x86", target_arch = "x86_64"),
feature = "log-debugcon"
))]
impl core::fmt::Write for DebugconWriter {
fn write_str(&mut self, s: &str) -> fmt::Result {
for &byte in s.as_bytes() {
Expand Down
19 changes: 13 additions & 6 deletions xtask/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub enum Feature {
// `uefi` features.
Alloc,
GlobalAllocator,
LogDebugcon,
Logger,
Unstable,
PanicHandler,
Expand All @@ -68,6 +69,7 @@ impl Feature {
match self {
Self::Alloc => "alloc",
Self::GlobalAllocator => "global_allocator",
Self::LogDebugcon => "log-debugcon",
Self::Logger => "logger",
Self::Unstable => "unstable",
Self::PanicHandler => "panic_handler",
Expand All @@ -88,6 +90,7 @@ impl Feature {
Package::Uefi => vec![
Self::Alloc,
Self::GlobalAllocator,
Self::LogDebugcon,
Self::Logger,
Self::Unstable,
Self::PanicHandler,
Expand All @@ -112,7 +115,7 @@ impl Feature {
/// - `include_unstable` - add all functionality behind the `unstable` feature
/// - `runtime_features` - add all functionality that effect the runtime of Rust
pub fn more_code(include_unstable: bool, runtime_features: bool) -> Vec<Self> {
let mut base_features = vec![Self::Alloc, Self::Logger];
let mut base_features = vec![Self::Alloc, Self::LogDebugcon, Self::Logger];
if include_unstable {
base_features.extend([Self::Unstable])
}
Expand Down Expand Up @@ -293,6 +296,10 @@ impl Cargo {
cmd.arg(sub_action);
}

// Turn off default features so that `--feature-permutations` can test
// with each feature enabled and disabled.
cmd.arg("--no-default-features");

if self.release {
cmd.arg("--release");
}
Expand Down Expand Up @@ -337,19 +344,19 @@ mod tests {
fn test_comma_separated_features() {
assert_eq!(
Feature::comma_separated_string(&Feature::more_code(false, false)),
"alloc,logger"
"alloc,log-debugcon,logger"
);
assert_eq!(
Feature::comma_separated_string(&Feature::more_code(false, true)),
"alloc,logger,global_allocator"
"alloc,log-debugcon,logger,global_allocator"
);
assert_eq!(
Feature::comma_separated_string(&Feature::more_code(true, false)),
"alloc,logger,unstable"
"alloc,log-debugcon,logger,unstable"
);
assert_eq!(
Feature::comma_separated_string(&Feature::more_code(true, true)),
"alloc,logger,unstable,global_allocator"
"alloc,log-debugcon,logger,unstable,global_allocator"
);
}

Expand Down Expand Up @@ -380,7 +387,7 @@ mod tests {
};
assert_eq!(
command_to_string(&cargo.command().unwrap()),
"RUSTDOCFLAGS=-Dwarnings cargo doc --package uefi --package xtask --features global_allocator --no-deps --document-private-items --open"
"RUSTDOCFLAGS=-Dwarnings cargo doc --no-default-features --package uefi --package xtask --features global_allocator --no-deps --document-private-items --open"
);
}
}