aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/WriteFile.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-05-03 11:49:55 +0300
committerAndrew Kelley <andrew@ziglang.org>2023-05-03 20:55:29 -0700
commit3f3b1a6808113fd5f9b2cec1033009cbb17dc969 (patch)
tree7893be58b9b8c8edfffdc8127a6b133ec823e141 /lib/std/Build/Step/WriteFile.zig
parent5def162391da5050761beb3e6efb24b99716fc99 (diff)
downloadzig-3f3b1a6808113fd5f9b2cec1033009cbb17dc969.tar.gz
zig-3f3b1a6808113fd5f9b2cec1033009cbb17dc969.zip
std.Build: use Step.* instead of *Step
Follow up to 13eb7251d37759bd47403db304c6120c706fe353
Diffstat (limited to 'lib/std/Build/Step/WriteFile.zig')
-rw-r--r--lib/std/Build/Step/WriteFile.zig38
1 files changed, 19 insertions, 19 deletions
diff --git a/lib/std/Build/Step/WriteFile.zig b/lib/std/Build/Step/WriteFile.zig
index 68f7c37c6c..0d817e7430 100644
--- a/lib/std/Build/Step/WriteFile.zig
+++ b/lib/std/Build/Step/WriteFile.zig
@@ -1,4 +1,4 @@
-//! WriteFileStep is primarily used to create a directory in an appropriate
+//! WriteFile is primarily used to create a directory in an appropriate
//! location inside the local cache which has a set of files that have either
//! been generated during the build, or are copied from the source package.
//!
@@ -12,7 +12,7 @@ const std = @import("std");
const Step = std.Build.Step;
const fs = std.fs;
const ArrayList = std.ArrayList;
-const WriteFileStep = @This();
+const WriteFile = @This();
step: Step,
/// The elements here are pointers because we need stable pointers for the
@@ -39,8 +39,8 @@ pub const Contents = union(enum) {
copy: std.Build.FileSource,
};
-pub fn create(owner: *std.Build) *WriteFileStep {
- const wf = owner.allocator.create(WriteFileStep) catch @panic("OOM");
+pub fn create(owner: *std.Build) *WriteFile {
+ const wf = owner.allocator.create(WriteFile) catch @panic("OOM");
wf.* = .{
.step = Step.init(.{
.id = .write_file,
@@ -55,7 +55,7 @@ pub fn create(owner: *std.Build) *WriteFileStep {
return wf;
}
-pub fn add(wf: *WriteFileStep, sub_path: []const u8, bytes: []const u8) void {
+pub fn add(wf: *WriteFile, sub_path: []const u8, bytes: []const u8) void {
const b = wf.step.owner;
const gpa = b.allocator;
const file = gpa.create(File) catch @panic("OOM");
@@ -72,11 +72,11 @@ pub fn add(wf: *WriteFileStep, sub_path: []const u8, bytes: []const u8) void {
/// Place the file into the generated directory within the local cache,
/// along with all the rest of the files added to this step. The parameter
/// here is the destination path relative to the local cache directory
-/// associated with this WriteFileStep. It may be a basename, or it may
+/// associated with this WriteFile. It may be a basename, or it may
/// include sub-directories, in which case this step will ensure the
/// required sub-path exists.
/// This is the option expected to be used most commonly with `addCopyFile`.
-pub fn addCopyFile(wf: *WriteFileStep, source: std.Build.FileSource, sub_path: []const u8) void {
+pub fn addCopyFile(wf: *WriteFile, source: std.Build.FileSource, sub_path: []const u8) void {
const b = wf.step.owner;
const gpa = b.allocator;
const file = gpa.create(File) catch @panic("OOM");
@@ -97,7 +97,7 @@ pub fn addCopyFile(wf: *WriteFileStep, source: std.Build.FileSource, sub_path: [
/// run by a developer with intent to modify source files and then commit
/// those changes to version control.
/// A file added this way is not available with `getFileSource`.
-pub fn addCopyFileToSource(wf: *WriteFileStep, source: std.Build.FileSource, sub_path: []const u8) void {
+pub fn addCopyFileToSource(wf: *WriteFile, source: std.Build.FileSource, sub_path: []const u8) void {
const b = wf.step.owner;
wf.output_source_files.append(b.allocator, .{
.contents = .{ .copy = source },
@@ -112,7 +112,7 @@ pub fn addCopyFileToSource(wf: *WriteFileStep, source: std.Build.FileSource, sub
/// run by a developer with intent to modify source files and then commit
/// those changes to version control.
/// A file added this way is not available with `getFileSource`.
-pub fn addBytesToSource(wf: *WriteFileStep, bytes: []const u8, sub_path: []const u8) void {
+pub fn addBytesToSource(wf: *WriteFile, bytes: []const u8, sub_path: []const u8) void {
const b = wf.step.owner;
wf.output_source_files.append(b.allocator, .{
.contents = .{ .bytes = bytes },
@@ -121,7 +121,7 @@ pub fn addBytesToSource(wf: *WriteFileStep, bytes: []const u8, sub_path: []const
}
/// Gets a file source for the given sub_path. If the file does not exist, returns `null`.
-pub fn getFileSource(wf: *WriteFileStep, sub_path: []const u8) ?std.Build.FileSource {
+pub fn getFileSource(wf: *WriteFile, sub_path: []const u8) ?std.Build.FileSource {
for (wf.files.items) |file| {
if (std.mem.eql(u8, file.sub_path, sub_path)) {
return .{ .generated = &file.generated_file };
@@ -131,12 +131,12 @@ pub fn getFileSource(wf: *WriteFileStep, sub_path: []const u8) ?std.Build.FileSo
}
/// Returns a `FileSource` representing the base directory that contains all the
-/// files from this `WriteFileStep`.
-pub fn getDirectorySource(wf: *WriteFileStep) std.Build.FileSource {
+/// files from this `WriteFile`.
+pub fn getDirectorySource(wf: *WriteFile) std.Build.FileSource {
return .{ .generated = &wf.generated_directory };
}
-fn maybeUpdateName(wf: *WriteFileStep) void {
+fn maybeUpdateName(wf: *WriteFile) void {
if (wf.files.items.len == 1) {
// First time adding a file; update name.
if (std.mem.eql(u8, wf.step.name, "WriteFile")) {
@@ -148,10 +148,10 @@ fn maybeUpdateName(wf: *WriteFileStep) void {
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
_ = prog_node;
const b = step.owner;
- const wf = @fieldParentPtr(WriteFileStep, "step", step);
+ const wf = @fieldParentPtr(WriteFile, "step", step);
// Writing to source files is kind of an extra capability of this
- // WriteFileStep - arguably it should be a different step. But anyway here
+ // WriteFile - arguably it should be a different step. But anyway here
// it is, it happens unconditionally and does not interact with the other
// files here.
var any_miss = false;
@@ -194,14 +194,14 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
// the data to a file would probably be very fast - but as a way to find a canonical
// location to put build artifacts.
- // If, for example, a hard-coded path was used as the location to put WriteFileStep
- // files, then two WriteFileSteps executing in parallel might clobber each other.
+ // If, for example, a hard-coded path was used as the location to put WriteFile
+ // files, then two WriteFiles executing in parallel might clobber each other.
var man = b.cache.obtain();
defer man.deinit();
- // Random bytes to make WriteFileStep unique. Refresh this with
- // new random bytes when WriteFileStep implementation is modified
+ // Random bytes to make WriteFile unique. Refresh this with
+ // new random bytes when WriteFile implementation is modified
// in a non-backwards-compatible way.
man.hash.add(@as(u32, 0xd767ee59));