@@ -8,27 +8,26 @@ const applyPatchToFile = @import("utils.zig").applyPatchToFile;
88pub 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
246248const luajit_lib = [_ ][]const u8 {
0 commit comments