Closed ashtonmeuser closed 1 year ago
@fire This is a simple yet hugely impactful change that may be of interest to you. Should really expand Godot Wasm's compatibility with languages targeting Wasm. Logging support is also super helpful for debugging. There is plenty more WASI functionality that could be added, but this is a good start.
Edit: The following is only partially relevant after making Godot 4 the target of the main branch to address #30. The Godot 3 branch will now be the "floating" branch that is occasionally rebased.
Once this is solid, I'll port it to Godot 4.x.
Speaking of Godot 4, I'll be rebasing the Godot 4 branch onto master to better reflect the changes that were done specifically for Godot 4 support (2 commits) and remove the commits cherry picked from master (21 commits). Linear history makes these changes more obvious and will catch any drift/differences incurred by cherry picking for a long stretch. It'll end up looking like this (which is identical to v0.1.9-godot-4) and history will be preserved by the v0.1.9-godot-4 tag. I'll likely do this every release or few releases. When the Godot 4 branch becomes main (#30), I'll do the same with the Godot 3 branch.
Some of the obvious next targets for WASI wasi_snapshot_preview1
support would be:
clock_time_get
args_sizes_get
(stubbed out)args_get
(stubbed out)environ_sizes_get
(stubbed out)environ_get
(stubbed out)random_get
Some of these would simply be stubbed out because args are irrelevant and environment should probably not be exposed to modules. However, at least providing these imports will allow loading modules that expect WASI bindings.
Edit: I would be very hesitant to implement any of the WASI filesystem functions. However, between this and environment variables, perhaps an optional permission model that defaults to safe is required. For example, you could set permissions with something like the following.
wasm.permissions({
"env": true,
"fs_read": true,
"fs_write": false,
})
Decided to address #30 and swap default branch to target Godot 4.x first. This'll be rebased and tested with Godot 4 before being backported to 3.
Support for a small subset of WASI wasi_snapshot_preview1. Includes the following WASI functionality.
wasi_snapshot_preview1.fd_write
. This allows simple logging from a Wasm module. This is supported in AssemblyScript (via WASI shim) usingconsole.log()
,console.error()
, etc. and Grain usingprint()
. Should help immensely with debugging.wasi_snapshot_preview1.proc_exit
. This allows Wasm modules to terminate with an error code. Supported in AssemblyScript (via WASI shim) usingprocess.exit()
and Grain usingProcess.exit()
._start
function, it will be called immediately on instantiation.