Skip to content

Commit

Permalink
examples showcase: use patches instead of sed for wasm hacks (#10601)
Browse files Browse the repository at this point in the history
# Objective

- Fix the asset hack for wasm examples so that they work on the website
- Use patches instead of sed for wasm hacks so that it fails explicitly
when they need to be updated
  • Loading branch information
mockersf authored Nov 17, 2023
1 parent 9a909f5 commit 7ee9f8e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
13 changes: 13 additions & 0 deletions tools/example-showcase/asset-source-website.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs
index 004f87a85..3c8656efc 100644
--- a/crates/bevy_asset/src/lib.rs
+++ b/crates/bevy_asset/src/lib.rs
@@ -105,7 +105,7 @@ impl Default for AssetPlugin {
fn default() -> Self {
Self {
mode: AssetMode::Unprocessed,
- file_path: Self::DEFAULT_UNPROCESSED_FILE_PATH.to_string(),
+ file_path: "/assets/examples".to_string(),
processed_file_path: Self::DEFAULT_PROCESSED_FILE_PATH.to_string(),
watch_for_changes_override: None,
}
15 changes: 12 additions & 3 deletions tools/example-showcase/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,20 @@ header_message = \"Examples ({})\"
let sh = Shell::new().unwrap();

// setting a canvas by default to help with integration
cmd!(sh, "sed -i.bak 's/canvas: None,/canvas: Some(\"#bevy\".to_string()),/' crates/bevy_window/src/window.rs").run().unwrap();
cmd!(sh, "sed -i.bak 's/fit_canvas_to_parent: false,/fit_canvas_to_parent: true,/' crates/bevy_window/src/window.rs").run().unwrap();
cmd!(
sh,
"git apply --ignore-whitespace tools/example-showcase/window-settings-wasm.patch"
)
.run()
.unwrap();

// setting the asset folder root to the root url of this domain
cmd!(sh, "sed -i.bak 's/asset_folder: \"assets\"/asset_folder: \"\\/assets\\/examples\\/\"/' crates/bevy_asset/src/lib.rs").run().unwrap();
cmd!(
sh,
"git apply --ignore-whitespace tools/example-showcase/asset-source-website.patch"
)
.run()
.unwrap();
}

let work_to_do = || {
Expand Down
16 changes: 16 additions & 0 deletions tools/example-showcase/window-settings-wasm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs
index 7b5c75d38..8e9404b93 100644
--- a/crates/bevy_window/src/window.rs
+++ b/crates/bevy_window/src/window.rs
@@ -245,9 +245,9 @@ impl Default for Window {
transparent: false,
focused: true,
window_level: Default::default(),
- fit_canvas_to_parent: false,
+ fit_canvas_to_parent: true,
prevent_default_event_handling: true,
- canvas: None,
+ canvas: Some("#bevy".to_string()),
window_theme: None,
visible: true,
}

0 comments on commit 7ee9f8e

Please sign in to comment.