Open atweiden opened 1 year ago
I've never looked into lua's build system. It might be that you can just throw all of the source files into a directory and just let cgo do its thing. If it's anything more complicated you can't do it because cmd/go doesn't let you run arbitrary code at install time.
One can vendor Lua in their golua-using module, compile Lua with a Makefile
or similar, and then link to the vendored Lua library using CGO_CFLAGS
+ CGO_LDFLAGS
.
Enabling this would seem to require patching golua’s lua/lua.go
to include a declaration for lua_gc_compat
in the Cgo special comments section, e.g.
/*
...
LUA_API int (lua_gc_compat) (lua_State *L, int what, int data);
...
*/
import "C"
... rather than patching Lua’s own lua.h
to include this declaration, as I believe lua/lua54/lua.h
does currently. Correct me if I’m wrong, but I don’t think lua_gc_compat
is part of any Lua 5.4x release.
It doesn't matter if there's an extra declaration in lua.h or not.
This module doesn’t build without Lua development libraries installed on the build host. This is a shortcoming compared to the situation in mlua, where users needn’t have Lua pre-installed for static linking to mlua’s vendored copy of Lua to work.
Does Go support this type of build? Would it take a custom
Makefile
or similar? I’ve forked golua to ~ioiojo/golua to experiment, but I don’t see how to link my vendored copy of Lua. As an example, see thelua-c-api/zig
subdirectory of ~ioiojo/export-anytype: https://git.sr.ht/~ioiojo/export-anytype/tree/master/item/lua-c-api/zig/internal/luautils/luautils.go