From ec0fe4227b1bf9d1565d70449ab10588f3e65f43 Mon Sep 17 00:00:00 2001 From: gak Date: Sat, 28 Sep 2024 09:20:13 +1000 Subject: [PATCH] Add wasm32 build to ci (#636), bevy_egui -> 0.29 * Fixes a wasm build problem with bevy_egui too! --- .cargo/config.toml | 2 ++ .github/workflows/ci.yml | 5 +++-- Cargo.toml | 2 +- tools/ci/src/main.rs | 35 +++++++++++++++++++++++++++++------ 4 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..f5d91204 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.wasm32-unknown-unknown] +rustflags = ["--cfg=web_sys_unstable_apis"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c25e5e18..47667104 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: - name: Cache Cargo build files uses: Leafwing-Studios/cargo-cache@v2.4.0 - name: Install alsa and udev - run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - name: Build & run tests # See tools/ci/src/main.rs for the commands this runs run: cargo run -p ci -- test @@ -50,10 +50,11 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: stable + targets: wasm32-unknown-unknown - name: Cache Cargo build files uses: Leafwing-Studios/cargo-cache@v2.4.0 - name: Install alsa and udev - run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - name: Check Compile # See tools/ci/src/main.rs for the commands this runs run: cargo run -p ci -- compile diff --git a/Cargo.toml b/Cargo.toml index 51a21524..fe22113c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ leafwing_input_manager_macros = { path = "macros", version = "0.15" } bevy = { version = "0.14.0-rc.3", default-features = false, features = [ "serialize", ] } -bevy_egui = { version = "0.28", optional = true } +bevy_egui = { version = "0.29", optional = true } derive_more = { version = "0.99", default-features = false, features = [ "display", diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 271fa2a7..ce657ee7 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -23,6 +23,8 @@ const CLIPPY_FLAGS: [&str; 3] = [ "-Dwarnings", ]; +const COMPILE_TARGETS: &[&str] = &["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]; + fn main() { // When run locally, results may differ from actual CI runs triggered by // .github/workflows/ci.yml @@ -84,6 +86,13 @@ fn main() { // and convert them into '--features=' let lib_features_options = (1..lib_features.len()) .flat_map(|combination_length| lib_features.iter().combinations(combination_length)) + .map(|mut combination| { + // bevy_egui 0.29 uses the bevy winit feature, which requires a renderer. + if combination.contains(&&"egui") { + combination.push(&"bevy/wayland"); + } + combination + }) .map(|combination| String::from("--features=") + &combination.iter().join(",")); let default_feature_options = ["--no-default-features", "--all-features"]; @@ -94,13 +103,19 @@ fn main() { .collect::>(); for feature_option in all_features_options { + let extra = if feature_option == "--all-features" { + &vec!["--features", "bevy/wayland"] + } else { + &vec![] + }; + if what_to_run.contains(Check::CLIPPY) { // See if clippy has any complaints. // --all-targets was removed because Emergence currently has no special targets; // please add them back as necessary cmd!( sh, - "cargo clippy --workspace {feature_option} -- {CLIPPY_FLAGS...}" + "cargo clippy --workspace {feature_option} {extra...} -- {CLIPPY_FLAGS...}" ) .run() .expect("Please fix clippy errors in output above."); @@ -110,7 +125,7 @@ fn main() { // Run tests (except doc tests and without building examples) cmd!( sh, - "cargo test --workspace {feature_option} --lib --bins --tests --benches" + "cargo test --workspace {feature_option} {extra...} --lib --bins --tests --benches" ) .run() .expect("Please fix failing tests in output above."); @@ -125,15 +140,23 @@ fn main() { } // Run doc tests - cmd!(sh, "cargo test --workspace {feature_option} --doc") - .run() - .expect("Please fix failing doc-tests in output above."); + cmd!( + sh, + "cargo test --workspace {feature_option} {extra...} --doc" + ) + .run() + .expect("Please fix failing doc-tests in output above."); } if what_to_run.contains(Check::COMPILE_CHECK) { - cmd!(sh, "cargo check --workspace {feature_option}") + for target in COMPILE_TARGETS { + cmd!( + sh, + "cargo check --workspace {feature_option} {extra...} --target {target}" + ) .run() .expect("Please fix compiler errors in above output."); + } } } }