From ae8f6f39d064ff75b4efe52b732bb0f72aae12a2 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 26 Jun 2022 10:50:06 +0200 Subject: [PATCH 1/5] CI: update APT package listing before installing Otherwise we might hit 404 errors when trying to download outdated package versions. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 180ca07..906d8a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: components: rust-src, rustfmt, clippy - name: Setup QEMU - run: sudo apt-get install -y qemu-system-x86 + run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 - name: Build as x86_64 uses: actions-rs/cargo@v1 From de5eb80c6c54c306972a4f1601a968b1672155a2 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 26 Jun 2022 10:40:26 +0200 Subject: [PATCH 2/5] Make Rust Nightly the default for local development MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since it is required for testing with Cargo’s build-std --- rust-toolchain.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5d56faf --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly" From 90a780b04c70c952c7ce5aeaee61288816b61f0b Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 26 Jun 2022 10:37:16 +0200 Subject: [PATCH 3/5] Document and test Rust 1.59.0 as minimum supported version 1.59.0 is the version that stabilized the asm! macro for inline assembly. The README previously said that Nightly is required, but that turned to be the case only for cross-compiling to i686-unknown-none. --- .github/workflows/ci.yml | 20 ++++++++++++-------- Cargo.toml | 3 +++ README.md | 6 +++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 906d8a8..a6dab92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,10 @@ jobs: rust: - nightly + # Minimum supported version. + # Keep this in sync with Cargo.toml and README.md + - 1.59.0 + steps: - name: Checkout uses: actions/checkout@v2 @@ -23,32 +27,32 @@ jobs: components: rust-src, rustfmt, clippy - name: Setup QEMU + if: ${{ matrix.rust == 'nightly' }} run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 - - name: Build as x86_64 + - name: Build (without testing) as x86_64 + if: ${{ matrix.rust == 'nightly' }} # Tier 2 (precompiled libcore in rustup) since 1.62 uses: actions-rs/cargo@v1 with: command: build args: --target x86_64-unknown-none - - name: Build as i686 - uses: actions-rs/cargo@v1 - with: - command: build - args: --target i686-unknown-none.json - - - name: Test + - name: Build and test as i686 + if: ${{ matrix.rust == 'nightly' }} uses: actions-rs/cargo@v1 with: command: test + args: --target i686-unknown-none.json - name: Rustfmt + if: ${{ matrix.rust == 'nightly' }} uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check - name: Clippy + if: ${{ matrix.rust == 'nightly' }} uses: actions-rs/cargo@v1 with: command: clippy diff --git a/Cargo.toml b/Cargo.toml index dd4ebf8..8c7fea9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ keywords = ["qemu", "fw_cfg"] categories = ["no-std", "embedded", "hardware-support"] readme = "README.md" +# Keep this in sync with README.md and .github/workflows/ci.yml +rust-version = "1.59" + [features] default = ["alloc"] alloc = [] diff --git a/README.md b/README.md index 51cb055..bd6efc0 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,11 @@ if running_in_qemu() { ## Rust support -Currently, `qemu-fw-cfg` required nightly compiler to build. + +The minimum supported Rust version for `qemu-fw-cfg` is 1.59.0. + +However, testing for x86 currently requires Rust Nightly as it uses +[Cargo’s `build-std`](https://doc.rust-lang.org/cargo/reference/unstable.html#build-std). ## License From c47209fa3564f4ba221570bb33fb5156407a9901 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 26 Jun 2022 10:56:50 +0200 Subject: [PATCH 4/5] Derive Eq for FwCfgFile in addition to PartialEq This fixes a Clippy warning --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index dea3efc..722c1d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -170,7 +170,7 @@ impl FwCfg { const FW_CFG_FILE_SIZE: usize = 64; /// A struct that contains information of a fw_cfg file. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct FwCfgFile<'a> { size: usize, key: u16, From c39d416f0006d7f33127b7aedaecedf153cb6f00 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 26 Jun 2022 11:21:31 +0200 Subject: [PATCH 5/5] Add support for `cargo test --no-default-features` --- tests/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/main.rs b/tests/main.rs index 0c47147..b9502eb 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -1,6 +1,6 @@ #![no_std] #![no_main] -#![feature(default_alloc_error_handler)] +#![cfg_attr(feature = "alloc", feature(default_alloc_error_handler))] use qemu_fw_cfg::FwCfg; @@ -42,6 +42,7 @@ fn main() { ); // Read file + #[cfg(feature = "alloc")] assert_eq!(DATA_INPUT_TXT, fw_cfg.read_file(&file_input_txt)); // Read file with buffer