1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
const std = @import("std");
const TreeSitterGrammars = @import("../build.zig").TreeSitterGrammars;
const core = @import("core.zig");
const patches = @import("patches.zig");
/// pardes as a library, all a package that depends on it is given: the
/// `pardes-syntax` module (src/lib_syntax.zig), the grammars, highlighting
/// and themes for a program that draws source text itself. It takes
/// tree-sitter and the grammars of its `tree-sitter` option and no other
/// dependency, so nothing else is fetched (build.zig.zon). test/lib is such
/// a package, which `lib-test` builds.
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const tree_sitter_grammars = b.option(TreeSitterGrammars, "tree-sitter", "tree-sitter grammar set: disabled, zig, minimal (c/c++/zig), full") orelse .full;
var threaded: std.Io.Threaded = .init(b.allocator, .{});
defer threaded.deinit();
const io = threaded.io();
const mod = b.addModule("pardes-syntax", .{
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/lib_syntax.zig"),
.link_libc = true,
});
mod.addOptions("pardes_config", core.shellOptions(b, .{
.tree_sitter_grammars = tree_sitter_grammars,
.tracy = false,
.workspace_tag = null,
.prebuilt_shaders = false,
.embed_sources = false,
.commit = null,
.change = null,
.built = null,
}, .tui));
const ts = core.treeSitter(b, io, target, if (optimize == .debug) .fast else optimize, tree_sitter_grammars);
const themes = core.generatedThemes(b, io, target, optimize);
core.wireCore(mod, .{
.themes = themes,
.tree_sitter = ts.mod,
.ts_libs = ts.libs.items,
.ts_queries = ts.queries,
.c_heap = b.createModule(.{ .target = target, .optimize = optimize, .root_source_file = b.path("src/c_heap.zig") }),
});
// The editor, `pardes-editor`, to a package that asks for it: uucode,
// mvzr and vaxis (with what its build names) are fetched then and only
// then. Of vaxis it takes the grapheme width, which uucode alone feeds.
if (!(b.option(bool, "editor", "also export `pardes-editor`, the text pane as a library (fetches uucode, mvzr and vaxis)") orelse false)) return;
const uucode = core.uucodeModule(b, target, optimize) orelse return;
const mvzr = patches.mvzr(b, io, b.lazyDependency("mvzr", .{ .target = target, .optimize = optimize }) orelse return, target, optimize);
const vaxis_dep = b.lazyDependency("vaxis", .{ .target = target, .optimize = optimize, .external_uucode = true }) orelse return;
const width = b.addWriteFiles();
_ = width.addCopyFile(vaxis_dep.path("src/gwidth.zig"), "gwidth.zig");
const vaxis = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = width.add("vaxis.zig", "pub const gwidth = @import(\"gwidth.zig\");\n"),
.imports = &.{.{ .name = "uucode", .module = uucode }},
});
_ = core.editorModule(b, "pardes-editor", target, optimize, .{
.tree_sitter_grammars = tree_sitter_grammars,
.tracy = false,
.workspace_tag = null,
.prebuilt_shaders = false,
.embed_sources = false,
.commit = null,
.change = null,
.built = null,
}, .{ .themes = themes, .tree_sitter = ts.mod, .ts_libs = ts.libs.items, .ts_queries = ts.queries, .uucode = uucode, .mvzr = mvzr, .vaxis = vaxis });
}
|