godot-rust / gdnative-book

The user guide for godot-rust.
https://godot-rust.github.io/book
MIT License
64 stars 42 forks source link

Add HTML5 export guide #71

Closed derivator closed 2 years ago

derivator commented 2 years ago

@Bromeon as discussed in #647 this should cover most of the current problems with HTML5 exports.

derivator commented 2 years ago

@Bromeon I don't use custom-godot, should I? I'm just rebuilding 3.4.4 with a newer Emscripten, but it's still 3.4.4

Bromeon commented 2 years ago

@derivator You should only need custom-godot if the generated API JSON would differ from the one shipped in the godot-rust repo. This is usually the case for other Godot minor versions.

I'm not sure if using Emscripten has an effect here. You could run

godot --gdnative-generate-json-api api.json

and diff the generated file against the api.json in the godot-rust repo.

derivator commented 2 years ago
godot --gdnative-generate-json-api api.json

I have no idea how I would do that for a wasm build, but I suspect it's fine. It works for me after all :laughing:

Bromeon commented 2 years ago

@derivator @hoodmane Any more comments before this is merged? 🙂

derivator commented 2 years ago

@Bromeon As far as I can tell at a glance, building Godot shouldn't be necessary anymore with Godot 3.5, as the commit that updates their emscripten version seems to have made it in, but I would still keep that information in the guide, in case the same kind of version mismatch happens in the future. I can try updating the guide this weekend.

Bromeon commented 2 years ago

@derivator have you had a chance to look at it yet? 🙂

derivator commented 2 years ago

@Bromeon I'm having a look right now. Some steps will not be necessary anymore, however Emscripten makes no ABI stability promises, so while using the export template provided by godot might work coincidentally, I think it's probably best to always compile it yourself. I will update the guide to reflect this.

derivator commented 2 years ago

I have it working with Godot 3.5 following the steps in the guide. I believe -Cpanic=abort shouldn't be necessary anymore thanks to https://github.com/emscripten-core/emscripten/pull/17328, but I'm still getting errors without it.

Bromeon commented 2 years ago

Thanks a lot to everyone involved! It's great to finally have a bit more resources on the topic of HTML5 exports ❤️

GeTechG commented 2 years ago

I was able to run on emscripten 3.1.14, Godot 3.5.1, rust nightly 0.65.0 (2022-09-03). I was unable to run as suggested on the latest versions of rust and emscripten, or even 3.1.21 as in the tutorial. A runtime error came out with similar text:

at: init_library (modules/gdnative/nativescript/nativescript.cpp:1479) - Condition "lib_path.length() == 0" is true.

all because I understood different versions of llvm, so I am puzzled how you could run with the latest version of emscripten, as nightly rust builds still have 15.0, not 16.0.