-
Notifications
You must be signed in to change notification settings - Fork 75
WebAssembly! #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
WebAssembly! #235
Conversation
great work, excited to test it out! |
The mruby is a huge limitation. That's exactly why dragonruby didn't work for me -- I could not figure out how to require gems. Also writing files/sockets/network... |
@Nakilon I hear ya. Now that Ruby 3.2 is gaining WASI support, we'll be able to use CRuby in the browser. I haven't tested the preview release yet, but looks promising. Running in a web browser will still impose limitations, regardless of the Ruby engine used, but hopefully will be more feature rich than mruby. Also not sure about how gems will work, but hopefully there's a decent story there too. |
Awesome work here, just want to follow up on this stuff as im curious to get some updates on achieving web platform support.
|
Hey @westonganger, yea, would be nice to finish this up and merge. (Free time to work on side projects is the enemy here.) Having mruby support is pretty trivial at this point, so we'll probably keep it. And now that Ruby 3.2 is out, and a lot more tooling and documentation exists, would be fun to give that an honest try. I'm not sure of the exact steps to get going, but might start at the Emscripten port, since that's what we're doing today with mruby (and it has all the WASM dependencies ported, like SDL2). If you're interested in doing some experimentation there, happy to open a new PR that's specific to ruby.wasm (separate from mruby). Can also chat about it in the Discord if you like. |
@blacktm what remains to be done to merge the mruby stuff? Also wanted to let you know that the ruby.wasm has made official Ruby 3.2 releases as of today, https://github.com/ruby/ruby.wasm/releases/tag/ruby-3_2-wasm-wasi%2F1.0.1 |
For Ruby 3.2 web assembly we will need to continue using the emscripten version as SDL2 currently only supports emscripten |
Hi @westonganger, I think left for mruby is making sure it works on Windows and Linux/Ubuntu I've only tested on macOS. I also didn't get the virtual file system set up yet. Overall, the developer experience is probably a little rough. This could be merged as a "first draft", then progressively add and test new features. Good to know that about Ruby 3.2, thanks. I'm down to give that a go, I think would be more popular than an mruby option. Would definitely want to open a new branch after merging this. If you're interested in collaborating on it, feel free to join the |
Yes if it can be merged as a first draft that would be helpful, we can create issues for any outstanding things such as Window/Linux testing and virtual FS. That would at least give us a baseline to continue forward with. This will allow for mruby development to continue in smaller steps and provide a general sense of direction for implementing cruby wasm support. |
Just checking in. Still hoping to see something budge here in regards to the mruby stuff here now. |
hi - thanks for referencing my thread on SDL2 / WASM / WASI here. |
I actually tried it with ruby.wasm
|
This PR will enable WebAssembly as a build target. Currently works on macOS, but will be testing on Windows and Linux soon. To test this branch locally, do the following after cloning:
rake update
to get the latest changes in theassets/
Git submodule.rake
to (re)build the gem and install in one command.ruby2d build test/wasm.rb --debug
to build our little test app.ruby2d serve build/web/app.html
to launch the built test app in your default browser.To conveniently build & serve a file in the
test/
directory, you can also use:That's it! If all goes well, should look something like the image below. Let me know how this works, and feedback welcome.
Caveats!
The build process currently doesn't include media files you might reference in your apps. For example, you can't yet include an image, font, or audio file in your build. This is something we need to figure out.Done!require
doesn't work. Because we're using mruby under the hood, there is norequire
. I think we should implement our own version ofrequire
that literally inserts the file referenced, kind of like a C#include
.libmruby.a
), can't berequire
d like standard gems.