aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/CheckFile.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2024-05-04 14:29:17 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2024-05-05 09:42:51 -0400
commite3424332d3fa1264e1f6861b76bb0d1b2996728d (patch)
tree2d786805328dd51b8d8e804ab6b655fc398d2f3f /lib/std/Build/Step/CheckFile.zig
parentd582575aba5264aaa02a8af0cdb7da7c4f4c6220 (diff)
downloadzig-e3424332d3fa1264e1f6861b76bb0d1b2996728d.tar.gz
zig-e3424332d3fa1264e1f6861b76bb0d1b2996728d.zip
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
Diffstat (limited to 'lib/std/Build/Step/CheckFile.zig')
-rw-r--r--lib/std/Build/Step/CheckFile.zig26
1 files changed, 13 insertions, 13 deletions
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(
\\