diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b8bcf4454dc4..0191064131d45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/tools/ci/src/ci.rs b/tools/ci/src/ci.rs index beaab08e09093..043a887e37ec7 100644 --- a/tools/ci/src/ci.rs +++ b/tools/ci/src/ci.rs @@ -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), diff --git a/tools/ci/src/commands/compile_check_no_std.rs b/tools/ci/src/commands/compile_check_no_std.rs new file mode 100644 index 0000000000000..86109c6279bb1 --- /dev/null +++ b/tools/ci/src/commands/compile_check_no_std.rs @@ -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> { + let target = self.target.as_str(); + vec![PreparedCommand::new::( + 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::( + 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::( + 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.", + ) + ] + } +} diff --git a/tools/ci/src/commands/mod.rs b/tools/ci/src/commands/mod.rs index 9c9f19e01a6d2..696155aee96ca 100644 --- a/tools/ci/src/commands/mod.rs +++ b/tools/ci/src/commands/mod.rs @@ -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;