-
Notifications
You must be signed in to change notification settings - Fork 46
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
Support system and vendored Lua libraries #75
Comments
Hey! I took a look at how redis/zkv uses Lua, and it seems that they have made several modifications. For example, the Even if this was only adding the following
I would still be hesitant to add it. Because Lua is so small and easy to modify, I'm sure Redis isn't alone in making modifications to Lua, and I don't want to set a precedent in modifying the Lua sources bundled with Ziglua. Hopefully that is understandable. But! I do think there is a solution here. I think Ziglua should be able to support system and vendored Lua sources. Currently it only supports using the Zig package manager Lua in the build.zig.zon. I know you want to remove your vendored Lua in zkv, but I'm really not sure you can do that because of the modifications. (You could move it to a separate repo though and use the Zig package manager to pull it in at build time.) What do you think about that? |
Also I think I'll move this issue to the Ziglua repo because I think it makes more sense there |
Hey, thanks. So far I've got this: https://github.com/terrablue/zua, which is working. But if possible, it would be nice to deduplicate work, and Ziglua is already doing some nice binding work. Seeing as I generally want to transition zkv to using Zig not just for the build but also for the source code, Ziglua is attractive here. Perhaps it could be possible to use a repository as a target in addition to the targets you have in build.zig.zon? That would probably allow me to get rid my own build.zig.zon/build.zig in the zua repository. (Edit: also, feel free to move the issue, I do think it better fits now in the Ziglua repo.) |
I agree, it would be ideal if Ziglua can integrate nicely with other Lua sources. I'll take a look later today on possible solutions and follow up. I'll move the issue |
I just solved the first part of this in 3b85c5d. This ensures only the required version of Lua is fetched from the package manager. Next we need to add a way to link against a different version of Lua. Because this use case is also needed for linking against system Lua libraries, I renamed this issue to reflect both needed features. Here are my ideas on how to proceed:
So more concretely, you might do something like this const zua = b.dependency("zua", .{
.target = target,
.optimize = optimize,
});
const ziglua = b.dependency("ziglua", .{
.target = target,
.optimize = optimize,
// Zua (the Lua used by Redis) is Lua 5.1
.lang = .lua51,
// Link a custom build of Lua
.source = .custom,
});
// Now link zua and ziglua to your project I think we can find a way to get this working, though I haven't tested. I'm open to other ideas though if you have them! One issue is Ziglua itself can't bind any custom functions in the ziglua.Lua struct. But we can expose Looking at ziglang/zig#18778, this seems very similar to the use case of system packages. I wonder if there should be some support in the build system / package manager for this. |
Sounds good to me! It there anything in particular I'd need to do for the |
At the moment, I don't think there is anything you need to do with zua. Again, this is just my first thoughts on how to proceed. I don't know for sure if it will work, but I'll give it a go sometime in the next few days and let you know how it goes |
Hey, I'm using your ziglua project to devendor lua in my redis fork. However, the vendored lua exposes two additional functions that it seems upstream doesn't otherwise expose (https://github.com/terrablue/zkv/blob/master/deps/lua/src/lua.h#L361-L362).
Would you mind exposing those functions as well? I find it very convenient to use ziglua as a dependency instead of rolling out my own.
The text was updated successfully, but these errors were encountered: