godot-kotlin-jvm
godot-kotlin-jvm copied to clipboard
[PROPOSAL] Write reload logic in cpp
Currently we have the bootstrap class which handles file system changes and reloads classes accordingly.
It basically is the sole reason why we have to ship the godot-bootstrap.jar
alongside the engine executable.
I propose that we implement this filewatching and reloading logic completely in cpp. Looking at the impl of some other cpp filewatching libs (like https://github.com/apetrone/simplefilewatcher/) we should be able to to this kind of filewatching ourselves pretty easily as well even if we have to implement it platform specific. Maybe even godot has some platform independent way of watching filesystem changes.
Also now that we use a buildLock file instead of watching the build
dir directly, the file watching logic is greatly simplified.
So we would in fact only need to watch one file which further simplifies things a lot.
This would pave the way for better/simpler editor builds and would completely remove the need for two jar files as we could pack everything into one jar. Which would also simplify export targets like android a lot.
I agree on this one. But for me we should rely on engine implementation and avoid creating our own FileAccess
.
But does godot have a file watching functionality? I'd rather not have some kind of service routine that periodically polls for changes. This creates unnecessary load on the system.
I back this, although I advise against using a third party library - hopefully godot provide something in a platform agnostic way. This exist https://docs.godotengine.org/en/stable/classes/class_editorfilesystem.html - although I'm not sure if it will serve our requirement.
I definitely agree. I wouldn't want a third party lib for this. This was just an implementation example if we have to do it ourselves in the end
I back this, although I advise against using a third party library - hopefully godot provide something in a platform agnostic way. This exist https://docs.godotengine.org/en/stable/classes/class_editorfilesystem.html - although I'm not sure if it will serve our requirement.
I don't think we can use this. As our buildLock file is not a imported resource. It resides in the tmp dir. Also i would not change this. I think this is a far more stable location than the project dir
It looks to me that C# is using a timer node for this: https://github.com/godotengine/godot/blob/8f7f5846397297fff6e8a08f89bc60ce658699cc/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
Searching the godot source didn't yield in any watching functionality so far.
I'm pretty sure that Godot got some thread running in the editor to check if a file in the project was changed recently: https://github.com/godotengine/godot/blob/d5bd8a704f096043174af7994ef3de055a36cf45/editor/editor_file_system.cpp#L209. Need to investigate that more in details.
This issue is postponed until https://github.com/utopia-rise/godot-kotlin-jvm/milestone/9 is done