const std = @import("std"); // Although this function looks imperative, note that its job is to // declaratively construct a build graph that will be executed by an external // runner. pub fn build(b: *std.Build) void { // Standard target options allows the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which // means any target is allowed, and the default is native. Other options // for restricting supported target set are available. const target = b.standardTargetOptions(.{}); // Standard optimization options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not // set a preferred release mode, allowing the user to decide how to optimize. const optimize = b.standardOptimizeOption(.{}); const seizer = b.dependency("seizer", .{ .target = target, .optimize = optimize, }); const exe = b.addExecutable(.{ .name = "seizer-solitaire", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); exe.root_module.addImport("seizer", seizer.module("seizer")); b.installArtifact(exe); // additionally generate an HTML file with the wasm module embedded when we use the wasi target if (target.result.os.tag == .wasi) { exe.wasi_exec_model = .reactor; const bundle_webpage_exe = seizer.artifact("bundle-webpage"); const bundle_webpage = b.addRunArtifact(bundle_webpage_exe); bundle_webpage.addArtifactArg(exe); const install_html = b.addInstallFile(bundle_webpage.captureStdOut(), "www/seizer-solitaire.html"); b.getInstallStep().dependOn(&install_html.step); } const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); const exe_unit_tests = b.addTest(.{ .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); exe_unit_tests.root_module.addImport("seizer", seizer.module("seizer")); const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); // Similar to creating the run step earlier, this exposes a `test` step to // the `zig build --help` menu, providing a way for the user to request // running the unit tests. const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_exe_unit_tests.step); }