Skip to content

feat: Adding odin-c-bindgen? #12

Description

@callframe

Preflight checklist

  • I have searched existing issues and discussions for this request.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions