Skip to content

Commit

Permalink
Add wasm32 build to ci (#636), bevy_egui -> 0.29 (#637)
Browse files Browse the repository at this point in the history
* Fixes a wasm build problem with bevy_egui too!

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
  • Loading branch information
gak and alice-i-cecile authored Oct 6, 2024
1 parent 0526be0 commit d6ef9e1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.wasm32-unknown-unknown]
rustflags = ["--cfg=web_sys_unstable_apis"]
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ leafwing_input_manager_macros = { path = "macros", version = "0.15.1" }
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",
Expand Down
37 changes: 30 additions & 7 deletions tools/ci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,7 +73,7 @@ fn main() {
std::env::set_var("RUSTDOCFLAGS", "-D warnings");
cmd!(
sh,
"cargo doc --workspace --all-features --no-deps --document-private-items"
"cargo doc --workspace --all-features --features bevy/wayland --no-deps --document-private-items"
)
.run()
.expect("Please fix doc warnings in output above.");
Expand All @@ -84,6 +86,13 @@ fn main() {
// and convert them into '--features=<FEATURE_A,FEATURE_B,...>'
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"];
Expand All @@ -94,13 +103,19 @@ fn main() {
.collect::<Vec<_>>();

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.");
Expand All @@ -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.");
Expand All @@ -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.");
}
}
}
}

0 comments on commit d6ef9e1

Please sign in to comment.