add support for dep files (.d) to Run Step
Run Step already has extra_file_dependencies for file inputs that are known ahead of time:
/// Additional file paths relative to build.zig that, when modified, indicate
/// that the Run step should be re-executed.
/// If the Run step is determined to have side-effects, this field is ignored
/// and the Run step is always executed when it appears in the build graph.
extra_file_dependencies: []const []const u8 = &.{},
However this issue is for handling file inputs that are discovered by the Run Step subprocess during execution.
There should be:
-
run_step.addDepFileOutputArg(); -
run_step.addPrefixedDepFileOutputArg("--dep-file=");
These would add a tmp file path ending with .d to the Run Step's argv. The sub-process would then be expected to populate that file with .d file syntax to list the input files that ended up being inputs to the output. These inputs are discovered at runtime by the child process, and communicated in this tmp file.
The cache system already has support for adding input files to the manifest that were discovered after executing the child process.
There is already this code for parsing this file syntax: https://github.com/ziglang/zig/blob/ff835cce106c27603142533e4eb59792abcf1f13/lib/std/Build/Cache/DepTokenizer.zig
This is used by the compiler when invoking clang to build object files.
Real world use case: https://github.com/thejoshwolfe/legend-of-swarkland/blob/0f85b84ab5f42a9ef873f5ea4eceec1f01e3cda3/build.zig#L150-L151