Open ramirez7 opened 1 year ago
Tangentially related:
I also use Nix for package management / cross-compilation. It looks like sokol
is in nixpkgs
. But it's not especially maintained.
I will probably maintain a Nix expression for sokol_gfx
in my macaroni.nix
project.
No docs on the bindgen stuff, but it should be relatively easy to get started from the readme here: https://github.com/floooh/sokol/blob/master/bindgen/README.md
Only thing that's missing there: you also need to clone sokol-rust.
Then, when you run python3 gen_all.py
there will be one .json file per module which is basically the 'intermediate format' which the per-language binding-generator scripts use (I attached a zip with the intermediate jsons as example).
When you look at the bindings-generator scripts (like gen_zig.py), start at the bottom, and then skip right away to the gen_module() function, this is the top-level 'interesting' function which calls per-declaration type functions for each public API item (consts, structs, enums and functions => gen_consts, gen_struct, gen_enum, and genfunc*).
The actual code generation is then essentially turning the declarations in the JSON file into language-specific lines of text. There's also a couple of special-case overrides for situations where an automatic mapping of specific C symbol names to target-language symbol names needs to be overriden (either to avoid collision with standard keywords, or to get a more 'idiomatic' naming).
Thanks for the help. That all makes sense. One ripple the Haskell bindings will have is that I will probably need to generate some small C wrappers to make the types satisfy Haskell's FFI (e.g. Haskell does not support FFI for passing or returning structs by-value). I think the JSON file has everything I need.
Not sure exactly when I'll get the time to dive into this, but hopefully this summer!
I would love to create, maintain, and use
sokol-gfx
Haskell bindings. There appears to bebindgen
- are there any docs or guidance on using that?