From e3424332d3fa1264e1f6861b76bb0d1b2996728d Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sat, 4 May 2024 14:29:17 -0400 Subject: Build: cleanup * `doc/langref` formatting * upgrade `.{ .path = "..." }` to `b.path("...")` * avoid using arguments named `self` * make `Build.Step.Id` usage more consistent * add `Build.pathResolve` * use `pathJoin` and `pathResolve` everywhere * make sure `Build.LazyPath.getPath2` returns an absolute path --- lib/std/Build/Step/CheckFile.zig | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'lib/std/Build/Step/CheckFile.zig') diff --git a/lib/std/Build/Step/CheckFile.zig b/lib/std/Build/Step/CheckFile.zig index 19d697a3b6..b3323f9e98 100644 --- a/lib/std/Build/Step/CheckFile.zig +++ b/lib/std/Build/Step/CheckFile.zig @@ -14,7 +14,7 @@ expected_exact: ?[]const u8, source: std.Build.LazyPath, max_bytes: usize = 20 * 1024 * 1024, -pub const base_id = .check_file; +pub const base_id: Step.Id = .check_file; pub const Options = struct { expected_matches: []const []const u8 = &.{}, @@ -26,10 +26,10 @@ pub fn create( source: std.Build.LazyPath, options: Options, ) *CheckFile { - const self = owner.allocator.create(CheckFile) catch @panic("OOM"); - self.* = .{ + const check_file = owner.allocator.create(CheckFile) catch @panic("OOM"); + check_file.* = .{ .step = Step.init(.{ - .id = .check_file, + .id = base_id, .name = "CheckFile", .owner = owner, .makeFn = make, @@ -38,27 +38,27 @@ pub fn create( .expected_matches = owner.dupeStrings(options.expected_matches), .expected_exact = options.expected_exact, }; - self.source.addStepDependencies(&self.step); - return self; + check_file.source.addStepDependencies(&check_file.step); + return check_file; } -pub fn setName(self: *CheckFile, name: []const u8) void { - self.step.name = name; +pub fn setName(check_file: *CheckFile, name: []const u8) void { + check_file.step.name = name; } fn make(step: *Step, prog_node: *std.Progress.Node) !void { _ = prog_node; const b = step.owner; - const self: *CheckFile = @fieldParentPtr("step", step); + const check_file: *CheckFile = @fieldParentPtr("step", step); - const src_path = self.source.getPath(b); - const contents = fs.cwd().readFileAlloc(b.allocator, src_path, self.max_bytes) catch |err| { + const src_path = check_file.source.getPath2(b, step); + const contents = fs.cwd().readFileAlloc(b.allocator, src_path, check_file.max_bytes) catch |err| { return step.fail("unable to read '{s}': {s}", .{ src_path, @errorName(err), }); }; - for (self.expected_matches) |expected_match| { + for (check_file.expected_matches) |expected_match| { if (mem.indexOf(u8, contents, expected_match) == null) { return step.fail( \\ @@ -71,7 +71,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { } } - if (self.expected_exact) |expected_exact| { + if (check_file.expected_exact) |expected_exact| { if (!mem.eql(u8, expected_exact, contents)) { return step.fail( \\ -- cgit v1.2.3