Merge pull request #175 from dwilliam62/fix/lua-header-mismatch
Browse files
[BUG] Build failed on Arch lua header mismatch
+11 −5 build.zig
| @@ -4,6 +4,8 @@ const zon = @import("build.zig.zon"); | |||
| 4 | pub fn build(b: *std.Build) void { | 4 | pub fn build(b: *std.Build) void { |
| 5 | const target = b.standardTargetOptions(.{}); | 5 | const target = b.standardTargetOptions(.{}); |
| 6 | const optimize = b.standardOptimizeOption(.{}); | 6 | const optimize = b.standardOptimizeOption(.{}); |
| 7 | + const lua_dep = b.dependency("lua", .{}); | ||
| 8 | + const lua_headers = lua_dep.path("src/"); | ||
| 7 | 9 | ||
| 8 | const exe = b.addExecutable(.{ | 10 | const exe = b.addExecutable(.{ |
| 9 | .name = "oxwm", | 11 | .name = "oxwm", |
| @@ -24,7 +26,7 @@ pub fn build(b: *std.Build) void { | |||
| 24 | 26 | ||
| 25 | exe.use_lld = false; | 27 | exe.use_lld = false; |
| 26 | 28 | ||
| 27 | - const lua = buildLua(b, target, optimize); | 29 | + const lua = buildLua(b, lua_dep, target, optimize); |
| 28 | exe.linkLibrary(lua); | 30 | exe.linkLibrary(lua); |
| 29 | exe.linkSystemLibrary("X11"); | 31 | exe.linkSystemLibrary("X11"); |
| 30 | exe.linkSystemLibrary("Xinerama"); | 32 | exe.linkSystemLibrary("Xinerama"); |
| @@ -61,6 +63,7 @@ pub fn build(b: *std.Build) void { | |||
| 61 | }), | 63 | }), |
| 62 | }); | 64 | }); |
| 63 | src_main_unit_tests.use_lld = false; | 65 | src_main_unit_tests.use_lld = false; |
| 66 | + src_main_unit_tests.root_module.addIncludePath(lua_headers); | ||
| 64 | src_main_unit_tests.linkLibrary(lua); | 67 | src_main_unit_tests.linkLibrary(lua); |
| 65 | src_main_unit_tests.linkSystemLibrary("X11"); | 68 | src_main_unit_tests.linkSystemLibrary("X11"); |
| 66 | src_main_unit_tests.linkSystemLibrary("Xinerama"); | 69 | src_main_unit_tests.linkSystemLibrary("Xinerama"); |
| @@ -77,11 +80,14 @@ pub fn build(b: *std.Build) void { | |||
| 77 | }), | 80 | }), |
| 78 | }); | 81 | }); |
| 79 | lua_config_tests.use_lld = false; | 82 | lua_config_tests.use_lld = false; |
| 80 | - lua_config_tests.root_module.addImport("lua", b.createModule(.{ | 83 | + lua_config_tests.root_module.addIncludePath(lua_headers); |
| 84 | + const lua_config_module = b.createModule(.{ | ||
| 81 | .root_source_file = b.path("src/config/lua.zig"), | 85 | .root_source_file = b.path("src/config/lua.zig"), |
| 82 | .target = target, | 86 | .target = target, |
| 83 | .optimize = optimize, | 87 | .optimize = optimize, |
| 84 | - })); | 88 | + }); |
| 89 | + lua_config_module.addIncludePath(lua_headers); | ||
| 90 | + lua_config_tests.root_module.addImport("lua", lua_config_module); | ||
| 85 | lua_config_tests.linkLibrary(lua); | 91 | lua_config_tests.linkLibrary(lua); |
| 86 | lua_config_tests.linkLibC(); | 92 | lua_config_tests.linkLibC(); |
| 87 | test_step.dependOn(&b.addRunArtifact(lua_config_tests).step); | 93 | test_step.dependOn(&b.addRunArtifact(lua_config_tests).step); |
| @@ -159,8 +165,8 @@ fn addXwaylandRun(b: *std.Build, exe: *std.Build.Step.Compile) *std.Build.Step.R | |||
| 159 | return run_wm; | 165 | return run_wm; |
| 160 | } | 166 | } |
| 161 | 167 | ||
| 162 | -fn buildLua(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.Compile { | 168 | +fn buildLua(b: *std.Build, lua_dep: *std.Build.Dependency, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.Compile { |
| 163 | - const lua_src = b.dependency("lua", .{}); | 169 | + const lua_src = lua_dep; |
| 164 | const lua = b.addLibrary(.{ | 170 | const lua = b.addLibrary(.{ |
| 165 | .name = "lua", | 171 | .name = "lua", |
| 166 | .root_module = b.createModule(.{ | 172 | .root_module = b.createModule(.{ |