diff options
Diffstat (limited to 'build/core.zig')
| -rw-r--r-- | build/core.zig | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/build/core.zig b/build/core.zig index 2a434ba9..1e2801cf 100644 --- a/build/core.zig +++ b/build/core.zig @@ -29,7 +29,7 @@ const deps_text = blk: { /// A file read while configuring, under a package's root. A dependency's is /// hash-addressed and never changes under the same pin; this repo's are not /// tracked one by one, since the configure runs again on every build anyway -/// (findProgram and gitCommit poison its cache). +/// (build.zig poisons its cache). // ponytail: untracked repo reads; b.dependOnFileContents each one if the configure cache ever stays pure. pub fn configureRead(b: *std.Build, io: std.Io, root: std.Build.Cache.Path, sub: []const u8, limit: usize) ![]u8 { return root.root_dir.handle.readFileAlloc(io, b.pathJoin(&.{ root.subPathOrDot(), sub }), b.allocator, .limited(limit)); @@ -50,8 +50,10 @@ pub fn jjChange(b: *std.Build) ?[]const u8 { /// files the configure cache can track, so the cache is poisoned. pub fn command(b: *std.Build, argv: []const []const u8) ?[]const u8 { b.graph.poisonCache(); - var code: u8 = 0; - const out = b.runAllowFail(argv, &code, .ignore) catch return null; + const out = switch (b.runFallible(argv, .{ .stderr_behavior = .ignore })) { + .success => |stdout| stdout, + else => return null, + }; const trimmed = std.mem.trim(u8, out, " \t\r\n"); return if (trimmed.len == 0) null else trimmed; } @@ -102,7 +104,7 @@ fn vendoredThemes(b: *std.Build, io: std.Io) []const []const u8 { var it = dir.iterate(); while (it.next(io) catch @panic("read vendor/themes")) |e| { if (!std.mem.endsWith(u8, e.name, ".toml") and !std.mem.endsWith(u8, e.name, ".json")) continue; - names.append(b.allocator, b.dupe(e.name)) catch @panic("OOM"); + names.append(b.allocator, b.graph.dupeString(e.name)) catch @panic("OOM"); } std.mem.sort([]const u8, names.items, {}, struct { fn lt(_: void, a: []const u8, c: []const u8) bool { @@ -164,7 +166,7 @@ pub fn treeSitter(b: *std.Build, io: std.Io, target: std.Build.ResolvedTarget, c (tree_sitter_grammars == .minimal and g.tier != .full) or (tree_sitter_grammars == .zig and g.tier == .zig)) grammar: { - const dep = b.lazyDependency(g.dep, .{}) orelse break :grammar; + const dep = b.dependencyLazy(g.dep, .{}) catch break :grammar; const upstream = configureRead(b, io, dep.builder.root, g.query, 0x100000) catch @panic("read " ++ g.name ++ " highlights"); // the patterns that colour, filtered here once and not in // every compile, and the whole query, the filter's test's @@ -212,17 +214,17 @@ pub fn treeSitter(b: *std.Build, io: std.Io, target: std.Build.ResolvedTarget, c /// and vaxis share; null while it is still to be fetched. pub fn uucodeModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) ?*std.Build.Module { const uucode_config = b.path("uucode_config.zig"); - const uucode_tables = (b.lazyDependency("uucode", .{ + const uucode_tables = (b.dependencyLazy("uucode", .{ .target = target, .optimize = optimize, .build_config_path = uucode_config, - }) orelse return null).namedLazyPath("tables.zig"); - return (b.lazyDependency("uucode", .{ + }) catch return null).namedLazyPath("tables.zig"); + return (b.dependencyLazy("uucode", .{ .target = target, .optimize = optimize, .build_config_path = uucode_config, .tables_path = uucode_tables, - }) orelse return null).module("uucode"); + }) catch return null).module("uucode"); } /// The editor as a library (src/lib_editor.zig, docs/next-editor.md): the @@ -419,7 +421,7 @@ pub fn assemble(b: *std.Build, c: struct { // A dependency by path (none of these today) has no hash and is always there. const dep = @field(zon.dependencies, name); if (@hasField(@TypeOf(dep), "hash")) if (!std.Build.package_map.get(dep.hash).?.available) { - _ = b.lazyDependency(name, .{}); + _ = b.dependencyLazy(name, .{}) catch {}; }; } const cloud9 = b.dependency("cloud9", .{ .target = target, .optimize = optimize }).module("cloud9"); @@ -446,15 +448,15 @@ pub fn assemble(b: *std.Build, c: struct { }); // MuPDF and FreeType, lazy (build.zig's `pdf` option has why). - const mupdf_dep = if (c.pdf) b.lazyDependency("mupdf", .{}) else null; + const mupdf_dep = if (c.pdf) b.dependencyLazy("mupdf", .{}) catch null else null; // One FreeType in a binary: the gui's glyph atlas links it and MuPDF is // built against it (see build/mupdf.zig). At c_optimize with the rest of the // vendored C, since MuPDF rasterizes a PDF's text through it. - const freetype_dep = if (c.pdf or c.also_gui or c.platform == .gui) b.lazyDependency("freetype", .{ + const freetype_dep = if (c.pdf or c.also_gui or c.platform == .gui) b.dependencyLazy("freetype", .{ .target = target, .optimize = c_optimize, .@"enable-libpng" = false, - }) else null; + }) catch null else null; const freetype = if (freetype_dep) |d| d.artifact("freetype") else null; // The kinds' C ABI (src/kinds/pardes_addon.h), translated once: the core's @@ -490,7 +492,7 @@ pub fn assemble(b: *std.Build, c: struct { var ghostty_vt_for_tests: ?*std.Build.Module = null; const ghostty_simd = !target.result.os.tag.isDarwin() or b.graph.host.result.os.tag.isDarwin(); const ghostty_optimize: std.lang.Optimize = if (optimize == .debug) .safe else optimize; - const ghostty_dep = b.lazyDependency("ghostty", .{ .target = target, .optimize = ghostty_optimize, .simd = ghostty_simd, .@"app-runtime" = .none, .@"emit-xcframework" = false }); + const ghostty_dep = b.dependencyLazy("ghostty", .{ .target = target, .optimize = ghostty_optimize, .simd = ghostty_simd, .@"app-runtime" = .none, .@"emit-xcframework" = false }) catch null; if (ghostty_dep) |dep| { const ghostty_vt = dep.module("ghostty-vt"); ghostty_vt_for_tests = ghostty_vt; |
