size: 1 KiB
| 1 | const std = @import("std"); |
| 2 | |
| 3 | pub fn build(b: *std.Build) void { |
| 4 | const target = b.standardTargetOptions(.{}); |
| 5 | const optimize = b.standardOptimizeOption(.{}); |
| 6 | const exe = b.addExecutable(.{ |
| 7 | .name = "loa", |
| 8 | .root_module = b.createModule(.{ |
| 9 | .root_source_file = b.path("src/main.zig"), |
| 10 | .target = target, |
| 11 | .optimize = optimize, |
| 12 | }), |
| 13 | }); |
| 14 | |
| 15 | b.installArtifact(exe); |
| 16 | |
| 17 | const use_system_lua = b.systemIntegrationOption("lua", .{}); |
| 18 | |
| 19 | const lua_dep = b.dependency("zlua", .{ |
| 20 | .target = target, |
| 21 | .optimize = optimize, |
| 22 | .shared = use_system_lua, |
| 23 | }); |
| 24 | if (use_system_lua) { |
| 25 | exe.linkSystemLibrary("lua"); |
| 26 | } |
| 27 | exe.root_module.addImport("zlua", lua_dep.module("zlua")); |
| 28 | |
| 29 | const run_step = b.step("run", "Run the app"); |
| 30 | |
| 31 | const run_cmd = b.addRunArtifact(exe); |
| 32 | run_step.dependOn(&run_cmd.step); |
| 33 | |
| 34 | run_cmd.step.dependOn(b.getInstallStep()); |
| 35 | |
| 36 | // This allows the user to pass arguments to the application in the build |
| 37 | // command itself, like this: `zig build run -- arg1 arg2 etc` |
| 38 | if (b.args) |args| { |
| 39 | run_cmd.addArgs(args); |
| 40 | } |
| 41 | |
| 42 | // Creates an executable that will run `test` blocks from the executable's |
| 43 | // root module. Note that test executables only test one module at a time, |
| 44 | // hence why we have to create two separate ones. |
| 45 | const exe_tests = b.addTest(.{ |
| 46 | .root_module = exe.root_module, |
| 47 | }); |
| 48 | |
| 49 | const run_exe_tests = b.addRunArtifact(exe_tests); |
| 50 | |
| 51 | const test_step = b.step("test", "Run tests"); |
| 52 | test_step.dependOn(&run_exe_tests.step); |
| 53 | } |