Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01b27af

Browse files
Merge pull request #590 from nicholasbishop/bishop-add-unstable-feat
Add `unstable` feature and improve CI for feature flags
2 parents b35ffb8 + 87df1a5 commit 01b27af

File tree

8 files changed

+86
-3
lines changed

8 files changed

+86
-3
lines changed

‎.github/workflows/rust.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,13 @@ jobs:
159159

160160
- name: Build
161161
run: cargo xtask build
162+
163+
build_feature_permutations:
164+
name: Check that the build works for all feature combinations
165+
runs-on: ubuntu-latest
166+
steps:
167+
- name: Checkout sources
168+
uses: actions/checkout@v3
169+
170+
- name: Build
171+
run: cargo xtask build --feature-permutations

‎uefi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ logger = []
1919
# were observed on the VirtualBox UEFI implementation (see uefi-rs#121).
2020
# In those cases, this feature can be excluded by removing the default features.
2121
panic-on-logger-errors = []
22+
unstable = []
2223

2324
[dependencies]
2425
bitflags = "1.3.1"

‎uefi/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
//! is not a high-performance logger.
3333
//! - `panic-on-logger-errors` (enabled by default): Panic if a text
3434
//! output error occurs in the logger.
35+
//! - `unstable`: Enable functionality that depends on [unstable
36+
//! features] in the nightly compiler. Note that currently the `uefi`
37+
//! crate _always_ requires unstable features even if the `unstable`
38+
//! feature is not enabled, but once a couple more required features
39+
//! are stabilized we intend to make the `uefi` crate work on the
40+
//! stable channel by default.
3541
//!
3642
//! The `global_allocator` and `logger` features require special
3743
//! handling to perform initialization and tear-down. The
@@ -48,13 +54,14 @@
4854
//!
4955
//! [`GlobalAlloc`]: alloc::alloc::GlobalAlloc
5056
//! [`uefi-services`]: https://crates.io/crates/uefi-services
57+
//! [unstable features]: https://doc.rust-lang.org/unstable-book/
5158
5259
#![feature(abi_efiapi)]
5360
#![feature(maybe_uninit_slice)]
5461
#![feature(negative_impls)]
5562
#![feature(ptr_metadata)]
56-
#![feature(error_in_core)]
5763
#![cfg_attr(feature = "alloc", feature(vec_into_raw_parts))]
64+
#![cfg_attr(feature = "unstable", feature(error_in_core))]
5865
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
5966
#![no_std]
6067
// Enable some additional warnings and lints.

‎uefi/src/result/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ impl<Data: Debug + Display> Display for Error<Data> {
4646
}
4747
}
4848

49+
#[cfg(feature = "unstable")]
4950
impl<Data: Debug + Display> core::error::Error for Error<Data> {}

‎xtask/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ clap = { version = "4.0.4", features = ["derive"] }
1111
fatfs = { git = "https://github.com/rafalh/rust-fatfs.git", rev = "87fc1ed5074a32b4e0344fcdde77359ef9e75432" }
1212
fs-err = "2.6.0"
1313
heck = "0.4.0"
14+
itertools = "0.10.5"
1415
# Use git as a temporary workaround for https://github.com/rust-osdev/uefi-rs/issues/573.
1516
mbrman = { git = "https://github.com/cecton/mbrman.git", rev = "78565860e55c272488d94480e72a4e2cd159ad8e" }
1617
nix = "0.25.0"

‎xtask/src/cargo.rs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,55 @@ impl Package {
4545

4646
#[derive(Clone, Copy, Debug)]
4747
pub enum Feature {
48-
GlobalAllocator,
48+
// `uefi` features.
4949
Alloc,
50+
GlobalAllocator,
5051
Logger,
52+
PanicOnLoggerErrors,
53+
Unstable,
54+
55+
// `uefi-services` features.
56+
PanicHandler,
57+
Qemu,
58+
ServicesLogger,
5159

60+
// `uefi-test-runner` features.
5261
Ci,
5362
}
5463

5564
impl Feature {
5665
fn as_str(&self) -> &'static str {
5766
match self {
58-
Self::GlobalAllocator => "global_allocator",
5967
Self::Alloc => "alloc",
68+
Self::GlobalAllocator => "global_allocator",
6069
Self::Logger => "logger",
70+
Self::PanicOnLoggerErrors => "panic-on-logger-errors",
71+
Self::Unstable => "unstable",
72+
73+
Self::PanicHandler => "uefi-services/panic_handler",
74+
Self::Qemu => "uefi-services/qemu",
75+
Self::ServicesLogger => "uefi-services/logger",
6176

6277
Self::Ci => "uefi-test-runner/ci",
6378
}
6479
}
6580

81+
/// Get the features for the given package.
82+
pub fn package_features(package: Package) -> Vec<Self> {
83+
match package {
84+
Package::Uefi => vec![
85+
Self::Alloc,
86+
Self::GlobalAllocator,
87+
Self::Logger,
88+
Self::PanicOnLoggerErrors,
89+
Self::Unstable,
90+
],
91+
Package::UefiServices => vec![Self::PanicHandler, Self::Qemu, Self::ServicesLogger],
92+
Package::UefiTestRunner => vec![Self::Ci],
93+
_ => vec![],
94+
}
95+
}
96+
6697
/// Set of features that enables more code in the root uefi crate.
6798
pub fn more_code() -> Vec<Self> {
6899
vec![Self::GlobalAllocator, Self::Alloc, Self::Logger]

‎xtask/src/main.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,39 @@ mod util;
1212
use anyhow::Result;
1313
use cargo::{fix_nested_cargo_env, Cargo, CargoAction, Feature, Package, TargetTypes};
1414
use clap::Parser;
15+
use itertools::Itertools;
1516
use opt::{Action, BuildOpt, ClippyOpt, DocOpt, Opt, QemuOpt};
1617
use std::process::Command;
1718
use tempfile::TempDir;
1819
use util::{command_to_string, run_cmd};
1920

21+
fn build_feature_permutations(opt: &BuildOpt) -> Result<()> {
22+
for package in [Package::Uefi, Package::UefiServices] {
23+
let all_package_features = Feature::package_features(package);
24+
for features in all_package_features.iter().powerset() {
25+
let features = features.iter().map(|f| **f).collect();
26+
27+
let cargo = Cargo {
28+
action: CargoAction::Build,
29+
features,
30+
packages: vec![package],
31+
release: opt.build_mode.release,
32+
target: Some(*opt.target),
33+
warnings_as_errors: true,
34+
target_types: TargetTypes::BinsExamplesLib,
35+
};
36+
run_cmd(cargo.command()?)?;
37+
}
38+
}
39+
40+
Ok(())
41+
}
42+
2043
fn build(opt: &BuildOpt) -> Result<()> {
44+
if opt.feature_permutations {
45+
return build_feature_permutations(opt);
46+
}
47+
2148
let cargo = Cargo {
2249
action: CargoAction::Build,
2350
features: Feature::more_code(),

‎xtask/src/opt.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ pub struct BuildOpt {
6262

6363
#[clap(flatten)]
6464
pub build_mode: BuildModeOpt,
65+
66+
/// Build multiple times to check that different feature
67+
/// combinations work.
68+
#[clap(long, action)]
69+
pub feature_permutations: bool,
6570
}
6671

6772
/// Run clippy on all the packages.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /