zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 31c159c228ecf6c2ffcf44ee44621c3d6b1ceb61 (tree)
parent 92038675af545ecdbe1f1b4cbd1095a8b3264e07
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Fri, 22 May 2026 18:56:09 -0700

Maker: implement CheckFile

Diffstat:
Mlib/compiler/Maker/Step.zig | 3++-
Mlib/compiler/Maker/Step/CheckFile.zig | 17++++++++++-------
2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/compiler/Maker/Step.zig b/lib/compiler/Maker/Step.zig @@ -18,6 +18,7 @@ const assert = std.debug.assert; const WebServer = @import("WebServer.zig"); const Maker = @import("../Maker.zig"); +pub const CheckFile = @import("Step/CheckFile.zig"); pub const Compile = @import("Step/Compile.zig"); pub const FindProgram = @import("Step/FindProgram.zig"); pub const Fmt = @import("Step/Fmt.zig"); @@ -75,7 +76,7 @@ comptime { } pub const Extended = union(enum) { - check_file: Todo, + check_file: CheckFile, compile: Compile, config_header: Todo, fail: Fail, diff --git a/lib/compiler/Maker/Step/CheckFile.zig b/lib/compiler/Maker/Step/CheckFile.zig @@ -13,6 +13,7 @@ pub fn make( maker: *Maker, progress_node: std.Progress.Node, ) Step.ExtendedMakeError!void { + _ = check_file; _ = progress_node; const graph = maker.graph; const arena = maker.graph.arena; // TODO don't leak into process arena @@ -20,7 +21,7 @@ pub fn make( const step = maker.stepByIndex(step_index); const conf = &maker.scanned_config.configuration; const conf_step = step_index.ptr(conf); - const conf_cf = conf_step.extended.get(conf.extra).install_file; + const conf_cf = conf_step.extended.get(conf.extra).check_file; const lazy_path = conf_cf.file.get(conf); try step.singleUnchangingWatchInput(maker, arena, lazy_path); @@ -29,11 +30,12 @@ pub fn make( const limit: Io.Limit = if (conf_cf.max_bytes.value) |x| .limited(x) else .unlimited; const contents = src_path.root_dir.handle.readFileAlloc(io, src_path.sub_path, arena, limit) catch |err| - return step.fail("failed to read {f}: {t}", .{ src_path, err }); + return step.fail(maker, "failed to read {f}: {t}", .{ src_path, err }); - for (check_file.expected_matches) |expected_match| { + for (conf_cf.expected_matches.slice) |expected_match_index| { + const expected_match = expected_match_index.slice(conf); if (std.mem.find(u8, contents, expected_match) == null) { - return step.fail( + return step.fail(maker, \\ \\========= expected to find: =================== \\{s} @@ -44,16 +46,17 @@ pub fn make( } } - if (check_file.expected_exact) |expected_exact| { + if (conf_cf.expected_exact.value) |expected_exact_index| { + const expected_exact = expected_exact_index.slice(conf); if (!std.mem.eql(u8, expected_exact, contents)) { - return step.fail( + return step.fail(maker, \\ \\========= expected: ===================== \\{s} \\========= but found: ==================== \\{s} \\========= from the following file: ====== - \\{s} + \\{f} , .{ expected_exact, contents, src_path }); } }