this repo has no description

workflows: fix missing system libraries

altagos.dev c9cdf819 3d6965dc

verified
+45 -41
+8 -6
.tangled/workflows/build.yml
··· 1 1 when: 2 - - event: ["push", "pull_request"] 3 - branch: ["main"] 2 + - event: ["push", "pull_request"] 3 + branch: ["main", "workflows"] 4 4 5 5 engine: nixery 6 6 7 7 dependencies: 8 8 nixpkgs: 9 - - mise 9 + - mise 10 10 11 11 steps: 12 12 - name: Setup Zig 13 13 command: | 14 14 mise trust 15 - mise exec zig -- zig version 15 + mise exec zig -- zig version 16 16 - name: Run Tests 17 17 command: | 18 - mise exec zig -- zig build test --summary all 18 + eval "$(mise activate bash)" 19 + zig build test -Dbuild-gui=false --summary all 19 20 - name: Build ReleaseSafe 20 21 command: | 21 - mise exec zig -- zig build -Doptimize=ReleaseSafe -Ddocking 22 + eval "$(mise activate bash)" 23 + zig build -Doptimize=ReleaseSafe -Dbuild-gui=false
-18
.tangled/workflows/web.yml
··· 1 - when: 2 - - event: ["push", "pull_request"] 3 - branch: ["main"] 4 - 5 - engine: nixery 6 - 7 - dependencies: 8 - nixpkgs: 9 - - mise 10 - 11 - steps: 12 - - name: Setup Zig 13 - command: | 14 - mise trust 15 - mise exec zig -- zig version 16 - - name: Build ReleaseSafe 17 - command: | 18 - mise exec zig -- zig build -Doptimize=ReleaseSmall -Dtarget=wasm32-emscripten -Ddocking
+37 -17
build.zig
··· 5 5 const cimgui = @import("cimgui"); 6 6 7 7 const Options = struct { 8 + build_gui: bool, 8 9 mod_ft: *Build.Module, 9 10 mod_exe: *Build.Module, 10 11 dep_sokol: *Build.Dependency, ··· 17 18 const optimize = b.standardOptimizeOption(.{}); 18 19 19 20 const opt_docking = b.option(bool, "docking", "Build with docking support") orelse false; 21 + const build_gui_opt = b.option(bool, "build-gui", "When disabled only build factorio-toolbox library and not the gui app") orelse true; 20 22 21 23 const cimgui_conf = cimgui.getConfig(opt_docking); 22 24 ··· 60 62 mod_exe.addOptions("build_options", options_mod_exe); 61 63 62 64 const opts = Options{ 65 + .build_gui = build_gui_opt, 63 66 .mod_ft = mod_ft, 64 67 .mod_exe = mod_exe, 65 68 .dep_sokol = dep_sokol, ··· 69 72 if (target.result.cpu.arch.isWasm()) { 70 73 try buildWeb(b, opts); 71 74 } else { 72 - try buildNative(b, opts); 75 + if (opts.build_gui) { 76 + try buildNative(b, opts); 77 + } else { 78 + buildFTLib(b, opts); 79 + } 80 + tests(b, opts); 73 81 } 74 82 } 75 83 84 + fn buildFTLib(b: *Build, opts: Options) void { 85 + const lib = b.addLibrary(.{ 86 + .name = "factorio-toolbox", 87 + .root_module = opts.mod_ft, 88 + }); 89 + b.installArtifact(lib); 90 + } 91 + 76 92 fn buildNative(b: *Build, opts: Options) !void { 77 93 const exe = b.addExecutable(.{ 78 94 .name = "factorio_toolbox", ··· 90 106 if (b.args) |args| { 91 107 run_cmd.addArgs(args); 92 108 } 93 - 94 - const mod_tests = b.addTest(.{ 95 - .name = "mod tests", 96 - .root_module = opts.mod_ft, 97 - }); 98 - const run_mod_tests = b.addRunArtifact(mod_tests); 99 - 100 - const exe_tests = b.addTest(.{ 101 - .name = "exe tests", 102 - .root_module = opts.mod_exe, 103 - }); 104 - const run_exe_tests = b.addRunArtifact(exe_tests); 105 - 106 - const test_step = b.step("test", "Run tests"); 107 - test_step.dependOn(&run_mod_tests.step); 108 - test_step.dependOn(&run_exe_tests.step); 109 109 } 110 110 111 111 fn buildWeb(b: *Build, opts: Options) !void { ··· 138 138 }); 139 139 run.step.dependOn(&link_step.step); 140 140 b.step("run", "Run the web app").dependOn(&run.step); 141 + } 142 + 143 + fn tests(b: *Build, opts: Options) void { 144 + const test_step = b.step("test", "Run tests"); 145 + 146 + const mod_tests = b.addTest(.{ 147 + .name = "mod tests", 148 + .root_module = opts.mod_ft, 149 + }); 150 + const run_mod_tests = b.addRunArtifact(mod_tests); 151 + test_step.dependOn(&run_mod_tests.step); 152 + 153 + if (opts.build_gui) { 154 + const exe_tests = b.addTest(.{ 155 + .name = "exe tests", 156 + .root_module = opts.mod_exe, 157 + }); 158 + const run_exe_tests = b.addRunArtifact(exe_tests); 159 + test_step.dependOn(&run_exe_tests.step); 160 + } 141 161 } 142 162 143 163 fn createShaderModule(b: *Build, dep_sokol: *Build.Dependency) !*Build.Module {