const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const exe = b.addExecutable(.{ .name = "nxdns", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }), }); // Link SQLite exe.linkSystemLibrary("sqlite3"); exe.linkLibC(); b.installArtifact(exe); // Run command 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 nxdns"); run_step.dependOn(&run_cmd.step); // Unit tests for main (includes all modules via imports - runs all embedded tests) const main_tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }), }); main_tests.linkSystemLibrary("sqlite3"); main_tests.linkLibC(); const run_main_tests = b.addRunArtifact(main_tests); // Unit tests for DNS packet module (self-contained) const dns_tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/dns/packet.zig"), .target = target, .optimize = optimize, }), }); const run_dns_tests = b.addRunArtifact(dns_tests); const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_main_tests.step); test_step.dependOn(&run_dns_tests.step); // Memory test binary const memtest = b.addExecutable(.{ .name = "memtest", .root_module = b.createModule(.{ .root_source_file = b.path("src/memtest.zig"), .target = target, .optimize = .ReleaseFast, }), }); const run_memtest = b.addRunArtifact(memtest); const memtest_step = b.step("memtest", "Run memory test with real blocklists"); memtest_step.dependOn(&run_memtest.step); }