-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrating with LuaRocks #21
Comments
I use the standard headers provided by lua and luajit. So this makes it compatible with whatever luarocks is doing to build and link. I am following this guide: https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Unix Lua doesn't build correctly using their script because the lua tar.gz moved. LuaRocks requires an interpreter to run for tasks such as downloading rocks. Download and install lua. I am using a custom directory here because I dont like installing non-aur programs into my system.
Next up is configuring and installing LuaRocks. I am using hard copied paths below that will only work for me. However, beyond the home /home/mkp/src/Lua.NET prefix, you want to target the relevant directories. This configures it so that it will use the lua interpreter installed above and keep the rocks tree separate. This will be handy for giving to liblua when requiring.
Question now is how to hook everything up with this sane install. require() will search various directories. But first we need a package installed.
LuaRocks builds shared libraries and the entry point is typically core.{so,dll} However, we do know that it lobbed everything in luarocks_install/rocks.
Looking at the cookie.lua example it appears that libraries are required from the rocks/lib/lua/5.4 rocks/share/lua/5.4 directory.
This means that as long as we 1. target the appropriate lua version (luarocks supports multi-version), 2. link the appropriate lua dll to the resulting binaries (enabled through config), 3. provide lua the rocks install paths as mentioned in the above paragraph, we should be able to integrate luarocks seemlessly. To resolve 1 and 3, this will need to be handled in-code. This is the print-out of the package in our
We are using a non-standard /usr/local/share/lua/5.4 directory, so for path you will need to concat this string with the share directory something like using LuaNET.Lua54;
using static LuaNET.Lua54.Lua;
lua_State L = luaL_newstate();
if (L == 0)
{
Console.WriteLine("Unable to create context!");
}
luaL_openlibs(L);
// TODO: concat package.cpath package.path with above information
lua_pushcfunction(L, lfunc);
Console.WriteLine(lua_pcall(L, 0, 0, 0));
lua_close(L); To resolve 2, we can use
This resolves the symbols for us, as the rocks built for us are not linked to anything, theyre just configured with symbols they could import via the headers we suppied with the lua reply we built above. However, it wont be linked to Lua.NET's shared libraries. This can also be configured through the config. Somehow. I would recommend you do so, so that you dont have to lug around yet another shared library in addition to the ones I provide with Lua.NET automatically. |
A REPL environment is NOT needed for LuaRocks. Just something able to execute a script with param args. So some internal solution could be resolved for dependency management as well. |
This issue serves for discussion on integrating LuaRocks with Lua.NET.
The text was updated successfully, but these errors were encountered: