mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
Add compile-check-no-std
Command to CI Tool (#15843)
# Objective - Fixes #15840 ## Solution Added a new subcommand to the CI tool, `compile-check-no-std`, which will attempt to compile each `no_std` crate in Bevy with the appropriate features (no-defaults, `libm`, etc.) for `x86_64-unknown-none`. The exact target chosen could be changed to any reasonable platform which does not include the `std` library. The currently tested crates are: - `bevy_ptr` - `bevy_utils` - `bevy_mikktspace` As more crates have `no_std` support added, they _should_ be added to this CI command. Once Bevy itself can be `no_std`, the individual checks can be replaced with just checking Bevy, since it will transiently check all other crates as appropriate. ## Testing - Ran CI. From a clean target directory (`cargo clean`), these new checks take approximately 10 seconds total. --------- Co-authored-by: François Mockers <francois.mockers@vleue.com>
This commit is contained in:
parent
6a39c33d49
commit
aa5e93d0bf
4 changed files with 71 additions and 0 deletions
25
.github/workflows/ci.yml
vendored
25
.github/workflows/ci.yml
vendored
|
@ -127,6 +127,31 @@ jobs:
|
|||
- name: Check Compile
|
||||
# See tools/ci/src/main.rs for the commands this runs
|
||||
run: cargo run -p ci -- compile
|
||||
|
||||
check-compiles-no-std:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
needs: ci
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
target/
|
||||
crates/bevy_ecs_compile_fail_tests/target/
|
||||
crates/bevy_reflect_compile_fail_tests/target/
|
||||
key: ${{ runner.os }}-cargo-check-compiles-no-std-${{ hashFiles('**/Cargo.toml') }}
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-unknown-none
|
||||
- name: Install Linux dependencies
|
||||
uses: ./.github/actions/install-linux-deps
|
||||
- name: Check Compile
|
||||
run: cargo run -p ci -- compile-check-no-std
|
||||
|
||||
build-wasm:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -77,6 +77,7 @@ impl CI {
|
|||
cmds.append(&mut commands::DocCheckCommand::default().prepare(sh, flags));
|
||||
cmds.append(&mut commands::DocTestCommand::default().prepare(sh, flags));
|
||||
cmds.append(&mut commands::CompileCheckCommand::default().prepare(sh, flags));
|
||||
cmds.append(&mut commands::CompileCheckNoStdCommand::default().prepare(sh, flags));
|
||||
cmds.append(&mut commands::CompileFailCommand::default().prepare(sh, flags));
|
||||
cmds.append(&mut commands::BenchCheckCommand::default().prepare(sh, flags));
|
||||
cmds.append(&mut commands::ExampleCheckCommand::default().prepare(sh, flags));
|
||||
|
@ -102,6 +103,7 @@ enum Commands {
|
|||
DocCheck(commands::DocCheckCommand),
|
||||
DocTest(commands::DocTestCommand),
|
||||
CompileCheck(commands::CompileCheckCommand),
|
||||
CompileCheckNoStd(commands::CompileCheckNoStdCommand),
|
||||
CompileFail(commands::CompileFailCommand),
|
||||
BenchCheck(commands::BenchCheckCommand),
|
||||
ExampleCheck(commands::ExampleCheckCommand),
|
||||
|
@ -121,6 +123,7 @@ impl Prepare for Commands {
|
|||
Commands::DocCheck(subcommand) => subcommand.prepare(sh, flags),
|
||||
Commands::DocTest(subcommand) => subcommand.prepare(sh, flags),
|
||||
Commands::CompileCheck(subcommand) => subcommand.prepare(sh, flags),
|
||||
Commands::CompileCheckNoStd(subcommand) => subcommand.prepare(sh, flags),
|
||||
Commands::CompileFail(subcommand) => subcommand.prepare(sh, flags),
|
||||
Commands::BenchCheck(subcommand) => subcommand.prepare(sh, flags),
|
||||
Commands::ExampleCheck(subcommand) => subcommand.prepare(sh, flags),
|
||||
|
|
41
tools/ci/src/commands/compile_check_no_std.rs
Normal file
41
tools/ci/src/commands/compile_check_no_std.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
use crate::{Flag, Prepare, PreparedCommand};
|
||||
use argh::FromArgs;
|
||||
use xshell::cmd;
|
||||
|
||||
/// Checks that the project compiles for a `no_std` target.
|
||||
#[derive(FromArgs, Default)]
|
||||
#[argh(subcommand, name = "compile-check-no-std")]
|
||||
pub struct CompileCheckNoStdCommand {
|
||||
/// the target to check against.
|
||||
/// Defaults to "x86_64-unknown-none"
|
||||
#[argh(option, default = "String::from(\"x86_64-unknown-none\")")]
|
||||
target: String,
|
||||
}
|
||||
|
||||
impl Prepare for CompileCheckNoStdCommand {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec<PreparedCommand<'a>> {
|
||||
let target = self.target.as_str();
|
||||
vec![PreparedCommand::new::<Self>(
|
||||
cmd!(
|
||||
sh,
|
||||
"cargo check -p bevy_ptr --no-default-features --target {target}"
|
||||
),
|
||||
"Please fix compiler errors in output above for bevy_ptr no_std compatibility.",
|
||||
),
|
||||
PreparedCommand::new::<Self>(
|
||||
cmd!(
|
||||
sh,
|
||||
"cargo check -p bevy_utils --no-default-features --target {target}"
|
||||
),
|
||||
"Please fix compiler errors in output above for bevy_utils no_std compatibility.",
|
||||
),
|
||||
PreparedCommand::new::<Self>(
|
||||
cmd!(
|
||||
sh,
|
||||
"cargo check -p bevy_mikktspace --no-default-features --features libm --target {target}"
|
||||
),
|
||||
"Please fix compiler errors in output above for bevy_mikktspace no_std compatibility.",
|
||||
)
|
||||
]
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ pub use bench_check::*;
|
|||
pub use clippy::*;
|
||||
pub use compile::*;
|
||||
pub use compile_check::*;
|
||||
pub use compile_check_no_std::*;
|
||||
pub use compile_fail::*;
|
||||
pub use doc::*;
|
||||
pub use doc_check::*;
|
||||
|
@ -16,6 +17,7 @@ mod bench_check;
|
|||
mod clippy;
|
||||
mod compile;
|
||||
mod compile_check;
|
||||
mod compile_check_no_std;
|
||||
mod compile_fail;
|
||||
mod doc;
|
||||
mod doc_check;
|
||||
|
|
Loading…
Add table
Reference in a new issue