atproto pds in zig pds.zat.dev
pds atproto
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174const std = @import("std");const manifest = @import("build.zig.zon");
pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const version = b.option([]const u8, "version", "Build version reported by /xrpc/_health") orelse manifest.version;
const zat = b.dependency("zat", .{ .target = target, .optimize = optimize, }); const zqlite = b.dependency("zqlite", .{ .target = target, .optimize = optimize, }); const webauthn = b.dependency("webauthn", .{ .target = target, .optimize = optimize, }); const metrics = b.dependency("metrics", .{ .target = target, .optimize = optimize, }); const websocket = b.dependency("websocket", .{ .target = target, .optimize = optimize, }); // zat and httpz must share one websocket module. const zat_mod = zat.module("zat"); zat_mod.addImport("websocket", websocket.module("websocket"));
const httpz = b.dependency("httpz", .{ .target = target, .optimize = optimize, }); const httpz_mod = b.addModule("httpz", .{ .link_libc = true, .root_source_file = httpz.path("src/httpz.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "metrics", .module = metrics.module("metrics") }, .{ .name = "websocket", .module = websocket.module("websocket") }, }, }); { const options = b.addOptions(); options.addOption(bool, "httpz_blocking", false); httpz_mod.addOptions("build", options); }
const drawing_manifest = b.option([]const u8, "web-drawings", "Path to an explicitly selected cached drawing manifest"); const web_drawings = b.createModule(.{ .root_source_file = b.path(drawing_manifest orelse "src/internal/web/icons/defaults.zig"), .target = target, .optimize = optimize, });
const mod = b.addModule("zds", .{ .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "build_options", .module = buildOptions(b, version) }, .{ .name = "web_drawings", .module = web_drawings }, .{ .name = "zat", .module = zat_mod }, .{ .name = "zqlite", .module = zqlite.module("zqlite") }, .{ .name = "webauthn", .module = webauthn.module("webauthn") }, .{ .name = "httpz", .module = httpz_mod }, }, });
const exe = b.addExecutable(.{ .name = "zds", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "zds", .module = mod }}, }), }); b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe); run_cmd.addPassthruArgs();
const run_step = b.step("run", "Run zds"); run_step.dependOn(&run_cmd.step);
const bench = b.addExecutable(.{ .name = "zds-bench", .root_module = b.createModule(.{ .root_source_file = b.path("bench/main.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "zds", .module = mod }}, }), }); b.installArtifact(bench);
const run_bench = b.addRunArtifact(bench); run_bench.addPassthruArgs();
const bench_step = b.step("bench", "Run local ZDS benchmarks"); bench_step.dependOn(&run_bench.step);
const plc_repair = b.addExecutable(.{ .name = "zds-plc-repair", .root_module = b.createModule(.{ .root_source_file = b.path("tools/plc_repair.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "zds", .module = mod }}, }), }); b.installArtifact(plc_repair);
const run_plc_repair = b.addRunArtifact(plc_repair); run_plc_repair.addPassthruArgs();
const plc_repair_step = b.step("plc-repair", "Repair an existing account PLC rotation key set"); plc_repair_step.dependOn(&run_plc_repair.step);
const drawings = b.addExecutable(.{ .name = "zds-drawings", .root_module = b.createModule(.{ .root_source_file = b.path("tools/drawings.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "zds", .module = mod }}, }), }); const run_drawings = b.addRunArtifact(drawings); run_drawings.addPassthruArgs(); b.step("drawings", "Cache operator-selected Doodl drawings").dependOn(&run_drawings.step);
const space_signature = b.addExecutable(.{ .name = "zds-space-signature", .root_module = b.createModule(.{ .root_source_file = b.path("tools/space_signature.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "zds", .module = mod }}, }), }); b.installArtifact(space_signature);
// HTTP smoke tests need these two binaries, not the bench/admin tools. const smoke_build = b.step("smoke-build", "Install binaries for HTTP smoke tests"); smoke_build.dependOn(&b.addInstallArtifact(exe, .{}).step); smoke_build.dependOn(&b.addInstallArtifact(space_signature, .{}).step);
const run_space_signature = b.addRunArtifact(space_signature); run_space_signature.addPassthruArgs(); const space_signature_step = b.step("space-signature", "Create permissioned-data HTTP signature headers for local testing"); space_signature_step.dependOn(&run_space_signature.step);
const tests = b.addTest(.{ .root_module = mod }); const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&exe.step); test_step.dependOn(&run_tests.step); const drawing_tests = b.addTest(.{ .root_module = drawings.root_module }); test_step.dependOn(&b.addRunArtifact(drawing_tests).step);}
fn buildOptions(b: *std.Build, version: []const u8) *std.Build.Module { const options = b.addOptions(); options.addOption([]const u8, "version", version); return options.createModule();}