mirror of
https://github.com/rust-osdev/uefi-rs
synced 2026-08-26 18:26:05 -04:00
Add rust-toolchain.toml
Add a `rust-toolchain.toml` file that specifies the channel and components needed to build uefi-rs. See https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file for documentation of the `rust-toolchain.toml` format. Remove the `--toolchain` option from `xtask`, as using this file is a simpler alternative. Also remove the instructions for installing the nightly toolchain from the readme, as `rustup` will do this automatically now. The template application has been updated to add a `rust-toolchain.toml`, and `BUILDING.md` has been updated to mention it as well. The `toolchain` action previously used in the CI is unmaintained and doesn't understand `rust-toolchain.toml` (it does understand the older `rust-toolchain` file, but that doesn't allow for including required components). Since the runners come with rustup already installed, we don't actually need a complex action here anyway, so just remove those sections entirely. A few jobs need extra components installed, do that with `rustup component add`. Note that this change will also cause `xtask` itself to be built with nightly. That should generally be fine, we only had it using stable because of https://github.com/rust-osdev/uefi-rs/issues/397, and in the future we can easily temporarily pin to a non-current nightly if a bug occurs with an `xtask` dependency again. Fixes https://github.com/rust-osdev/uefi-rs/issues/498
This commit is contained in:
parent
55e6896469
commit
26be8902f7
9 changed files with 45 additions and 173 deletions
110
.github/workflows/rust.yml
vendored
110
.github/workflows/rust.yml
vendored
|
|
@ -28,18 +28,6 @@ jobs:
|
|||
sudo apt-get update
|
||||
sudo apt-get install qemu-system-arm qemu-efi-aarch64 -y
|
||||
|
||||
- name: Install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Install latest nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: rust-src
|
||||
# TODO: cache Rust binaries
|
||||
|
||||
- name: Build
|
||||
run: cargo xtask build --target aarch64
|
||||
|
||||
|
|
@ -59,18 +47,6 @@ jobs:
|
|||
sudo apt-get update
|
||||
sudo apt-get install qemu-system-x86 ovmf -y
|
||||
|
||||
- name: Install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Install latest nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: rust-src
|
||||
# TODO: cache Rust binaries
|
||||
|
||||
- name: Build
|
||||
run: cargo xtask build --target x86_64
|
||||
|
||||
|
|
@ -106,18 +82,6 @@ jobs:
|
|||
curl -o OVMF32_CODE.fd https://raw.githubusercontent.com/retrage/edk2-nightly/${EDK2_NIGHTLY_COMMIT}/bin/RELEASEIa32_OVMF_CODE.fd
|
||||
curl -o OVMF32_VARS.fd https://raw.githubusercontent.com/retrage/edk2-nightly/${EDK2_NIGHTLY_COMMIT}/bin/RELEASEIa32_OVMF_VARS.fd
|
||||
|
||||
- name: Install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Install latest nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: rust-src
|
||||
# TODO: cache Rust binaries
|
||||
|
||||
- name: Build
|
||||
run: cargo xtask build --target ia32
|
||||
|
||||
|
|
@ -132,18 +96,6 @@ jobs:
|
|||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Install latest nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
components: rust-src
|
||||
|
||||
- name: Run cargo test
|
||||
run: cargo xtask test
|
||||
|
||||
|
|
@ -154,26 +106,15 @@ jobs:
|
|||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Install latest nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
components: rustfmt, clippy, rust-src
|
||||
|
||||
- name: Run cargo fmt
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
run: |
|
||||
rustup component add rustfmt
|
||||
cargo fmt --all -- --check
|
||||
|
||||
- name: Run clippy
|
||||
run: cargo xtask clippy --warnings-as-errors
|
||||
run: |
|
||||
rustup component add clippy
|
||||
cargo xtask clippy --warnings-as-errors
|
||||
|
||||
- name: Run cargo doc
|
||||
run: cargo xtask doc --warnings-as-errors
|
||||
|
|
@ -185,20 +126,10 @@ jobs:
|
|||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Install latest nightly toolchain that includes Miri
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
components: miri
|
||||
|
||||
- name: Run miri
|
||||
run: cargo xtask miri
|
||||
run: |
|
||||
rustup component add miri
|
||||
cargo xtask miri
|
||||
|
||||
# This job tests that the template app builds successfully with the
|
||||
# released versions of the libraries on crates.io.
|
||||
|
|
@ -214,17 +145,6 @@ jobs:
|
|||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Install latest nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: rust-src
|
||||
|
||||
- name: Build
|
||||
run: cargo xtask test-latest-release
|
||||
|
||||
|
|
@ -235,17 +155,5 @@ jobs:
|
|||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Install latest nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
components: rust-src
|
||||
|
||||
- name: Build
|
||||
run: cargo xtask build
|
||||
|
|
|
|||
30
BUILDING.md
30
BUILDING.md
|
|
@ -13,25 +13,31 @@ targets.
|
|||
[`i686-unknown-uefi`]: https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_target/src/spec/i686_unknown_uefi.rs
|
||||
[`x86_64-unknown-uefi`]: https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_target/src/spec/x86_64_unknown_uefi.rs
|
||||
|
||||
## Building
|
||||
## Building for a UEFI target
|
||||
|
||||
- Install a `nightly` version of the Rust [toolchain](https://rust-lang.github.io/rustup/concepts/toolchains.html):
|
||||
For instructions on building the `uefi-rs` crates, see the
|
||||
[README](README.md). This section is for building your own crates,
|
||||
outside of the `uefi-rs` repo.
|
||||
|
||||
`rustup toolchain install nightly`
|
||||
- Install a `nightly` version of the Rust [toolchain] and include the
|
||||
`rust-src` [component]. The easiest way to do this is with a
|
||||
`rust-toolchain.toml` file, for example:
|
||||
|
||||
```toml
|
||||
[toolchain]
|
||||
channel = "nightly"
|
||||
components = ["rust-src"]
|
||||
```
|
||||
|
||||
It is not currently possible to build the core crate with a stable version of the Rust compiler.
|
||||
- Build the crate:
|
||||
|
||||
- You need to add the `rust-src` toolchain [component](https://rust-lang.github.io/rustup/concepts/components.html)
|
||||
(if it's not already installed), which Cargo will use to build the core crates for the UEFI target:
|
||||
|
||||
`rustup component add --toolchain nightly rust-src`
|
||||
|
||||
- Build this crate using the `nightly` toolchain:
|
||||
|
||||
`cargo +nightly build --target x86_64-unknown-uefi`.
|
||||
`cargo build --target x86_64-unknown-uefi`.
|
||||
|
||||
- The `target` directory will contain a `x86_64-unknown-uefi` subdirectory,
|
||||
where you will find a `<crate name>.efi` file - a normal UEFI executable.
|
||||
|
||||
[toolchain]: https://rust-lang.github.io/rustup/concepts/toolchains.html
|
||||
[component]: https://rust-lang.github.io/rustup/concepts/components.html
|
||||
|
||||
## Running
|
||||
|
||||
|
|
|
|||
|
|
@ -63,12 +63,6 @@ the [UEFI specification][spec] for detailed information.
|
|||
|
||||
## Building and testing uefi-rs
|
||||
|
||||
Install the `nightly` version of Rust and the `rust-src` component:
|
||||
```
|
||||
rustup toolchain install nightly
|
||||
rustup component add --toolchain nightly rust-src
|
||||
```
|
||||
|
||||
Use the `cargo xtask` command to build and test the crate.
|
||||
|
||||
Available commands:
|
||||
|
|
|
|||
7
rust-toolchain.toml
Normal file
7
rust-toolchain.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[toolchain]
|
||||
# Nightly is required due to use of unstable features.
|
||||
channel = "nightly"
|
||||
|
||||
# Install the `rust-src` component so that `-Zbuild-std` works. This in
|
||||
# addition to the components included in the default profile.
|
||||
components = ["rust-src"]
|
||||
|
|
@ -8,7 +8,8 @@ how to build and run a UEFI application developed using `uefi-rs`.
|
|||
|
||||
## File structure
|
||||
|
||||
- [`.cargo/config`](./.cargo/config) file sets some `build-std` options.
|
||||
- [`.cargo/config`](./.cargo/config) sets some `build-std` options.
|
||||
- [`rust-toolchain.toml`](rust-toolchain.toml) sets the nightly channel.
|
||||
- [`Cargo.toml`](./Cargo.toml) shows the necessary dependencies.
|
||||
- [`src/main.rs`](./src/main.rs) has a minimal entry point that
|
||||
initializes the `uefi-services` crate and exits successfully.
|
||||
|
|
|
|||
3
template/rust-toolchain.toml
Normal file
3
template/rust-toolchain.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[toolchain]
|
||||
channel = "nightly"
|
||||
components = ["rust-src"]
|
||||
|
|
@ -118,7 +118,6 @@ pub fn fix_nested_cargo_env(cmd: &mut Command) {
|
|||
pub struct Cargo {
|
||||
pub action: CargoAction,
|
||||
pub features: Vec<Feature>,
|
||||
pub toolchain: Option<String>,
|
||||
pub packages: Vec<Package>,
|
||||
pub release: bool,
|
||||
pub target: Option<UefiArch>,
|
||||
|
|
@ -131,10 +130,6 @@ impl Cargo {
|
|||
|
||||
fix_nested_cargo_env(&mut cmd);
|
||||
|
||||
if let Some(toolchain) = &self.toolchain {
|
||||
cmd.arg(&format!("+{}", toolchain));
|
||||
}
|
||||
|
||||
let action;
|
||||
let mut sub_action = None;
|
||||
let mut extra_args: Vec<&str> = Vec::new();
|
||||
|
|
@ -239,7 +234,6 @@ mod tests {
|
|||
let cargo = Cargo {
|
||||
action: CargoAction::Doc { open: true },
|
||||
features: vec![Feature::Alloc],
|
||||
toolchain: Some("nightly".into()),
|
||||
packages: vec![Package::Uefi, Package::Xtask],
|
||||
release: false,
|
||||
target: None,
|
||||
|
|
@ -247,7 +241,7 @@ mod tests {
|
|||
};
|
||||
assert_eq!(
|
||||
command_to_string(&cargo.command().unwrap()),
|
||||
"RUSTDOCFLAGS=-Dwarnings cargo +nightly doc --package uefi --package xtask --features alloc --open"
|
||||
"RUSTDOCFLAGS=-Dwarnings cargo doc --package uefi --package xtask --features alloc --open"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,18 +11,15 @@ mod util;
|
|||
use anyhow::Result;
|
||||
use cargo::{fix_nested_cargo_env, Cargo, CargoAction, Feature, Package};
|
||||
use clap::Parser;
|
||||
use opt::{Action, BuildOpt, ClippyOpt, DocOpt, MiriOpt, Opt, QemuOpt};
|
||||
use opt::{Action, BuildOpt, ClippyOpt, DocOpt, Opt, QemuOpt};
|
||||
use std::process::Command;
|
||||
use tempfile::TempDir;
|
||||
use util::{command_to_string, run_cmd};
|
||||
|
||||
const NIGHTLY: &str = "nightly";
|
||||
|
||||
fn build(opt: &BuildOpt) -> Result<()> {
|
||||
let cargo = Cargo {
|
||||
action: CargoAction::Build,
|
||||
features: Feature::more_code(),
|
||||
toolchain: opt.toolchain.or(NIGHTLY),
|
||||
packages: Package::all_except_xtask(),
|
||||
release: opt.build_mode.release,
|
||||
target: Some(*opt.target),
|
||||
|
|
@ -36,7 +33,6 @@ fn clippy(opt: &ClippyOpt) -> Result<()> {
|
|||
let cargo = Cargo {
|
||||
action: CargoAction::Clippy,
|
||||
features: Feature::more_code(),
|
||||
toolchain: opt.toolchain.or(NIGHTLY),
|
||||
packages: Package::all_except_xtask(),
|
||||
release: false,
|
||||
target: Some(*opt.target),
|
||||
|
|
@ -48,7 +44,6 @@ fn clippy(opt: &ClippyOpt) -> Result<()> {
|
|||
let cargo = Cargo {
|
||||
action: CargoAction::Clippy,
|
||||
features: Vec::new(),
|
||||
toolchain: None,
|
||||
packages: vec![Package::Xtask],
|
||||
release: false,
|
||||
target: None,
|
||||
|
|
@ -62,7 +57,6 @@ fn doc(opt: &DocOpt) -> Result<()> {
|
|||
let cargo = Cargo {
|
||||
action: CargoAction::Doc { open: opt.open },
|
||||
features: Feature::more_code(),
|
||||
toolchain: opt.toolchain.or(NIGHTLY),
|
||||
packages: Package::published(),
|
||||
release: false,
|
||||
target: None,
|
||||
|
|
@ -72,11 +66,10 @@ fn doc(opt: &DocOpt) -> Result<()> {
|
|||
}
|
||||
|
||||
/// Run unit tests and doctests under Miri.
|
||||
fn run_miri(opt: &MiriOpt) -> Result<()> {
|
||||
fn run_miri() -> Result<()> {
|
||||
let cargo = Cargo {
|
||||
action: CargoAction::Miri,
|
||||
features: [Feature::Exts].into(),
|
||||
toolchain: opt.toolchain.or(NIGHTLY),
|
||||
packages: [Package::Uefi].into(),
|
||||
release: false,
|
||||
target: None,
|
||||
|
|
@ -100,7 +93,6 @@ fn run_vm_tests(opt: &QemuOpt) -> Result<()> {
|
|||
let cargo = Cargo {
|
||||
action: CargoAction::Build,
|
||||
features,
|
||||
toolchain: opt.toolchain.or(NIGHTLY),
|
||||
packages: vec![Package::UefiTestRunner],
|
||||
release: opt.build_mode.release,
|
||||
target: Some(*opt.target),
|
||||
|
|
@ -119,7 +111,6 @@ fn run_host_tests() -> Result<()> {
|
|||
let cargo = Cargo {
|
||||
action: CargoAction::Test,
|
||||
features: Vec::new(),
|
||||
toolchain: None,
|
||||
packages: vec![Package::Xtask],
|
||||
release: false,
|
||||
target: None,
|
||||
|
|
@ -131,7 +122,6 @@ fn run_host_tests() -> Result<()> {
|
|||
let cargo = Cargo {
|
||||
action: CargoAction::Test,
|
||||
features: vec![Feature::Exts],
|
||||
toolchain: Some(NIGHTLY.into()),
|
||||
// Don't test uefi-services (or the packages that depend on it)
|
||||
// as it has lang items that conflict with `std`.
|
||||
packages: vec![Package::Uefi, Package::UefiMacros],
|
||||
|
|
@ -173,7 +163,7 @@ fn test_latest_release() -> Result<()> {
|
|||
let mut build_cmd = Command::new("cargo");
|
||||
fix_nested_cargo_env(&mut build_cmd);
|
||||
build_cmd
|
||||
.args(&["+nightly", "build", "--target", "x86_64-unknown-uefi"])
|
||||
.args(&["build", "--target", "x86_64-unknown-uefi"])
|
||||
.current_dir(tmp_dir.join("template"));
|
||||
|
||||
// Check that the command is indeed in BUILDING.md, then verify the
|
||||
|
|
@ -190,7 +180,7 @@ fn main() -> Result<()> {
|
|||
Action::Build(build_opt) => build(build_opt),
|
||||
Action::Clippy(clippy_opt) => clippy(clippy_opt),
|
||||
Action::Doc(doc_opt) => doc(doc_opt),
|
||||
Action::Miri(miri_opt) => run_miri(miri_opt),
|
||||
Action::Miri(_) => run_miri(),
|
||||
Action::Run(qemu_opt) => run_vm_tests(qemu_opt),
|
||||
Action::Test(_) => run_host_tests(),
|
||||
Action::TestLatestRelease(_) => test_latest_release(),
|
||||
|
|
|
|||
|
|
@ -21,22 +21,6 @@ impl Deref for TargetOpt {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct ToolchainOpt {
|
||||
/// Rust toolchain to use, e.g. "nightly-2022-02-24".
|
||||
#[clap(long, action)]
|
||||
toolchain: Option<String>,
|
||||
}
|
||||
|
||||
impl ToolchainOpt {
|
||||
/// Get the toolchain arg if set, otherwise use `default_toolchain`.
|
||||
pub fn or(&self, default_toolchain: &str) -> Option<String> {
|
||||
self.toolchain
|
||||
.clone()
|
||||
.or_else(|| Some(default_toolchain.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct BuildModeOpt {
|
||||
/// Build in release mode.
|
||||
|
|
@ -75,9 +59,6 @@ pub struct BuildOpt {
|
|||
#[clap(flatten)]
|
||||
pub target: TargetOpt,
|
||||
|
||||
#[clap(flatten)]
|
||||
pub toolchain: ToolchainOpt,
|
||||
|
||||
#[clap(flatten)]
|
||||
pub build_mode: BuildModeOpt,
|
||||
}
|
||||
|
|
@ -88,9 +69,6 @@ pub struct ClippyOpt {
|
|||
#[clap(flatten)]
|
||||
pub target: TargetOpt,
|
||||
|
||||
#[clap(flatten)]
|
||||
pub toolchain: ToolchainOpt,
|
||||
|
||||
#[clap(flatten)]
|
||||
pub warning: WarningOpt,
|
||||
}
|
||||
|
|
@ -98,9 +76,6 @@ pub struct ClippyOpt {
|
|||
/// Build the docs for the uefi packages.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct DocOpt {
|
||||
#[clap(flatten)]
|
||||
pub toolchain: ToolchainOpt,
|
||||
|
||||
/// Open the docs in a browser.
|
||||
#[clap(long, action)]
|
||||
pub open: bool,
|
||||
|
|
@ -111,10 +86,7 @@ pub struct DocOpt {
|
|||
|
||||
/// Run unit tests and doctests under Miri.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct MiriOpt {
|
||||
#[clap(flatten)]
|
||||
pub toolchain: ToolchainOpt,
|
||||
}
|
||||
pub struct MiriOpt {}
|
||||
|
||||
/// Build uefi-test-runner and run it in QEMU.
|
||||
#[derive(Debug, Parser)]
|
||||
|
|
@ -122,9 +94,6 @@ pub struct QemuOpt {
|
|||
#[clap(flatten)]
|
||||
pub target: TargetOpt,
|
||||
|
||||
#[clap(flatten)]
|
||||
pub toolchain: ToolchainOpt,
|
||||
|
||||
#[clap(flatten)]
|
||||
pub build_mode: BuildModeOpt,
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue