authorgravatar for xq@random-projects.netFelix "xq" Queißner <xq@random-projects.net> 2020-07-25 18:36:55+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-07-27 19:46:15+00:00
logfb9d5529dad8356de51f09da5da5f36c8fd8bf9c
treee2854063faca68ff2928857e3e108d7390dd78d5
parentf0ed2ed67f8ea53991e0077e3b5b43a94708c3b7

Adds support for RunStep to use the result of a WriteFileStep.


1 files changed, 18 insertions(+), 0 deletions(-)

lib/std/build/run.zig+18
......@@ -4,6 +4,7 @@ const build = std.build;
44const Step = build.Step;
55const Builder = build.Builder;
66const LibExeObjStep = build.LibExeObjStep;
7const WriteFileStep = build.WriteFileStep;
78const fs = std.fs;
89const mem = std.mem;
910const process = std.process;
......@@ -42,6 +43,10 @@ pub const RunStep = struct {
4243
4344 pub const Arg = union(enum) {
4445 Artifact: *LibExeObjStep,
46 WriteFile: struct {
47 step: *WriteFileStep,
48 file_name: []const u8,
49 },
4550 Bytes: []u8,
4651 };
4752
......@@ -62,6 +67,16 @@ pub const RunStep = struct {
6267 self.step.dependOn(&artifact.step);
6368 }
6469
70 pub fn addWriteFileArg(self: *RunStep, write_file: *WriteFileStep, file_name: []const u8) void {
71 self.argv.append(Arg{
72 .WriteFile = .{
73 .step = write_file,
74 .file_name = file_name,
75 },
76 }) catch unreachable;
77 self.step.dependOn(&write_file.step);
78 }
79
6580 pub fn addArg(self: *RunStep, arg: []const u8) void {
6681 self.argv.append(Arg{ .Bytes = self.builder.dupe(arg) }) catch unreachable;
6782 }
......@@ -142,6 +157,9 @@ pub const RunStep = struct {
142157 for (self.argv.span()) |arg| {
143158 switch (arg) {
144159 Arg.Bytes => |bytes| try argv_list.append(bytes),
160 Arg.WriteFile => |file| {
161 try argv_list.append(file.step.getOutputPath(file.file_name));
162 },
145163 Arg.Artifact => |artifact| {
146164 if (artifact.target.isWindows()) {
147165 // On Windows we don't have rpaths so we have to add .dll search paths to PATH