Skip to content

Commit 7ee9f8e

Browse files
authored
examples showcase: use patches instead of sed for wasm hacks (#10601)
# 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
1 parent 9a909f5 commit 7ee9f8e

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs
2+
index 004f87a85..3c8656efc 100644
3+
--- a/crates/bevy_asset/src/lib.rs
4+
+++ b/crates/bevy_asset/src/lib.rs
5+
@@ -105,7 +105,7 @@ impl Default for AssetPlugin {
6+
fn default() -> Self {
7+
Self {
8+
mode: AssetMode::Unprocessed,
9+
- file_path: Self::DEFAULT_UNPROCESSED_FILE_PATH.to_string(),
10+
+ file_path: "/assets/examples".to_string(),
11+
processed_file_path: Self::DEFAULT_PROCESSED_FILE_PATH.to_string(),
12+
watch_for_changes_override: None,
13+
}

tools/example-showcase/src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,20 @@ header_message = \"Examples ({})\"
562562
let sh = Shell::new().unwrap();
563563

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

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

572581
let work_to_do = || {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs
2+
index 7b5c75d38..8e9404b93 100644
3+
--- a/crates/bevy_window/src/window.rs
4+
+++ b/crates/bevy_window/src/window.rs
5+
@@ -245,9 +245,9 @@ impl Default for Window {
6+
transparent: false,
7+
focused: true,
8+
window_level: Default::default(),
9+
- fit_canvas_to_parent: false,
10+
+ fit_canvas_to_parent: true,
11+
prevent_default_event_handling: true,
12+
- canvas: None,
13+
+ canvas: Some("#bevy".to_string()),
14+
window_theme: None,
15+
visible: true,
16+
}

0 commit comments

Comments
 (0)