This program generates D bindings for the API exported by Godot. It requires two JSON files: gdnative_api.json
for the C interface, api.json
for the rest of Godot's API. The JSONs from the most recent official Godot release are included in the Godot-D repository, but the steps below show how to obtain them from a custom Godot build.
All the modules in classes/
are generated using this program.
- Export the API from the Godot editor with
<godot editor executable> --gdnative-generate-json-api api.json
. - Copy (or symlink) the generated
api.json
togodot-d/
(next todub.json
). - Copy (or symlink)
modules/gdnative/gdnative_api.json
from Godot source togodot-d/
.- Note: take it from up-to-date Godot source even if you'll use an older Godot binary. Any newer GDNative functions used by the bindings must be declared for them to compile, but your library will be backwards-compatible thanks to GDNative's extension API.
- Compile and run the generator with
dub run godot-d:generator
. It will place the generated classes inclasses/
automatically.
(Remember to delete the entireclasses
directory first when re-exporting, in case any classes were removed.)
The main Godot-D package can now be compiled.
If you need the generator to use a different API JSON or output directory, you can still specify those options: godot-d_generator [path/to/api.json] [output/dir]