godot-dlang
godot-dlang copied to clipboard
Add build check for generated api and version
It seems this step is often enough missed by people and we probably should add a check if generator was even run and throw if not
Edit: Also would be nice to check latest allowed version against gdextension api version and point to, I guess, different branch
Probably will have to use "preRunCommands" option in dub and print all caps message if classes haven't been generated
Nah, these dub commands would be too awkward in a library, probably static assert with a message in api package to check if refcounted exists will do.
smth like
static assert (__traits(compiles, __traits(identifier, godot.refcounted), "oops did you forgot to generate bindings?");
Didn't think about traits, yea, that's much better
Added edit in top post about versions
gdextension_binding.h now has metadata in comments showing which version this API was introduced, we can probably extract it and slap version or a plain UDA, but for now I can't tell if we should as the current version works with both 4.1 and 4.2.
IIRC the same thing now should be in extension_api.json along with the docs.
Well unfortunately import checks has higher priority than static assert and suggested approach won't work without rewriting all imports to put them under static if/version imports which will not work anyway for user code.
Then the only way is preGenerate/preBuild/preRunCommands in dub