HARDWARE & SUBSTRATES DEVTOOLS LOCAL AIR-GAPPED
ABIGen C/C++ Binding Synthesizer
libclang-driven generator that parses C/C++ headers and synthesizes C ABI shims and safe C# P/Invoke bindings.
ABIGen C/C++ Binding Synthesizer
ABIGen is a code generation toolkit driven by libclang that parses native C and C++ header files, analyzes API surfaces, and generates clean C ABI shims alongside safe, type-strict C# bindings.
Generation Workflow
[C/C++ Headers] ──> (libclang AST Analysis) ──> (Policy & Type Mapper)
│
[Safe C# P/Invoke Bindings] <── [C ABI Shim .c/.h] <──┘
- AST Extraction: Traverses header files via
libclang, extracting function signatures, structs, enums, and typedefs. - Unsupported API Detection: Identifies C++ virtual tables, complex templates, and compiler-specific extensions requiring ABI flattening.
- C ABI Shim Generation: Synthesizes flat,
extern "C"wrapper functions with explicit calling conventions (cdecl,stdcall). - C# Binding Synthesis: Emits managed C# classes with
LibraryImport/DllImport, safe handle lifetimes, and marshalling attributes.
Running ABIGen
dotnet run --project src/HFLabs/DevTools/ABIGen/ABIGen.csproj -- --config abigen-poplar.json --generate-bindings