libriscv / rvscript

Fast RISC-V-based scripting backend for game engines
MIT License
238 stars 7 forks source link

is hot reload possible? #10

Open longzhiri opened 5 months ago

longzhiri commented 5 months ago

Hello! If I have a rather large script project, and I want to hot reload a single script file, just like reloading a module in Lua, is that possible?

fwsGonzo commented 4 months ago

For example in this repository, if you change a single script file, only that file will be recompiled when you build. All my build scripts use incremental compilation. I also use ccache in order to reduce build times even further. The result is that the iteration speed is quite fast, despite having to build a program after each change.

I don't know if it can compete with a Lua hot-reload. But it would be possible to detect a source change and rebuild the RISC-V binary in the background with a simple shell script that uses inotify. Example: https://gist.github.com/mpapi/4656389

As an example, Godot will use this on every resource: If the resource changes, reload it. Initializing the VM with a new program is fast enough that it is nearly instant.