Skip to content

Commit 22a6f9f

Browse files
committed
Simplify test module by linking to main luaz module
1 parent 36bb993 commit 22a6f9f

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

build.zig

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,7 @@ pub fn build(b: *std.Build) !void {
131131
mod.linkLibrary(luau_codegen);
132132
mod.linkLibrary(luau_compiler);
133133

134-
const exe = b.addExecutable(.{
135-
.name = "luau-compile",
136-
.root_module = mod,
137-
});
138-
134+
const exe = b.addExecutable(.{ .name = "luau-compile", .root_module = mod });
139135
const run = b.addRunArtifact(exe);
140136

141137
if (b.args) |args| {
@@ -236,10 +232,7 @@ pub fn build(b: *std.Build) !void {
236232
mod.addImport("c", c_module);
237233

238234
// Add C wrapper
239-
mod.addCSourceFile(.{
240-
.file = b.path("src/handler.cpp"),
241-
.flags = flags,
242-
});
235+
mod.addCSourceFile(.{ .file = b.path("src/handler.cpp"), .flags = flags });
243236
mod.addCMacro("LUA_VECTOR_SIZE", b.fmt("{d}", .{opts.vector_size}));
244237
mod.addIncludePath(luau_dep.path("VM/include"));
245238
mod.addIncludePath(luau_dep.path("Common/include"));
@@ -278,21 +271,10 @@ pub fn build(b: *std.Build) !void {
278271
.optimize = optimize,
279272
});
280273

274+
test_mod.addImport("luaz", b.modules.get("luaz").?);
281275
test_mod.addImport("c", c_module);
282276

283-
const unit_tests = b.addTest(.{
284-
.root_module = test_mod,
285-
});
286-
287-
// Add C wrapper
288-
unit_tests.root_module.addCSourceFile(.{
289-
.file = b.path("src/handler.cpp"),
290-
.flags = flags,
291-
});
292-
unit_tests.root_module.addCMacro("LUA_VECTOR_SIZE", b.fmt("{d}", .{opts.vector_size}));
293-
unit_tests.root_module.addIncludePath(luau_dep.path("VM/include"));
294-
unit_tests.root_module.addIncludePath(luau_dep.path("Common/include"));
295-
unit_tests.root_module.addIncludePath(b.path("src"));
277+
const unit_tests = b.addTest(.{ .root_module = test_mod });
296278

297279
// See https://zig.news/squeek502/code-coverage-for-zig-1dk1
298280
if (opts.cover) {
@@ -305,9 +287,6 @@ pub fn build(b: *std.Build) !void {
305287
});
306288
}
307289

308-
unit_tests.linkLibrary(luau_vm);
309-
unit_tests.linkLibrary(luau_codegen);
310-
unit_tests.linkLibrary(luau_compiler);
311290
unit_tests.linkLibCpp();
312291

313292
const run_tests = b.addRunArtifact(unit_tests);
@@ -331,10 +310,7 @@ pub fn build(b: *std.Build) !void {
331310

332311
mod.addImport("luaz", b.modules.get("luaz").?);
333312

334-
const guided_tour = b.addExecutable(.{
335-
.name = "guided-tour",
336-
.root_module = mod,
337-
});
313+
const guided_tour = b.addExecutable(.{ .name = "guided-tour", .root_module = mod });
338314

339315
const run_guided_tour = b.addRunArtifact(guided_tour);
340316
if (b.args) |args| {

0 commit comments

Comments
 (0)