// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie // SPDX-License-Identifier: MIT const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const zigwin32 = b.dependency("zigwin32", .{}); const exe = b.addExecutable(.{ .name = "clipwatch", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "win32", .module = zigwin32.module("win32") }, }, }), }); b.installArtifact(exe); // Note: clipwatch needs to own the tty, so prefer running the installed // binary directly (./zig-out/bin/clipwatch) over `zig build run`. const run_step = b.step("run", "Run clipwatch"); const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| run_cmd.addArgs(args); run_step.dependOn(&run_cmd.step); const exe_tests = b.addTest(.{ .root_module = exe.root_module, }); const run_exe_tests = b.addRunArtifact(exe_tests); const test_step = b.step("test", "Run tests"); test_step.dependOn(&run_exe_tests.step); // Sign release artifacts with a minisign key, using the minizign module: // zig build sign -- ... // The helper is compiled and run as part of this step — it is never // installed or shipped. The dependency is lazy, so it is only fetched // when the sign step is actually built. const sign_step = b.step("sign", "Sign files with a minisign key (-- ...)"); if (b.lazyDependency("minizign", .{ .target = target, .optimize = optimize })) |minizign| { const sign_exe = b.addExecutable(.{ .name = "clipwatch-sign", .root_module = b.createModule(.{ .root_source_file = b.path("src/sign.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "minizign", .module = minizign.module("minizign") }, }, }), }); const run_sign = b.addRunArtifact(sign_exe); if (b.args) |args| run_sign.addArgs(args); sign_step.dependOn(&run_sign.step); } }