summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig16
1 files changed, 15 insertions, 1 deletions
diff --git a/build.zig b/build.zig
index c490cbac..2c8a8858 100644
--- a/build.zig
+++ b/build.zig
@@ -410,6 +410,14 @@ pub fn build(b: *std.Build) void {
const mvzr_mod = b.dependency("mvzr", .{ .target = target, .optimize = optimize }).module("mvzr");
+ // The C heap every C library with an allocator hook is handed: the core's
+ // tree-sitter and fonts, and pdf.zig's MuPDF, which is a module of its own.
+ const c_heap_mod = b.createModule(.{
+ .target = target,
+ .optimize = optimize,
+ .root_source_file = b.path("src/c_heap.zig"),
+ });
+
if (enable_mupdf) {
if (b.lazyDependency("mupdf", .{})) |mupdf_dep| {
const mupdf = mupdf_build.add(b, io, mupdf_dep, .{
@@ -424,6 +432,7 @@ pub fn build(b: *std.Build) void {
.link_libc = true,
});
mupdf.linkTo(mupdf_mod);
+ mupdf_mod.addImport("c_heap", c_heap_mod);
mupdf_mod.addIncludePath(b.path("src"));
mupdf_mod.addCSourceFile(.{
.file = b.path("src/pdf_bridge.c"),
@@ -446,6 +455,7 @@ pub fn build(b: *std.Build) void {
.link_libc = true,
});
mupdf.linkTo(pdf_bench_mod);
+ pdf_bench_mod.addImport("c_heap", c_heap_mod);
pdf_bench_mod.addIncludePath(b.path("src"));
pdf_bench_mod.addCSourceFile(.{
.file = b.path("src/pdf_bridge.c"),
@@ -565,6 +575,7 @@ pub fn build(b: *std.Build) void {
.ts_queries = ts_queries_opts,
.zstbi = zstbi_mod,
.mvzr = mvzr_mod,
+ .c_heap = c_heap_mod,
.mupdf = mupdf_core_mod,
.ghostty_vt = ghostty_core_vt,
.vaxis = vaxis_mod,
@@ -1180,7 +1191,7 @@ pub fn build(b: *std.Build) void {
.link_libc = true,
});
syntax_module.addOptions("pardes_config", opts);
- wireCore(syntax_module, .{ .tree_sitter = ts_mod, .ts_libs = ts_libs.items, .ts_queries = ts_queries_opts });
+ wireCore(syntax_module, .{ .tree_sitter = ts_mod, .ts_libs = ts_libs.items, .ts_queries = ts_queries_opts, .c_heap = c_heap_mod });
const syntax_runner = b.addExecutable(.{
.name = "pardes-syntax",
.root_module = b.createModule(.{
@@ -1377,6 +1388,7 @@ pub fn build(b: *std.Build) void {
.{ .path = "src/esp32p4_gpio.zig", .libc = false },
.{ .path = "src/esp32p4/input_rescue.zig", .libc = false },
.{ .path = "src/fonts.zig", .libc = true },
+ .{ .path = "src/c_heap.zig", .libc = false },
.{ .path = "src/gui/crt.zig", .libc = false },
}) |entry| {
const tests = b.addTest(.{
@@ -1606,6 +1618,7 @@ fn wireCore(m: *std.Build.Module, d: struct {
ts_queries: ?*std.Build.Step.Options = null,
zstbi: ?*std.Build.Module = null,
mvzr: ?*std.Build.Module = null,
+ c_heap: ?*std.Build.Module = null,
mupdf: ?*std.Build.Module = null,
ghostty_vt: ?*std.Build.Module = null,
vaxis: ?*std.Build.Module = null,
@@ -1618,6 +1631,7 @@ fn wireCore(m: *std.Build.Module, d: struct {
if (d.ts_queries) |x| m.addOptions("ts_queries", x);
if (d.zstbi) |x| m.addImport("zstbi", x);
if (d.mvzr) |x| m.addImport("mvzr", x);
+ if (d.c_heap) |x| m.addImport("c_heap", x);
if (d.mupdf) |x| m.addImport("mupdf", x);
if (d.ghostty_vt) |x| m.addImport("ghostty-vt", x);
if (d.vaxis) |x| m.addImport("vaxis", x);