godot-dlang icon indicating copy to clipboard operation
godot-dlang copied to clipboard

Add build check for generated api and version

Open nxuv opened this issue 2 years ago • 7 comments

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

nxuv avatar Oct 13 '23 17:10 nxuv

Probably will have to use "preRunCommands" option in dub and print all caps message if classes haven't been generated

nxuv avatar Oct 13 '23 17:10 nxuv

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?");

Superbelko avatar Oct 13 '23 18:10 Superbelko

Didn't think about traits, yea, that's much better

nxuv avatar Oct 13 '23 18:10 nxuv

Added edit in top post about versions

nxuv avatar Oct 14 '23 12:10 nxuv

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.

Superbelko avatar Oct 19 '23 16:10 Superbelko

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.

Superbelko avatar Oct 25 '23 06:10 Superbelko

Then the only way is preGenerate/preBuild/preRunCommands in dub

nxuv avatar Oct 25 '23 14:10 nxuv