@@ -51,8 +51,9 @@ pub fn build(b: *Build) void {
5151 else = > buildLua (b , target , optimize , upstream , lang , shared ),
5252 };
5353
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 );
5657
5758 switch (lang ) {
5859 .luau = > {
@@ -66,6 +67,21 @@ pub fn build(b: *Build) void {
6667
6768 ziglua .linkLibrary (lib );
6869
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+
6985 // Tests
7086 const tests = b .addTest (.{
7187 .root_source_file = b .path ("src/tests.zig" ),
@@ -235,10 +251,10 @@ fn buildLuau(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.Opti
235251 lib .addCSourceFile (.{ .file = b .path ("src/luau.cpp" ), .flags = & flags });
236252 lib .linkLibCpp ();
237253
238- // It may not be as likely that other software links against Luau, but might as well expose these anyway
239254 lib .installHeader (upstream .path ("VM/include/lua.h" ), "lua.h" );
240255 lib .installHeader (upstream .path ("VM/include/lualib.h" ), "lualib.h" );
241256 lib .installHeader (upstream .path ("VM/include/luaconf.h" ), "luaconf.h" );
257+ lib .installHeader (upstream .path ("Compiler/include/luacode.h" ), "luacode.h" );
242258
243259 return lib ;
244260}
0 commit comments