Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adapted the project to compile as either an addon or module. Closes #7. Does not actually allow for web/HTML5 exports due to Wasmer not being able to be compiled to Wasm via Emscripten (which is what happens internally when compiling Godot export templates). More details in #18).
Surprisingly few compromises and defines were required. An overview of the quirks introduced:
GODOT_MODULE
define determines how Godot sources are included. To make things easier, all Godot source includes should go indefs.h
. While a little awkward, I think this is an okay pattern for the (currently) very limited imports used. If this proves problematic, could use the same pattern in each individual source file. Example:_bind_methods
in Godot and_register_methods
.REGISTRATION_METHOD
is used to abstract this difference. Inside the method, there's a check on theGODOT_MODULE
define to actually register the methods differently. Example:NS
define used to define thegodot::
namespace that is required for addon and blank (::
) namespace for module.godot_error
(used in GDNative) is defined as an alias forError
for modules.godot_
prefix. This aligns error names with Godot proper (3.x and 4) and GDExtension. For example, Godot and GDExtension useOK
while GDNative usesGODOT_OK
. Now anOK
define exists to align GDNative with the others.To build the engine with the Godot Wasm module, add the entire project in
godot/modules/wasm
and runscons platform=MY_PLATFORM
.CC @Trey2k