Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Commit

Permalink
Fix compile errors on wasm (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
iliakonnov authored Jul 10, 2021
1 parent de5f625 commit d3d35e5
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
config:
- { os: ubuntu-latest, target: 'x86_64-unknown-linux-gnu' }
- { os: ubuntu-latest, target: 'x86_64-pc-windows-gnu' }
# - { os: ubuntu-latest, target: 'wasm32-unknown-unknown' }
- { os: ubuntu-latest, target: 'wasm32-unknown-unknown' }
- { os: macos-latest, target: 'x86_64-apple-darwin' }
- { os: macos-latest, target: 'aarch64-apple-ios' }
- { os: macos-latest, target: 'x86_64-apple-ios' }
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2018"
description = "A lite, fully featured 2D game engine."
repository = "https://github.com/Bombfuse/emerald"
license = "MIT OR Apache-2.0"
resolver = "2"

[features]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -28,13 +29,15 @@ nalgebra = { version = "0.26.2" }
# Optionals
rapier2d = { version = "0.8.0", default-features = false, features = [ "dim2", "f32" ], optional = true }
gamepad = { version = "0.1.1", optional = true }
kira = { version= "0.5.2", optional = true }

[target.'cfg(target_arch="wasm32")'.dependencies]
miniquad = { version = "0.3.0-alpha.30", features = [ "log-impl" ] }
# mp3 does not works on wasm :(
kira = { version= "0.5.2", optional = true, default-features = false, features = ["ogg", "flac", "wav"] }

[target.'cfg(not(target_arch="wasm32"))'.dependencies]
miniquad = "0.3.0-alpha.30"
kira = { version= "0.5.2", optional = true }

[target.'cfg(target_os = "android")'.dependencies]
sapp-android = "0.1.8"
Expand Down
2 changes: 1 addition & 1 deletion examples/gamepads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Game for GamepadExample {
emd.loader()
.pack_bytes(
"./examples/assets/bunny.png",
include_bytes!("../assets/bunny.png").to_vec(),
include_bytes!("./assets/bunny.png").to_vec(),
)
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Game for GamepadExample {
emd.loader()
.pack_bytes(
"./examples/assets/Roboto-Light.ttf",
include_bytes!("../assets/Roboto-Light.ttf").to_vec(),
include_bytes!("./assets/Roboto-Light.ttf").to_vec(),
)
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Game for MouseExample {
emd.loader()
.pack_bytes(
"./examples/assets/bunny.png",
include_bytes!("../assets/bunny.png").to_vec(),
include_bytes!("./assets/bunny.png").to_vec(),
)
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/physics_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Game for PhysicsGroupsExample {
emd.loader()
.pack_bytes(
"./examples/assets/bunny.png",
include_bytes!("../assets/bunny.png").to_vec(),
include_bytes!("./assets/bunny.png").to_vec(),
)
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion src/assets/asset_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::*;

use std::ffi::OsStr;

#[cfg(target_arch = "wasm")]
#[cfg(target_arch = "wasm32")]
fn read_file(path: &str) -> Result<Vec<u8>, EmeraldError> {
Err(EmeraldError::new(format!(
"Unable to get bytes for {}",
Expand Down

0 comments on commit d3d35e5

Please sign in to comment.