Something went wrong. Try again.
DMARC (RFC 7489) for Zig: the record grammar, identifier alignment, and policy discovery by DNS tree walk rather than a public suffix list.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091// SPDX-FileCopyrightText: 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
const std = @import("std");
pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const docs_port = b.option(u16, "docs-port", "Port for `zig build docs-serve` (default 8000)") orelse 8000;
const mod = b.addModule("dmarc", .{ .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize, });
// A tool for looking at records, which is also what gives the // package something to install. const exe = b.addExecutable(.{ .name = "dmarc", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "dmarc", .module = mod }, }, }), }); b.installArtifact(exe);
const run = b.addRunArtifact(exe); run.step.dependOn(b.getInstallStep()); run.addPassthruArgs(); b.step("run", "Run the dmarc tool").dependOn(&run.step);
// Compiled with LLVM: the self-hosted backend emits no coverage // instrumentation, so neither `--fuzz` nor kcov sees anything under it. const mod_tests = b.addTest(.{ .root_module = mod, .use_llvm = true, }); const run_mod_tests = b.addRunArtifact(mod_tests);
const test_step = b.step("test", "Run the unit tests"); test_step.dependOn(&run_mod_tests.step);
// The documentation comes out of the compiler as a side effect of // building the module as a library. const library = b.addLibrary(.{ .name = "dmarc", .root_module = mod }); const install_docs = b.addInstallDirectory(.{ .source_dir = library.getEmittedDocs(), .install_dir = .prefix, .install_subdir = "docs", }); const docs_step = b.step("docs", "Build the API documentation into zig-out/docs"); docs_step.dependOn(&install_docs.step);
// It has to be served rather than opened: the viewer fetches // sources.tar and main.wasm at runtime and a browser refuses either // from a file:// page. const docs_server = b.addExecutable(.{ .name = "docs-server", .root_module = b.createModule(.{ .root_source_file = b.path("tools/docs_server.zig"), // Always the machine running the build, never whatever // -Dtarget the library is being built for. .target = b.graph.host, .optimize = .Debug, }), }); const run_docs_server = b.addRunArtifact(docs_server); run_docs_server.step.dependOn(&install_docs.step); run_docs_server.addDirectoryArg(library.getEmittedDocs()); run_docs_server.addArg(b.fmt("{d}", .{docs_port})); run_docs_server.stdio = .inherit; const docs_serve_step = b.step("docs-serve", "Serve the API documentation over HTTP"); docs_serve_step.dependOn(&run_docs_server.step);
test_step.dependOn(&b.addRunArtifact( b.addTest(.{ .root_module = docs_server.root_module }), ).step);
// "Compile everything without running it", so that a file nothing // else reaches cannot quietly stop building. const check_step = b.step("check", "Type-check without emitting a binary"); check_step.dependOn(&mod_tests.step); check_step.dependOn(&docs_server.step); check_step.dependOn(&exe.step);}