amethyst / bracket-lib

The Roguelike Toolkit (RLTK), implemented for Rust.
MIT License
1.51k stars 108 forks source link

Compile problem with wasm32 using bracket-terminal 0.8.7 #301

Open webbiscuit opened 1 year ago

webbiscuit commented 1 year ago

I'm pulling bracket-terminal into my project as a dependency and compiling for wasm:

 rustup target add wasm32-unknown-unknown
 cargo install wasm-bindgen-cli
 cargo build --release --target wasm32-unknown-unknown

I'm seeing the new errors:

error[E0432]: unresolved imports `glow::NativeFramebuffer`, `glow::NativeTexture`
 --> /home/dan/.cargo/registry/src/github.com-1ecc6299db9ec823/bracket-terminal-0.8.7/src/hal/gl_common/framebuffer.rs:3:24
  |
3 | use glow::{HasContext, NativeFramebuffer, NativeTexture};
  |                        ^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^ no `NativeTexture` in the root
  |                        |
  |                        no `NativeFramebuffer` in the root

   Compiling async-executor v1.4.1
error[E0609]: no field `fitscreen` on type `hal::wasm::InitHints`
   --> /home/dan/.cargo/registry/src/github.com-1ecc6299db9ec823/bracket-terminal-0.8.7/src/initializer.rs:455:29
    |
455 |         self.platform_hints.fitscreen = fitscreen;
    |                             ^^^^^^^^^ help: a field with a similar name exists: `fullscreen`
thebracket commented 1 year ago

Oops! I'll try and get that fixed, probably tomorrow. It looks like I missed a type alias.

jimmykiang commented 1 year ago

Oops! I'll try and get that fixed, probably tomorrow. It looks like I missed a type alias.

Hi, at least could you please point out which was the prior version of bracket lib that was working to generate the wasm files following the instructions from you website?

thebracket commented 1 year ago

You can change your dependency in Cargo.toml to read bracket-lib = "=0.8.1" and it should work. I'm working on a fix for this version now.

thebracket commented 1 year ago

I have a few other fixes to roll up before I release 0.8.8. In the interim, you can use the latest version with WASM by using the following as your dependency:

bracket-lib = { git = "https://github.com/amethyst/bracket-lib.git" }

It compiles now; when I've had some more coffee, I'll do a full integration test.

webbiscuit commented 1 year ago

Thanks! I can confirm the latest unreleased version works. @jimmykiang - the last released version that works is 0.8.5

JonnieCache commented 1 year ago

just confirming that my hello world example fails for me in the way described in this ticket on 0.8.7, (when following the wasm guide in the rust roguelike tutorial) but still works for me when I pin brackets-lib to master.

bbarker commented 1 year ago

If you want to pin the most recent buildable commit (according to git's CI), you can do this :

bracket-lib = { git = "https://github.com/amethyst/bracket-lib.git", rev = "851f6f08675444fb6fa088b9e67bee9fd75554c6", features = ["serde"] }
VKUnicorn commented 8 months ago

In case you came here trying to compile Chapter 1 from "Roguelike Tutorial" you need to add rltk = { git = "https://github.com/amethyst/bracket-lib" } (not bracket-lib) as described here https://github.com/amethyst/rustrogueliketutorial/issues/201#issuecomment-1427829960

iwyatt commented 7 months ago

Thanks for posting the solution to the wasm build!

I was following the directions on running wasm on https://hands-on-rust.com/2021/11/06/run-your-rust-games-in-a-browser-hands-on-rust-bonus-content/ after finishing Hands-on Rust (Fantastic book, btw!) and luckily found this github issue with a fix.

Putting bracket-lib = { git = "https://github.com/amethyst/bracket-lib.git" } in my .toml worked for me to compile. There was a little confusion as the output files were going in to .wasm_help instead of wasm_help and slash vs backslash on the copied commands, but after I sorted that out, the Dungeon Crawler was running in my browser with a local python web server I ran using python3 -m http.server. I'm very excited about the possibility to self-host little proof of concept games.

Edit: got it working and hosted it on GitHub Pages. I published it to my website, and wrote a blog post about it. Thanks again for this wonderful tutorial!

NaughtyDog6000 commented 7 months ago

@thebracket is there any plans to release a newer version (at least the patch for wasm) so that people dont have to rely on a link to the GH repo and instead can use cargo add as you would expect. If not could you add a warning to readme / docs to state the last version that compiles wasm correctly?

thebracket commented 7 months ago

I hope so. I've had a really nasty combination of being ill, overworked, a crazy toddler and a bit of burnout. So I'm trying to get this into my schedule and ease back into things.

On Mon, Feb 5, 2024 at 7:43 AM NaughtyDog6000 @.***> wrote:

@thebracket https://github.com/thebracket is there any plans to release a newer version (at least the patch for wasm) so that people dont have to rely on a link to the GH repo and instead can use cargo add as you would expect. If not could you add a warning to readme / docs to state the last version that compiles wasm correctly?

— Reply to this email directly, view it on GitHub https://github.com/amethyst/bracket-lib/issues/301#issuecomment-1927043066, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRU435TLHRECSKA7STS65TYSDOZBAVCNFSM6AAAAAAQ5ZO2ICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRXGA2DGMBWGY . You are receiving this because you were mentioned.Message ID: @.***>