Skip to content

Commit 8d0937a

Browse files
authored
Merge pull request #1389 from nicholasbishop/bishop-debugcon-fixes
Fix unused warnings if log-debugcon is not enabled
2 parents 121aa93 + 8c51602 commit 8d0937a

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

uefi/src/helpers/logger.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,25 @@ pub fn disable() {
4646
/// cloud-hypervisor.
4747
///
4848
/// More info: <https://phip1611.de/blog/how-to-use-qemus-debugcon-feature/>
49-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
49+
#[cfg(all(
50+
any(target_arch = "x86", target_arch = "x86_64"),
51+
feature = "log-debugcon"
52+
))]
5053
#[derive(Copy, Clone, Debug)]
5154
struct DebugconWriter;
5255

53-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
56+
#[cfg(all(
57+
any(target_arch = "x86", target_arch = "x86_64"),
58+
feature = "log-debugcon"
59+
))]
5460
impl DebugconWriter {
5561
const IO_PORT: u16 = 0xe9;
5662
}
5763

58-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
64+
#[cfg(all(
65+
any(target_arch = "x86", target_arch = "x86_64"),
66+
feature = "log-debugcon"
67+
))]
5968
impl core::fmt::Write for DebugconWriter {
6069
fn write_str(&mut self, s: &str) -> fmt::Result {
6170
for &byte in s.as_bytes() {

xtask/src/cargo.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub enum Feature {
4949
// `uefi` features.
5050
Alloc,
5151
GlobalAllocator,
52+
LogDebugcon,
5253
Logger,
5354
Unstable,
5455
PanicHandler,
@@ -68,6 +69,7 @@ impl Feature {
6869
match self {
6970
Self::Alloc => "alloc",
7071
Self::GlobalAllocator => "global_allocator",
72+
Self::LogDebugcon => "log-debugcon",
7173
Self::Logger => "logger",
7274
Self::Unstable => "unstable",
7375
Self::PanicHandler => "panic_handler",
@@ -88,6 +90,7 @@ impl Feature {
8890
Package::Uefi => vec![
8991
Self::Alloc,
9092
Self::GlobalAllocator,
93+
Self::LogDebugcon,
9194
Self::Logger,
9295
Self::Unstable,
9396
Self::PanicHandler,
@@ -112,7 +115,7 @@ impl Feature {
112115
/// - `include_unstable` - add all functionality behind the `unstable` feature
113116
/// - `runtime_features` - add all functionality that effect the runtime of Rust
114117
pub fn more_code(include_unstable: bool, runtime_features: bool) -> Vec<Self> {
115-
let mut base_features = vec![Self::Alloc, Self::Logger];
118+
let mut base_features = vec![Self::Alloc, Self::LogDebugcon, Self::Logger];
116119
if include_unstable {
117120
base_features.extend([Self::Unstable])
118121
}
@@ -293,6 +296,10 @@ impl Cargo {
293296
cmd.arg(sub_action);
294297
}
295298

299+
// Turn off default features so that `--feature-permutations` can test
300+
// with each feature enabled and disabled.
301+
cmd.arg("--no-default-features");
302+
296303
if self.release {
297304
cmd.arg("--release");
298305
}
@@ -337,19 +344,19 @@ mod tests {
337344
fn test_comma_separated_features() {
338345
assert_eq!(
339346
Feature::comma_separated_string(&Feature::more_code(false, false)),
340-
"alloc,logger"
347+
"alloc,log-debugcon,logger"
341348
);
342349
assert_eq!(
343350
Feature::comma_separated_string(&Feature::more_code(false, true)),
344-
"alloc,logger,global_allocator"
351+
"alloc,log-debugcon,logger,global_allocator"
345352
);
346353
assert_eq!(
347354
Feature::comma_separated_string(&Feature::more_code(true, false)),
348-
"alloc,logger,unstable"
355+
"alloc,log-debugcon,logger,unstable"
349356
);
350357
assert_eq!(
351358
Feature::comma_separated_string(&Feature::more_code(true, true)),
352-
"alloc,logger,unstable,global_allocator"
359+
"alloc,log-debugcon,logger,unstable,global_allocator"
353360
);
354361
}
355362

@@ -380,7 +387,7 @@ mod tests {
380387
};
381388
assert_eq!(
382389
command_to_string(&cargo.command().unwrap()),
383-
"RUSTDOCFLAGS=-Dwarnings cargo doc --package uefi --package xtask --features global_allocator --no-deps --document-private-items --open"
390+
"RUSTDOCFLAGS=-Dwarnings cargo doc --no-default-features --package uefi --package xtask --features global_allocator --no-deps --document-private-items --open"
384391
);
385392
}
386393
}

0 commit comments

Comments
 (0)