Skip to content

Commit e20bb29

Browse files
committed
fix(build): update to zig 0.15.0-dev.1034+bd97b6618
1 parent 6a11845 commit e20bb29

File tree

5 files changed

+99
-87
lines changed

5 files changed

+99
-87
lines changed

build.zig

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ pub fn build(b: *Build) void {
9999

100100
// Tests
101101
const tests = b.addTest(.{
102-
.root_source_file = b.path("src/tests.zig"),
103-
.target = target,
104-
.optimize = optimize,
102+
.root_module = b.createModule(.{
103+
.root_source_file = b.path("src/tests.zig"),
104+
.target = target,
105+
.optimize = optimize,
106+
}),
105107
});
106108
tests.root_module.addImport("zlua", zlua);
107109

@@ -123,9 +125,11 @@ pub fn build(b: *Build) void {
123125
for (examples) |example| {
124126
const exe = b.addExecutable(.{
125127
.name = example[0],
126-
.root_source_file = b.path(example[1]),
127-
.target = target,
128-
.optimize = optimize,
128+
.root_module = b.createModule(.{
129+
.root_source_file = b.path(example[1]),
130+
.target = target,
131+
.optimize = optimize,
132+
}),
129133
});
130134
exe.root_module.addImport("zlua", zlua);
131135

@@ -143,9 +147,11 @@ pub fn build(b: *Build) void {
143147

144148
const docs = b.addObject(.{
145149
.name = "ziglua",
146-
.root_source_file = b.path("src/lib.zig"),
147-
.target = target,
148-
.optimize = optimize,
150+
.root_module = b.createModule(.{
151+
.root_source_file = b.path("src/lib.zig"),
152+
.target = target,
153+
.optimize = optimize,
154+
}),
149155
});
150156

151157
const install_docs = b.addInstallDirectory(.{
@@ -159,9 +165,11 @@ pub fn build(b: *Build) void {
159165

160166
// definitions example
161167
const def_exe = b.addExecutable(.{
162-
.root_source_file = b.path("examples/define-exe.zig"),
163168
.name = "define-zig-types",
164-
.target = target,
169+
.root_module = b.createModule(.{
170+
.root_source_file = b.path("examples/define-exe.zig"),
171+
.target = target,
172+
}),
165173
});
166174
def_exe.root_module.addImport("zlua", zlua);
167175
var run_def_exe = b.addRunArtifact(def_exe);

build/lua.zig

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,16 @@ pub fn configure(
4141
else => unreachable,
4242
};
4343

44-
const lib = if (shared)
45-
b.addSharedLibrary(.{
46-
.name = library_name,
47-
.target = target,
48-
.optimize = optimize,
49-
.version = version,
50-
})
51-
else
52-
b.addStaticLibrary(.{
53-
.name = library_name,
54-
.target = target,
55-
.optimize = optimize,
56-
.version = version,
57-
});
44+
const lib = b.createModule(.{
45+
.target = target,
46+
.optimize = optimize,
47+
});
48+
const library = b.addLibrary(.{
49+
.name = library_name,
50+
.version = version,
51+
.linkage = if (shared) .dynamic else .static,
52+
.root_module = lib,
53+
});
5854

5955
lib.addIncludePath(upstream.path("src"));
6056

@@ -102,24 +98,24 @@ pub fn configure(
10298
if (lang == .lua51) {
10399
const patched = applyPatchToFile(b, b.graph.host, upstream.path("src/ldo.c"), b.path("build/lua-5.1.patch"), "ldo.c");
104100

105-
lib.step.dependOn(&patched.run.step);
101+
library.step.dependOn(&patched.run.step);
106102

107103
lib.addCSourceFile(.{ .file = patched.output, .flags = &flags });
108104
}
109105

110-
lib.linkLibC();
106+
library.linkLibC();
111107

112-
lib.installHeader(upstream.path("src/lua.h"), "lua.h");
113-
lib.installHeader(upstream.path("src/lualib.h"), "lualib.h");
114-
lib.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h");
115-
lib.installHeader(upstream.path("src/luaconf.h"), "luaconf.h");
108+
library.installHeader(upstream.path("src/lua.h"), "lua.h");
109+
library.installHeader(upstream.path("src/lualib.h"), "lualib.h");
110+
library.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h");
111+
library.installHeader(upstream.path("src/luaconf.h"), "luaconf.h");
116112

117113
if (lua_user_h) |user_h| {
118-
lib.addIncludePath(user_h.dirname());
119-
lib.installHeader(user_h, user_header);
114+
library.addIncludePath(user_h.dirname());
115+
library.installHeader(user_h, user_header);
120116
}
121117

122-
return lib;
118+
return library;
123119
}
124120

125121
const lua_base_source_files = [_][]const u8{

build/luajit.zig

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,26 @@ const applyPatchToFile = @import("utils.zig").applyPatchToFile;
88
pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, upstream: *Build.Dependency, shared: bool) *Step.Compile {
99
// TODO: extract this to the main build function because it is shared between all specialized build functions
1010

11-
const lib: *Step.Compile = if (shared)
12-
b.addSharedLibrary(.{
13-
.name = "lua",
14-
.target = target,
15-
.optimize = optimize,
16-
.unwind_tables = .sync,
17-
})
18-
else
19-
b.addStaticLibrary(.{
20-
.name = "lua",
21-
.target = target,
22-
.optimize = optimize,
23-
.unwind_tables = .sync,
24-
});
11+
const lib = b.createModule(.{
12+
.target = target,
13+
.optimize = optimize,
14+
.unwind_tables = .sync,
15+
});
16+
const library = b.addLibrary(.{
17+
.name = "lua",
18+
.root_module = lib,
19+
.linkage = if (shared) .dynamic else .static,
20+
});
2521

2622
// Compile minilua interpreter used at build time to generate files
27-
const minilua = b.addExecutable(.{
28-
.name = "minilua",
23+
const minilua_mod = b.createModule(.{
2924
.target = b.graph.host, // Use host target for cross build
3025
.optimize = .ReleaseSafe,
3126
});
27+
const minilua = b.addExecutable(.{
28+
.name = "minilua",
29+
.root_module = minilua_mod,
30+
});
3231
minilua.linkLibC();
3332
// FIXME: remove branch when zig-0.15 is released and 0.14 can be dropped
3433
const builtin = @import("builtin");
@@ -106,11 +105,14 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
106105
const luajit_h = genversion_run.addOutputFileArg("luajit.h");
107106

108107
// Compile the buildvm executable used to generate other files
109-
const buildvm = b.addExecutable(.{
110-
.name = "buildvm",
108+
const vm_mod = b.createModule(.{
111109
.target = b.graph.host, // Use host target for cross build
112110
.optimize = .ReleaseSafe,
113111
});
112+
const buildvm = b.addExecutable(.{
113+
.name = "buildvm",
114+
.root_module = vm_mod,
115+
});
114116
buildvm.linkLibC();
115117
// FIXME: remove branch when zig-0.15 is released and 0.14 can be dropped
116118
if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 15) {
@@ -197,27 +199,27 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
197199
}
198200

199201
// Finally build LuaJIT after generating all the files
200-
lib.step.dependOn(&genversion_run.step);
201-
lib.step.dependOn(&buildvm_bcdef.step);
202-
lib.step.dependOn(&buildvm_ffdef.step);
203-
lib.step.dependOn(&buildvm_libdef.step);
204-
lib.step.dependOn(&buildvm_recdef.step);
205-
lib.step.dependOn(&buildvm_folddef.step);
206-
lib.step.dependOn(&buildvm_ljvm.step);
202+
library.step.dependOn(&genversion_run.step);
203+
library.step.dependOn(&buildvm_bcdef.step);
204+
library.step.dependOn(&buildvm_ffdef.step);
205+
library.step.dependOn(&buildvm_libdef.step);
206+
library.step.dependOn(&buildvm_recdef.step);
207+
library.step.dependOn(&buildvm_folddef.step);
208+
library.step.dependOn(&buildvm_ljvm.step);
207209

208-
lib.linkLibC();
210+
library.linkLibC();
209211

210-
lib.root_module.addCMacro("LUAJIT_UNWIND_EXTERNAL", "");
212+
lib.addCMacro("LUAJIT_UNWIND_EXTERNAL", "");
211213

212-
lib.linkSystemLibrary("unwind");
214+
lib.linkSystemLibrary("unwind", .{});
213215

214-
lib.addIncludePath(upstream.path("src"));
215-
lib.addIncludePath(luajit_h.dirname());
216-
lib.addIncludePath(bcdef_header.dirname());
217-
lib.addIncludePath(ffdef_header.dirname());
218-
lib.addIncludePath(libdef_header.dirname());
219-
lib.addIncludePath(recdef_header.dirname());
220-
lib.addIncludePath(folddef_header.dirname());
216+
library.addIncludePath(upstream.path("src"));
217+
library.addIncludePath(luajit_h.dirname());
218+
library.addIncludePath(bcdef_header.dirname());
219+
library.addIncludePath(ffdef_header.dirname());
220+
library.addIncludePath(libdef_header.dirname());
221+
library.addIncludePath(recdef_header.dirname());
222+
library.addIncludePath(folddef_header.dirname());
221223

222224
lib.addCSourceFiles(.{
223225
.root = .{ .dependency = .{
@@ -229,18 +231,18 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
229231

230232
// FIXME: remove branch when zig-0.15 is released and 0.14 can be dropped
231233
if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 15) {
232-
lib.root_module.sanitize_c = false;
234+
lib.sanitize_c = false;
233235
} else {
234-
lib.root_module.sanitize_c = .off;
236+
lib.sanitize_c = .off;
235237
}
236238

237-
lib.installHeader(upstream.path("src/lua.h"), "lua.h");
238-
lib.installHeader(upstream.path("src/lualib.h"), "lualib.h");
239-
lib.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h");
240-
lib.installHeader(upstream.path("src/luaconf.h"), "luaconf.h");
241-
lib.installHeader(luajit_h, "luajit.h");
239+
library.installHeader(upstream.path("src/lua.h"), "lua.h");
240+
library.installHeader(upstream.path("src/lualib.h"), "lualib.h");
241+
library.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h");
242+
library.installHeader(upstream.path("src/luaconf.h"), "luaconf.h");
243+
library.installHeader(luajit_h, "luajit.h");
242244

243-
return lib;
245+
return library;
244246
}
245247

246248
const luajit_lib = [_][]const u8{

build/luau.zig

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ const Build = std.Build;
44
const Step = std.Build.Step;
55

66
pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, upstream: *Build.Dependency, luau_use_4_vector: bool) *Step.Compile {
7-
const lib = b.addStaticLibrary(.{
8-
.name = "luau",
7+
const lib = b.createModule(.{
98
.target = target,
109
.optimize = optimize,
10+
});
11+
const library = b.addLibrary(.{
12+
.name = "luau",
13+
.linkage = .static,
1114
.version = std.SemanticVersion{ .major = 0, .minor = 653, .patch = 0 },
15+
.root_module = lib,
1216
});
1317

1418
lib.addIncludePath(upstream.path("Common/include"));
@@ -33,14 +37,14 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
3337
.flags = &flags,
3438
});
3539
lib.addCSourceFile(.{ .file = b.path("src/luau.cpp"), .flags = &flags });
36-
lib.linkLibCpp();
40+
library.linkLibCpp();
3741

38-
lib.installHeader(upstream.path("VM/include/lua.h"), "lua.h");
39-
lib.installHeader(upstream.path("VM/include/lualib.h"), "lualib.h");
40-
lib.installHeader(upstream.path("VM/include/luaconf.h"), "luaconf.h");
41-
lib.installHeader(upstream.path("Compiler/include/luacode.h"), "luacode.h");
42+
library.installHeader(upstream.path("VM/include/lua.h"), "lua.h");
43+
library.installHeader(upstream.path("VM/include/lualib.h"), "lualib.h");
44+
library.installHeader(upstream.path("VM/include/luaconf.h"), "luaconf.h");
45+
library.installHeader(upstream.path("Compiler/include/luacode.h"), "luacode.h");
4246

43-
return lib;
47+
return library;
4448
}
4549

4650
const luau_source_files = [_][]const u8{

build/utils.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ pub fn applyPatchToFile(
1717
) PatchFile {
1818
const patch = b.addExecutable(.{
1919
.name = "patch",
20-
.root_source_file = b.path("build/patch.zig"),
21-
.target = target,
20+
.root_module = b.createModule(.{
21+
.root_source_file = b.path("build/patch.zig"),
22+
.target = target,
23+
}),
2224
});
2325

2426
const patch_run = b.addRunArtifact(patch);

0 commit comments

Comments
 (0)