build runner: implement --watch (work-in-progress)

I'm still learning how the fanotify API works but I think after playing
with it in this commit, I finally know how to implement it, at least on
Linux. This commit does not accomplish the goal but I want to take the
code in a different direction and still be able to reference this point
in time by viewing a source control diff.

I think the move is going to be saving the file_handle for the parent
directory, which combined with the dirent names is how we can correlate
the events back to the Step instances that have registered file system
inputs. I predict this to be similar to implementations on other
operating systems.
This commit is contained in:
Andrew Kelley
2024-07-08 23:42:20 -07:00
parent deea36250f
commit bbd90a562e
4 changed files with 407 additions and 144 deletions

View File

@@ -39,7 +39,10 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
_ = prog_node;
const b = step.owner;
const install_file: *InstallFile = @fieldParentPtr("step", step);
step.addWatchInput(install_file.source);
// Inputs never change when re-running `make`.
if (!step.inputs.populated()) step.addWatchInput(install_file.source);
const full_src_path = install_file.source.getPath2(b, step);
const full_dest_path = b.getInstallPath(install_file.dir, install_file.dest_rel_path);
const cwd = std.fs.cwd();