diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-12 10:56:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | f2b02c455f2bcdfb905a015eefbb630a28b4b12e (patch) | |
| tree | c344c7ad42ec288dd5e1ebd0eb6d25f5aa2fbccc /build.zig | |
| parent | fc38c73c59f7855a4caad8aa4d3bb8e023309c13 (diff) | |
| download | pardes-f2b02c455f2bcdfb905a015eefbb630a28b4b12e.tar.gz pardes-f2b02c455f2bcdfb905a015eefbb630a28b4b12e.zip | |
addons: an addon can hand the frontend a GPU scene (ABI 3.1), and a snake drawn by shaders does; a commit's patch keeps its own +Diff pane; a real ZLS checked through the window build
ABI 3.1 appends an optional `gpu` callback and its context to pa_paint: one self-contained sketchbook SGPU v1 scene for the pane, at most 4 MiB, copied during the call, the last successful call winning. The SDL frontend runs it on its own GPU through sketchbook's executor and composites its target texture into the pane; replicas carry the scene beside the authoritative pane frame; cells and rasters stay the fallback for terminals, older hosts and frontends without an executor. addons/snake_shader is such an addon (`zig build snake-shader`, the SnakeShader word: a board that follows its pane, buffered turns, a CRT look), with test/gpu_snake.py, test/gpu_snake_interaction.py and test/gpu_upgrade.py.
Commit patches open as `+Diff-<short-hash>` and reuse only their own commit's pane, so another paged patch no longer replaces one already open.
The language-server client looks in the standard per-user bin directory, which desktop launchers often leave out of PATH, and takes an empty answer that beats the startup progress notification onto the wire; test/real_zls.py checks imports, hover, references, rename previews, diagnostics and completion against a real ZLS from a private home.
The dump's schema reader skips two fields older builds persisted, and a replica's shadow of a kind ticks when the authority's does. The reference, the guide, the building and setup notes and the changelog say so.
The working copy as it stood on 2026-11-12; message written by Claude from the diff, at the author's request.
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 46 |
1 files changed, 37 insertions, 9 deletions
@@ -68,10 +68,17 @@ pub fn build(b: *std.Build) void { // A bare `zig build` also copies the binaries into ~/.local/bin. Zig // 0.17 keeps the prefix in the maker process, out of this script's // reach, so `--prefix` no longer turns it off: -Dhome-install=false does. - const home_bin: ?[]const u8 = if (also_gui and (b.option(bool, "home-install", "a bare `zig build` also copies the binaries into ~/.local/bin (default: true)") orelse true)) + const home_enabled = b.option(bool, "home-install", "install binaries and addons into the user directories (default: true)") orelse true; + const home_bin: ?[]const u8 = if (also_gui and home_enabled) if (b.graph.environ_map.get("HOME")) |home| b.pathJoin(&.{ home, ".local", "bin" }) else null else null; + const home_addons: ?[]const u8 = if (!home_enabled) null else if (b.graph.environ_map.get("XDG_DATA_HOME")) |data| + b.pathJoin(&.{ data, "pardes", "addons" }) + else if (b.graph.environ_map.get("HOME")) |home| + b.pathJoin(&.{ home, ".local", "share", "pardes", "addons" }) + else + null; const home_install = home_bin != null; const target = b.standardTargetOptions(.{ .default_target = switch (platform) { @@ -438,6 +445,23 @@ pub fn build(b: *std.Build) void { const kind_mod = b.addTranslateC(.{ .root_source_file = b.path("src/kinds/pardes_addon.h"), .target = target, .optimize = optimize }).createModule(); // ...and what an addon in Zig imports over it (src/kinds/addon.zig). const addon_mod = b.createModule(.{ .root_source_file = b.path("src/kinds/addon.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "pardes_addon", .module = kind_mod }} }); + const snake_shader_step = b.step("snake-shader", "build the optional GPU snake addon into zig-out/lib"); + var snake_shader_lib: ?*std.Build.Step.Compile = null; + if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| { + const files = b.addWriteFiles(); + for ([_][]const u8{ "vert", "frag", "post.frag" }) |stage| { + const compile = b.addSystemCommand(&.{ "glslc", "-O" }); + compile.addFileArg(b.path(b.fmt("addons/snake_shader/snake.{s}", .{stage}))); + compile.addArg("-o"); + _ = files.addCopyFile(compile.addOutputFileArg(b.fmt("snake.{s}.spv", .{stage})), b.fmt("{s}.spv", .{stage})); + } + const shader_module = b.createModule(.{ .root_source_file = files.add("shaders.zig", "const v align(4) = @embedFile(\"vert.spv\").*;\npub const vert: []const u8 = &v;\nconst f align(4) = @embedFile(\"frag.spv\").*;\npub const frag: []const u8 = &f;\nconst p align(4) = @embedFile(\"post.frag.spv\").*;\npub const post: []const u8 = &p;\n") }); + const module = b.createModule(.{ .root_source_file = b.path("addons/snake_shader/snake_shader.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "addon", .module = addon_mod }, .{ .name = "gpu_scene", .module = sb.module("gpu_scene") }, .{ .name = "shaders", .module = shader_module } } }); + const lib = b.addLibrary(.{ .name = "snake_shader", .linkage = .dynamic, .root_module = module }); + snake_shader_lib = lib; + snake_shader_step.dependOn(&b.addInstallArtifact(lib, .{}).step); + snake_shader_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module })).step); + } // The PDF addon (addons/pdf/pdf.zig over MuPDF through pdf_bridge.c), built // and installed as the image addon is: compiled only for a step that // needs it (`pdf`, the tests). MuPDF is compiled against the build's @@ -894,7 +918,13 @@ pub fn build(b: *std.Build) void { const gui_c = b.addTranslateC(.{ .root_source_file = header, .target = target, .optimize = optimize }); gui_c.addIncludePath(dep.path("include")); gui_c.addIncludePath(b.path("src/gui")); - gm.addImport("gui_c", gui_c.createModule()); + const gui_c_mod = gui_c.createModule(); + gm.addImport("gui_c", gui_c_mod); + if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| { + const gpu = b.createModule(.{ .root_source_file = sb.path("src/gpu/Executor.zig"), .imports = &.{ .{ .name = "abi", .module = sb.module("abi") }, .{ .name = "c", .module = gui_c_mod } } }); + gm.addImport("sketch_gpu", gpu); + gm.addImport("gpu_scene", sb.module("gpu_scene")); + } sdl_include = dep.path("include"); if (target.result.os.tag == .macos) { const arch = if (target.result.cpu.arch == .aarch64) "arm64" else @tagName(target.result.cpu.arch); @@ -1151,7 +1181,7 @@ pub fn build(b: *std.Build) void { // The addons, a step each: the default install is the binaries // alone, and `zig build image pdf` (or `addons`) puts the libraries // where the start scan finds them, <prefix>/lib/pardes/addons (and - // ~/.local/lib/pardes/addons with the home install). + // $XDG_DATA_HOME/pardes/addons unless -Dhome-install=false). const addons_step = b.step("addons", "install the image and pdf addons"); for ([_]?*std.Build.Step.Compile{ image_addon, pdf_addon }, [_][]const u8{ "image", "pdf" }) |lib, name| { const step = b.step(name, b.fmt("install the {s} addon, <prefix>/lib/pardes/addons/{s}.so", .{ name, name })); @@ -1161,11 +1191,9 @@ pub fn build(b: *std.Build) void { continue; }; step.dependOn(&b.addInstallFileWithDir(l.getEmittedBin(), .lib, b.fmt("pardes/addons/{s}.so", .{name})).step); - if (home_bin) |dir| { - const copy = b.addSystemCommand(&.{ "install", "-Dm755" }); - copy.addFileArg(l.getEmittedBin()); - copy.addArg(b.pathJoin(&.{ dir, "..", "lib", "pardes", "addons", b.fmt("{s}.so", .{name}) })); - copy.has_side_effects = true; + if (home_addons) |dir| { + const copy = b.addUpdateSourceFiles(); + copy.addCopyFileToSource(l.getEmittedBin(), b.pathJoin(&.{ dir, b.fmt("{s}.so", .{name}) })); step.dependOn(©.step); } } @@ -1645,7 +1673,7 @@ pub fn build(b: *std.Build) void { for ([_]*std.Build.Module{ snake_mod, life_mod, image_mod }) |m| addon_test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m })).step); // ...and the pdf addon's, which mupdf-check runs too (its script // opens docs/design.pdf, from the build root). - const libs = [_]struct { ?*std.Build.Step.Compile, []const u8 }{ .{ fake_addon_lib.?, "addons/fake/fake" }, .{ snake_lib, "addons/snake/snake" }, .{ life_lib, "addons/life/life" }, .{ pdf_addon, "addons/pdf/pdf" } }; + const libs = [_]struct { ?*std.Build.Step.Compile, []const u8 }{ .{ fake_addon_lib.?, "addons/fake/fake" }, .{ snake_lib, "addons/snake/snake" }, .{ snake_shader_lib, "addons/snake_shader/snake_shader" }, .{ life_lib, "addons/life/life" }, .{ pdf_addon, "addons/pdf/pdf" } }; for (libs) |t| if (t[0]) |lib| { const run_addon_test = b.addRunArtifact(exe); run_addon_test.setCwd(b.path(".")); |
