summaryrefslogtreecommitdiff
path: root/test/lib/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 11:07:09 -0300
committerGabriel Schneider <[email protected]>2026-11-10 11:25:35 -0300
commit6b3df3071d16153bd554462c4f54ebb88f3ed50e (patch)
tree5428c2d4d6679fe0c34c0496cd58f94fad1b7486 /test/lib/build.zig
parenta953f560f648e91dda8dd3a8dafe60a7f75739d0 (diff)
downloadpardes-6b3df3071d16153bd554462c4f54ebb88f3ed50e.tar.gz
pardes-6b3df3071d16153bd554462c4f54ebb88f3ed50e.zip
lib: pardes's syntax is a library, as ghostty-vt is ghostty's: a package that depends on pardes is given build.zig's `library` and nothing of the editor, one module, `pardes-syntax` (src/lib_syntax.zig), naming what a program that draws source text itself takes, the editor's own code under its own names (highlightFileRange and analyzeSource for a Syn a byte and the sticky headers' declarations, parse and walkNodes over the tree-sitter bindings, theme, page, ink and synInk for a named theme's colours, the line arithmetic, pathFor for a language's name); every dependency but tree-sitter's runtime is lazy in the manifest, so such a package fetches the runtime and the grammars of its tree-sitter set alone, and pardes's own build asks for all it is missing in one round before its first b.dependency; build.zig's tree-sitter and theme-generator blocks become treeSitter and generatedThemes for both to call, a grammar not yet fetched asked for and left out of that round, and the scanners' -include of src/tree_sitter_heap.h is spelled from the root package's directory, where the compiler runs (pardes's own flags are as they were); File.synStyle's switch moves to colors.synInk, so the editor and the library colour a class from one place; test/lib is such a package, depending on pardes by path: it colours, outlines and walks a C and a Zig source in orchard's colours under the testing allocator, and `zig build lib-test`, which unit-test runs, is its own `zig build test` over this checkout's zig-pkg; ts_markdown is pinned by the commit its hash is of (a0a00f81): its split_parser branch moved to v0.5.4 and a fresh fetch no longer matched; building.typ and the changelog say so; syntax snapshots unchanged
Diffstat (limited to 'test/lib/build.zig')
-rw-r--r--test/lib/build.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/lib/build.zig b/test/lib/build.zig
new file mode 100644
index 00000000..6cd8d6e5
--- /dev/null
+++ b/test/lib/build.zig
@@ -0,0 +1,18 @@
+//! A package that depends on pardes for its library, as a program that draws
+//! source text itself would: pardes's `lib-test` step runs `zig build test`
+//! here, so the `pardes-syntax` module is built the way such a package
+//! builds it (build.zig's `library`), with the minimal grammars.
+const std = @import("std");
+
+pub fn build(b: *std.Build) void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+ const pardes = b.dependency("pardes", .{ .target = target, .optimize = optimize, .@"tree-sitter" = .minimal });
+ const tests = b.addTest(.{ .root_module = b.createModule(.{
+ .target = target,
+ .optimize = optimize,
+ .root_source_file = b.path("lib.zig"),
+ .imports = &.{.{ .name = "pardes-syntax", .module = pardes.module("pardes-syntax") }},
+ }) });
+ b.step("test", "colour, outline and walk a C and a Zig source through pardes's library").dependOn(&b.addRunArtifact(tests).step);
+}