-
Notifications
You must be signed in to change notification settings - Fork 63
allow using system lua #186
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
Open
p00f
wants to merge
1
commit into
natecraddock:main
Choose a base branch
from
p00f:system-lua
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ pub fn build(b: *Build) void { | |
| const lang = b.option(Language, "lang", "Lua language version to build") orelse .lua54; | ||
| const library_name = b.option([]const u8, "library_name", "Library name for lua linking, default is `lua`") orelse "lua"; | ||
| const shared = b.option(bool, "shared", "Build shared library instead of static") orelse false; | ||
| const system_lua = b.option(bool, "system_lua", "Use system lua") orelse false; | ||
| const luau_use_4_vector = b.option(bool, "luau_use_4_vector", "Build Luau to use 4-vectors instead of the default 3-vector.") orelse false; | ||
| const lua_user_h = b.option(Build.LazyPath, "lua_user_h", "Lazy path to user supplied c header file") orelse null; | ||
|
|
||
|
|
@@ -30,22 +31,36 @@ pub fn build(b: *Build) void { | |
| } | ||
|
|
||
| // Zig module | ||
| const zlua = b.addModule("zlua", .{ | ||
| const zlua = if (system_lua) b.addModule("zlua", .{ | ||
| .root_source_file = b.path("src/lib.zig"), | ||
| .target = target, | ||
| }) else b.addModule("zlua", .{ | ||
| .root_source_file = b.path("src/lib.zig"), | ||
| }); | ||
|
|
||
| // Expose build configuration to the ziglua module | ||
| const config = b.addOptions(); | ||
| config.addOption(Language, "lang", lang); | ||
| config.addOption(bool, "luau_use_4_vector", luau_use_4_vector); | ||
| config.addOption(bool, "system_lua", system_lua); | ||
| zlua.addOptions("config", config); | ||
|
|
||
| if (lang == .luau) { | ||
| const vector_size: usize = if (luau_use_4_vector) 4 else 3; | ||
| zlua.addCMacro("LUA_VECTOR_SIZE", b.fmt("{}", .{vector_size})); | ||
| } | ||
|
|
||
| if (b.lazyDependency(@tagName(lang), .{})) |upstream| { | ||
| if (system_lua) { | ||
| const link_mode: std.builtin.LinkMode = if (shared) .dynamic else .static; | ||
| switch (lang) { | ||
| .lua51 => zlua.linkSystemLibrary("lua5.1", .{ .preferred_link_mode = link_mode }), | ||
| .lua52 => zlua.linkSystemLibrary("lua5.2", .{ .preferred_link_mode = link_mode }), | ||
| .lua53 => zlua.linkSystemLibrary("lua5.3", .{ .preferred_link_mode = link_mode }), | ||
| .lua54 => zlua.linkSystemLibrary("lua5.4", .{ .preferred_link_mode = link_mode }), | ||
| .luajit => zlua.linkSystemLibrary("luajit", .{ .preferred_link_mode = link_mode }), | ||
| .luau => @panic("luau not supported for system lua"), | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the luau package in my distro doesn't come with libraries or headers |
||
| } | ||
| } else if (b.lazyDependency(@tagName(lang), .{})) |upstream| { | ||
| const lib = switch (lang) { | ||
| .luajit => luajit_setup.configure(b, target, optimize, upstream, shared), | ||
| .luau => luau_setup.configure(b, target, optimize, upstream, luau_use_4_vector), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't cross compile when using system lua so this should be fine