| ... | ... | @@ -77,6 +77,8 @@ max_stdio_size: usize = 10 * 1024 * 1024, |
| 77 | 77 | captured_stdout: ?*Output = null, |
| 78 | 78 | captured_stderr: ?*Output = null, |
| 79 | 79 | |
| 80 | dep_output_file: ?*Output = null, |
| 81 | |
| 80 | 82 | has_side_effects: bool = false, |
| 81 | 83 | |
| 82 | 84 | pub const StdIn = union(enum) { |
| ... | ... | @@ -240,6 +242,33 @@ pub fn addPrefixedDirectoryArg(self: *Run, prefix: []const u8, directory_source: |
| 240 | 242 | directory_source.addStepDependencies(&self.step); |
| 241 | 243 | } |
| 242 | 244 | |
| 245 | /// Add a path argument to a dep file (.d) for the child process to write its |
| 246 | /// discovered additional dependencies. |
| 247 | /// Only one dep file argument is allowed by instance. |
| 248 | pub fn addDepFileOutputArg(self: *Run, basename: []const u8) std.Build.LazyPath { |
| 249 | return self.addPrefixedDepFileOutputArg("", basename); |
| 250 | } |
| 251 | |
| 252 | /// Add a prefixed path argument to a dep file (.d) for the child process to |
| 253 | /// write its discovered additional dependencies. |
| 254 | /// Only one dep file argument is allowed by instance. |
| 255 | pub fn addPrefixedDepFileOutputArg(self: *Run, prefix: []const u8, basename: []const u8) void { |
| 256 | assert(self.dep_output_file == null); |
| 257 | |
| 258 | const b = self.step.owner; |
| 259 | |
| 260 | const dep_file = b.allocator.create(Output) catch @panic("OOM"); |
| 261 | dep_file.* = .{ |
| 262 | .prefix = b.dupe(prefix), |
| 263 | .basename = b.dupe(basename), |
| 264 | .generated_file = .{ .step = &self.step }, |
| 265 | }; |
| 266 | |
| 267 | self.dep_output_file = dep_file; |
| 268 | |
| 269 | self.argv.append(.{ .output = dep_file }) catch @panic("OOM"); |
| 270 | } |
| 271 | |
| 243 | 272 | pub fn addArg(self: *Run, arg: []const u8) void { |
| 244 | 273 | self.argv.append(.{ .bytes = self.step.owner.dupe(arg) }) catch @panic("OOM"); |
| 245 | 274 | } |
| ... | ... | @@ -559,6 +588,9 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 559 | 588 | |
| 560 | 589 | try runCommand(self, argv_list.items, has_side_effects, &digest, prog_node); |
| 561 | 590 | |
| 591 | if (self.dep_output_file) |dep_output_file| |
| 592 | try man.addDepFilePost(std.fs.cwd(), dep_output_file.generated_file.getPath()); |
| 593 | |
| 562 | 594 | try step.writeManifest(&man); |
| 563 | 595 | } |
| 564 | 596 | |