@@ -51,8 +51,9 @@ pub fn build(b: *Build) void {
51
51
else = > buildLua (b , target , optimize , upstream , lang , shared ),
52
52
};
53
53
54
- // Expose the Lua artifact
55
- b .installArtifact (lib );
54
+ // Expose the Lua artifact, and get an install step that header translation can refer to
55
+ const install_lib = b .addInstallArtifact (lib , .{});
56
+ b .getInstallStep ().dependOn (& install_lib .step );
56
57
57
58
switch (lang ) {
58
59
.luau = > {
@@ -66,6 +67,21 @@ pub fn build(b: *Build) void {
66
67
67
68
ziglua .linkLibrary (lib );
68
69
70
+ // lib must expose all headers included by these root headers
71
+ const c_header_path = switch (lang ) {
72
+ .luajit = > b .path ("include/luajit_all.h" ),
73
+ .luau = > b .path ("include/luau_all.h" ),
74
+ else = > b .path ("include/lua_all.h" ),
75
+ };
76
+ const c_headers = b .addTranslateC (.{
77
+ .root_source_file = c_header_path ,
78
+ .target = target ,
79
+ .optimize = optimize ,
80
+ });
81
+ c_headers .addIncludeDir (b .getInstallPath (install_lib .h_dir .? , "" ));
82
+ c_headers .step .dependOn (& install_lib .step );
83
+ ziglua .addImport ("c" , c_headers .createModule ());
84
+
69
85
// Tests
70
86
const tests = b .addTest (.{
71
87
.root_source_file = b .path ("src/tests.zig" ),
@@ -235,10 +251,10 @@ fn buildLuau(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.Opti
235
251
lib .addCSourceFile (.{ .file = b .path ("src/luau.cpp" ), .flags = & flags });
236
252
lib .linkLibCpp ();
237
253
238
- // It may not be as likely that other software links against Luau, but might as well expose these anyway
239
254
lib .installHeader (upstream .path ("VM/include/lua.h" ), "lua.h" );
240
255
lib .installHeader (upstream .path ("VM/include/lualib.h" ), "lualib.h" );
241
256
lib .installHeader (upstream .path ("VM/include/luaconf.h" ), "luaconf.h" );
257
+ lib .installHeader (upstream .path ("Compiler/include/luacode.h" ), "luacode.h" );
242
258
243
259
return lib ;
244
260
}
0 commit comments