@@ -39,53 +39,53 @@ pub fn build(b: *Build) void {
3939 zlua .addCMacro ("LUA_VECTOR_SIZE" , b .fmt ("{}" , .{vector_size }));
4040 }
4141
42- const upstream = b .dependency (@tagName (lang ), .{});
43-
44- const lib = switch (lang ) {
45- .luajit = > luajit_setup .configure (b , target , optimize , upstream , shared ),
46- .luau = > luau_setup .configure (b , target , optimize , upstream , luau_use_4_vector ),
47- else = > lua_setup .configure (b , target , optimize , upstream , lang , shared ),
48- };
42+ if (b .lazyDependency (@tagName (lang ), .{})) | upstream | {
43+ const lib = switch (lang ) {
44+ .luajit = > luajit_setup .configure (b , target , optimize , upstream , shared ),
45+ .luau = > luau_setup .configure (b , target , optimize , upstream , luau_use_4_vector ),
46+ else = > lua_setup .configure (b , target , optimize , upstream , lang , shared ),
47+ };
48+
49+ // Expose the Lua artifact, and get an install step that header translation can refer to
50+ const install_lib = b .addInstallArtifact (lib , .{});
51+ b .getInstallStep ().dependOn (& install_lib .step );
52+
53+ switch (lang ) {
54+ .luau = > {
55+ zlua .addIncludePath (upstream .path ("Common/include" ));
56+ zlua .addIncludePath (upstream .path ("Compiler/include" ));
57+ zlua .addIncludePath (upstream .path ("Ast/include" ));
58+ zlua .addIncludePath (upstream .path ("VM/include" ));
59+ },
60+ else = > zlua .addIncludePath (upstream .path ("src" )),
61+ }
62+
63+ zlua .linkLibrary (lib );
64+
65+ // lib must expose all headers included by these root headers
66+ const c_header_path = switch (lang ) {
67+ .luajit = > b .path ("include/luajit_all.h" ),
68+ .luau = > b .path ("include/luau_all.h" ),
69+ else = > b .path ("include/lua_all.h" ),
70+ };
71+ const c_headers = b .addTranslateC (.{
72+ .root_source_file = c_header_path ,
73+ .target = target ,
74+ .optimize = optimize ,
75+ });
76+ c_headers .addIncludePath (lib .getEmittedIncludeTree ());
77+ c_headers .step .dependOn (& install_lib .step );
78+
79+ const ziglua_c = b .addModule ("ziglua-c" , .{
80+ .root_source_file = c_headers .getOutput (),
81+ .target = c_headers .target ,
82+ .optimize = c_headers .optimize ,
83+ .link_libc = c_headers .link_libc ,
84+ });
4985
50- // Expose the Lua artifact, and get an install step that header translation can refer to
51- const install_lib = b .addInstallArtifact (lib , .{});
52- b .getInstallStep ().dependOn (& install_lib .step );
53-
54- switch (lang ) {
55- .luau = > {
56- zlua .addIncludePath (upstream .path ("Common/include" ));
57- zlua .addIncludePath (upstream .path ("Compiler/include" ));
58- zlua .addIncludePath (upstream .path ("Ast/include" ));
59- zlua .addIncludePath (upstream .path ("VM/include" ));
60- },
61- else = > zlua .addIncludePath (upstream .path ("src" )),
86+ zlua .addImport ("c" , ziglua_c );
6287 }
6388
64- zlua .linkLibrary (lib );
65-
66- // lib must expose all headers included by these root headers
67- const c_header_path = switch (lang ) {
68- .luajit = > b .path ("include/luajit_all.h" ),
69- .luau = > b .path ("include/luau_all.h" ),
70- else = > b .path ("include/lua_all.h" ),
71- };
72- const c_headers = b .addTranslateC (.{
73- .root_source_file = c_header_path ,
74- .target = target ,
75- .optimize = optimize ,
76- });
77- c_headers .addIncludePath (lib .getEmittedIncludeTree ());
78- c_headers .step .dependOn (& install_lib .step );
79-
80- const ziglua_c = b .addModule ("ziglua-c" , .{
81- .root_source_file = c_headers .getOutput (),
82- .target = c_headers .target ,
83- .optimize = c_headers .optimize ,
84- .link_libc = c_headers .link_libc ,
85- });
86-
87- zlua .addImport ("c" , ziglua_c );
88-
8989 // Tests
9090 const tests = b .addTest (.{
9191 .root_source_file = b .path ("src/tests.zig" ),
0 commit comments