Preflight checklist
Problem or motivation
I'd like to integrate various C libraries into my Odin projects, but there isn't currently a general API for doing so. Examples include libraries such as mimalloc and unitables, though the request isn't specific to those projects. They simply illustrate a broader need.
Proposed solution
Integrating odin-c-bindgen into the rule set would enable automatic generation of Odin bindings for C libraries.
Since rules_cc already requires users to declare the library headers, it would be possible to integrate directly with cc_library. The user could simply invoke odin_bindgen and pass a cc_library target, optionally alongside a manifest attribute for configuring custom odin-c-bindgen options.
The provided cc_library could also be reused during the build. One possible implementation would expose the resulting static or shared library to the generated bindings via -define values, allowing the bindings to use Odin's foreign import mechanism. Alternatively, the rule could forward the required linker arguments through -extra-linker-flags. The exact approach is an implementation detail, but either option could leverage the existing cc_library target and avoid requiring users to duplicate library configuration.
Alternatives considered
Instead of integrating with rules_cc, the user could also manually specify input headers and output odin files as well as manually pass the produced artifact to the linker or odin compiler
Additional context
No response
Preflight checklist
Problem or motivation
I'd like to integrate various C libraries into my Odin projects, but there isn't currently a general API for doing so. Examples include libraries such as mimalloc and unitables, though the request isn't specific to those projects. They simply illustrate a broader need.
Proposed solution
Integrating odin-c-bindgen into the rule set would enable automatic generation of Odin bindings for C libraries.
Since rules_cc already requires users to declare the library headers, it would be possible to integrate directly with
cc_library. The user could simply invokeodin_bindgenand pass acc_librarytarget, optionally alongside amanifestattribute for configuring customodin-c-bindgenoptions.The provided
cc_librarycould also be reused during the build. One possible implementation would expose the resulting static or shared library to the generated bindings via-definevalues, allowing the bindings to use Odin'sforeign importmechanism. Alternatively, the rule could forward the required linker arguments through-extra-linker-flags. The exact approach is an implementation detail, but either option could leverage the existingcc_librarytarget and avoid requiring users to duplicate library configuration.Alternatives considered
Instead of integrating with
rules_cc, the user could also manually specify input headers and output odin files as well as manually pass the produced artifact to the linker or odin compilerAdditional context
No response