LuaGObject dynamically generates Lua bindings to libraries that support GObject-Introspection — GLib, Gio, GTK 4, libadwaita, Pango and many more — plus the Cairo bindings needed by parts of GTK.
This repository is a fork of vtrlx/LuaGObject, maintained for IgnisLua. Upstream remains the canonical project; this fork exists because IgnisLua needs two things that are not upstream yet.
Licensed under an MIT-style
license — see LICENSE.
Tested with PUC-Rio Lua 5.1–5.5 and LuaJIT2. Other Lua implementations are not officially supported. The project descends from LGI and shares much of its internals and structure.
- Lua 5.5 build support. The core module is built against Lua 5.5 and is
loaded by the IgnisLua launcher from
deps/install/lib/lua/5.5/LuaGObject/. - GC ownership hardening.
object_gcused to unref every object a proxy pointed at. For objects Lua never held a reference to — borrowed values and objects already finalized by GTK — that dereferenced stale memory and crashed insideg_type_fundamental(). The fork keeps a registry of objects Lua actually owns and only unrefs those; anything else is left alone. - Closure and ParamSpec retention. Signal closures created for Lua
callbacks are anchored so a
GClosurecannot be freed while the signal is still connected, andGObject.ParamSpecis pre-registered so apspecarriving from C always has a valid repo table.
Everything else is upstream code. Diff against the vtrlx/LuaGObject master
branch to see the fork's changes in full.
GIRepository-2 >= 2.80.0 development files are required
(libgirepository-2.0-dev on Debian-based systems, glib2-devel on
RedHat-based systems).
make LUA_VERSION=5.5
sudo make install LUA_VERSION=5.5 PREFIX=/usrOn BSD systems use gmake. Plain GNU Make does not detect a system Lua through
pkg-config; install PUC-Rio Lua from source if you build this way.
meson setup build --prefix=/usr -Dlua-pc=... -Dlua-bin=...
ninja -C build
ninja -C build test
sudo ninja -C build installVisual Studio 2013 and later are supported through Meson as well; see the
upstream README for the %INCLUDE%/%LIB%/%PATH% details.
IgnisLua keeps a prebuilt copy of this fork under deps/install/, which the
launcher adds to package.path/package.cpath automatically. To rebuild it
in place:
make -C deps/LuaGObject/LuaGObject LUA_VERSION=5.5
cp deps/LuaGObject/LuaGObject/lua_gobject_core.so \
deps/install/lib/lua/5.5/LuaGObject/lua_gobject_core.solocal Gtk = require("LuaGObject").require("Gtk", "4.0")
local Gio = require("LuaGObject").require("Gio", "2.0")
local app = Gtk.Application({ application_id = "org.example.App" })Documentation lives in docs/. Older LGI-era examples are in samples/; some
of them, especially the GTK ones, are dated.
Replace require('lgi') with require('LuaGObject'). For build systems and CI
pipelines, note that corelgilua51.{so,dll} was renamed to
lua_gobject_core.{so,dll}, and all lgi/ paths became LuaGObject/.
Bug reports and pull requests for the fork belong in
sysv86/LuaGObject; use the templates in
.github/. Do not send fork-only changes upstream — open them against this
repository instead.
Upstream vtrlx/LuaGObject has its own contribution policy, including a ban on
machine-generated contributions. Anything intended for upstream must satisfy
that policy; changes in this fork are not affected by it.
LuaGObject exists because of Christian Hergert's initial port of LGI to GIRepository 2.80, and because of the LGI developers: Pavel Holejsovsky, Uli Schlachter, Jasper Lievisse Adriaanse, Ildar Mulyukov, Nils Nordman, Ignas Anikevicius, Craig Barnes, Nicola Fontana, Andreas Stührk, Aaron Faanes, Jiří Klimeš, Garrett Regier, Kenneth Zhou, Travis Hoppe, Tobias Jakobs, Heiko Becker, Vincent Bermel and Szunti.
Release history up to 0.10.5 is documented in the upstream README; older pre-fork versions are listed in LGI's history.