A Pony code generator for GObject ecosystem bindings, driven by GIR (GObject Introspection) XML.
gir-compiler reads one or more .gir files, scans user Pony source to discover which types and methods are referenced, computes a demand-driven closure, and emits a self-contained Pony package tree that includes both the generated bindings and the hand-written runtime support needed to call into the library at runtime.
Early. The v1 generator emits classes, interfaces, records, enums, bitfields, callbacks, and aliases for the GTK4 namespace set (Gtk-4.0, Gio-2.0, GObject-2.0, GLib-2.0). Method emission covers four body shapes:
- trivial void methods (primitives in, no return)
- trivial-return methods (primitives in, primitive out)
- floating-ref constructors (
new create(...)adopting viaGObjectHandle.adopt_floating) - signal-connect methods (currently only
close-requestwired through the embedded runtime)
Anything outside the v1 shape catalog (GError-throwing methods, object returns, out parameters, varargs, etc.) emits a compile_error skip-stub the user's call site triggers at compile time with a useful message.
gir-compiler \
--gir Gtk-4.0,Gio-2.0,GObject-2.0,GLib-2.0 \
--src ./my-app \
--target ./build--gir is a comma-separated list of GIR namespace names. They're looked up in /usr/share/gir-1.0/ (Linux default).
--src is the directory containing your Pony source.
--target is the output directory. After running, it contains:
gobject_runtime/— GObjectHandle and related glue (embedded from gir-compiler; written verbatim on each run)gtk_runtime/— pinned-actor GtkRuntime, signal trampolines, handler type aliases (embedded for the v1 GTK4 slice)gtk/,gio/,gobject/,glib/— generated bindings, one file per type, organised by GIR namespace
To build the resulting package tree:
PONYPATH=./build ponyc my-app -o my-appThe pipeline is also importable as four Pony packages:
gir— GIR XML loader and validator producingGirModel valscanner— Pony source scanner (typed-binding walker) producingScanResult valplanner— closure planner producingEmitPlan valemitter— emitter writing the plan + embedded runtime to disk
Useful for tools that want to embed parts of the pipeline (LSP integration, in-memory analysis, alternative emission backends).
make testRequires corral and ponyc. The corral fetches libxml2, pony_compiler (in-tree under ponyc-work), and ssl.
See LICENSE.