utopia-rise / godot-kotlin-jvm

Godot Kotlin JVM Module
MIT License
636 stars 44 forks source link

Registration files improvements #500

Closed chippmann closed 11 months ago

chippmann commented 1 year ago

We currently have the following limitations with our registration files (in the following just referenced as gdj files) which we introduced with #441:

These problems can be divided into two different improvements (which all tie together. Hence they are mentioned here):

Tie gdj file name to class instead of relative path

The gdj file name is actually already unique. Even for libraries and when fqName registration is enabled. Hence we can completely ditch the mapping by relative path and map directly by registration file name. From godot we still get the request to resolve a script by resource path like: res://scripts/subdir/MyClass.gdj but MyClass is already unique as far as gdj's are concerned. Hence we can just take the substring after the last / and use that as the identifier to retrieve the correct class.

Update gdj files by file tree scan rather than gdj root dir replacement

Note: This requires the above improvement to work. During build we generate the new registration files, update existing ones and delete obsolete ones. This is currently done "automatically" by ksp for us. But only inside the build dir. After ksp is done, we copy it to the users defined gdj root dir. This we can change so we scan the project dir for gdj files and create, update and delete them accordingly. This would allow the user to freely move the gdj files to where he wants them to be (or leave them where they are by default).