Skip to content

Commit 0398af8

Browse files
committed
build: split out options struct for lua build configuration
1 parent da7499c commit 0398af8

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

build.zig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ pub fn build(b: *Build) void {
4949
const lib = switch (lang) {
5050
.luajit => luajit_setup.configure(b, target, optimize, upstream, shared),
5151
.luau => luau_setup.configure(b, target, optimize, upstream, luau_use_4_vector),
52-
else => lua_setup.configure(b, target, optimize, upstream, lang, shared, library_name, lua_user_h),
52+
else => lua_setup.configure(b, target, optimize, upstream, .{
53+
.lang = lang,
54+
.shared = shared,
55+
.library_name = library_name,
56+
.lua_user_h = lua_user_h,
57+
}),
5358
};
5459

5560
// Expose the Lua artifact, and get an install step that header translation can refer to

build/lua.zig

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,25 @@ pub const Language = enum {
1212
luau,
1313
};
1414

15-
pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, upstream: *Build.Dependency, lang: Language, shared: bool, library_name: []const u8, lua_user_h: ?Build.LazyPath) *Step.Compile {
15+
pub const Options = struct {
16+
lang: Language,
17+
shared: bool,
18+
library_name: []const u8,
19+
lua_user_h: ?Build.LazyPath,
20+
};
21+
22+
pub fn configure(
23+
b: *Build,
24+
target: Build.ResolvedTarget,
25+
optimize: std.builtin.OptimizeMode,
26+
upstream: *Build.Dependency,
27+
opts: Options,
28+
) *Step.Compile {
29+
const lang = opts.lang;
30+
const library_name = opts.library_name;
31+
const lua_user_h = opts.lua_user_h;
32+
const shared = opts.shared;
33+
1634
const version: std.SemanticVersion = switch (lang) {
1735
.lua51 => .{ .major = 5, .minor = 1, .patch = 5 },
1836
.lua52 => .{ .major = 5, .minor = 2, .patch = 4 },

0 commit comments

Comments
 (0)