build2-packaging / godot-cpp

build2 package for Godot's GDExtension library
2 stars 1 forks source link

buildfile function to get target name relative to configuration #2

Open Klaim opened 1 year ago

Klaim commented 1 year ago

Godot GDExtensions should follow a naming convention ideally that depends on the configuration. For GDExtension example from the GDExtension tutorial, the .gdextension file describing to the Godot Engine which binary file to load as a plugin at runtime is described this way:

[configuration]

entry_symbol = "example_library_init"

[libraries]

macos.debug = "res://bin/libgdexample.macos.template_debug.framework"
macos.release = "res://bin/libgdexample.macos.template_release.framework"
windows.debug.x86_32 = "res://bin/libgdexample.windows.template_debug.x86_32.dll"
windows.release.x86_32 = "res://bin/libgdexample.windows.template_release.x86_32.dll"
windows.debug.x86_64 = "res://bin/libgdexample.windows.template_debug.x86_64.dll"
windows.release.x86_64 = "res://bin/libgdexample.windows.template_release.x86_64.dll"
linux.debug.x86_64 = "res://bin/libgdexample.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://bin/libgdexample.linux.template_release.x86_64.so"
linux.debug.arm64 = "res://bin/libgdexample.linux.template_debug.arm64.so"
linux.release.arm64 = "res://bin/libgdexample.linux.template_release.arm64.so"
linux.debug.rv64 = "res://bin/libgdexample.linux.template_debug.rv64.so"
linux.release.rv64 = "res://bin/libgdexample.linux.template_release.rv64.so"
android.debug.x86_64 = "res://bin/libgdexample.android.template_debug.x86_64.so"
android.release.x86_64 = "res://bin/libgdexample.android.template_release.x86_64.so"
android.debug.arm64 = "res://bin/libgdexample.android.template_debug.arm64.so"
android.release.arm64 = "res://bin/libgdexample.android.template_release.arm64.so"

While the binary could be just named libgdexample.so/dll/framework (I know that works because I tested it) and just copy pasted in the appropriate places, it would be helfpul to users to just provide a buildfile function that generate the right name for the library depending on which configuration it is built. Also that would allow to do one b install per configuration in the same directory would result in different binaries available, which is helpful for setting up a releaseable version of the game using Godot.

Providing such naming function is possible by implementing a build2-module (in C++).

Klaim commented 11 months ago

This might be done by providing an importable buildfile containing a special target-type, like gdextension{name}