fix windows wasm embedded assets (#19139)

# Objective

- Fix #14246

## Solution

- If building for wasm windows, add a bit of code that replaces `\\`
with `/` in the `file!()` arg

## Testing

- Used MRE https://github.com/janhohenheim/asset-crash

---------

Co-authored-by: François Mockers <francois.mockers@vleue.com>
This commit is contained in:
atlv 2025-05-12 06:10:32 -04:00 committed by GitHub
parent 86cc02dca2
commit ddc9f41519
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -168,6 +168,13 @@ pub fn _embedded_asset_path(
file_path: &Path,
asset_path: &Path,
) -> PathBuf {
let file_path = if cfg!(not(target_family = "windows")) {
// Work around bug: https://github.com/bevyengine/bevy/issues/14246
// Note, this will break any paths on Linux/Mac containing "\"
PathBuf::from(file_path.to_str().unwrap().replace("\\", "/"))
} else {
PathBuf::from(file_path)
};
let mut maybe_parent = file_path.parent();
let after_src = loop {
let Some(parent) = maybe_parent else {