| ... | @@ -4,6 +4,7 @@ const build = std.build; | ... | @@ -4,6 +4,7 @@ const build = std.build; |
| 4 | const Step = build.Step; | 4 | const Step = build.Step; |
| 5 | const Builder = build.Builder; | 5 | const Builder = build.Builder; |
| 6 | const LibExeObjStep = build.LibExeObjStep; | 6 | const LibExeObjStep = build.LibExeObjStep; |
| | 7 | const WriteFileStep = build.WriteFileStep; |
| 7 | const fs = std.fs; | 8 | const fs = std.fs; |
| 8 | const mem = std.mem; | 9 | const mem = std.mem; |
| 9 | const process = std.process; | 10 | const process = std.process; |
| ... | @@ -42,6 +43,10 @@ pub const RunStep = struct { | ... | @@ -42,6 +43,10 @@ pub const RunStep = struct { |
| 42 | | 43 | |
| 43 | pub const Arg = union(enum) { | 44 | pub const Arg = union(enum) { |
| 44 | Artifact: *LibExeObjStep, | 45 | Artifact: *LibExeObjStep, |
| | 46 | WriteFile: struct { |
| | 47 | step: *WriteFileStep, |
| | 48 | file_name: []const u8, |
| | 49 | }, |
| 45 | Bytes: []u8, | 50 | Bytes: []u8, |
| 46 | }; | 51 | }; |
| 47 | | 52 | |
| ... | @@ -62,6 +67,16 @@ pub const RunStep = struct { | ... | @@ -62,6 +67,16 @@ pub const RunStep = struct { |
| 62 | self.step.dependOn(&artifact.step); | 67 | self.step.dependOn(&artifact.step); |
| 63 | } | 68 | } |
| 64 | | 69 | |
| | 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 | |
| 65 | pub fn addArg(self: *RunStep, arg: []const u8) void { | 80 | pub fn addArg(self: *RunStep, arg: []const u8) void { |
| 66 | self.argv.append(Arg{ .Bytes = self.builder.dupe(arg) }) catch unreachable; | 81 | self.argv.append(Arg{ .Bytes = self.builder.dupe(arg) }) catch unreachable; |
| 67 | } | 82 | } |
| ... | @@ -142,6 +157,9 @@ pub const RunStep = struct { | ... | @@ -142,6 +157,9 @@ pub const RunStep = struct { |
| 142 | for (self.argv.span()) |arg| { | 157 | for (self.argv.span()) |arg| { |
| 143 | switch (arg) { | 158 | switch (arg) { |
| 144 | Arg.Bytes => |bytes| try argv_list.append(bytes), | 159 | Arg.Bytes => |bytes| try argv_list.append(bytes), |
| | 160 | Arg.WriteFile => |file| { |
| | 161 | try argv_list.append(file.step.getOutputPath(file.file_name)); |
| | 162 | }, |
| 145 | Arg.Artifact => |artifact| { | 163 | Arg.Artifact => |artifact| { |
| 146 | if (artifact.target.isWindows()) { | 164 | if (artifact.target.isWindows()) { |
| 147 | // On Windows we don't have rpaths so we have to add .dll search paths to PATH | 165 | // On Windows we don't have rpaths so we have to add .dll search paths to PATH |