Is there a way to see what files/directories are being watched?

Is there a way to see what files/directories are being watched when running with --watch?

2 Likes

In the zig compiler source lib/compiler/Maker.zig:814 there is this code:

// Wait until a file system notification arrives. Read all such events
// until the buffer is empty. Then wait for a debounce interval, resetting
// if any more events come in. After the debounce interval has passed,
// trigger a rebuild on all steps with modified inputs, as well as their
// recursive dependants.
var caption_buf: [std.Progress.Node.max_name_len]u8 = undefined;
const caption = std.fmt.bufPrint(&caption_buf, "watching {d} directories, {d} processes", .{
    w.dir_count, countSubProcesses(&maker),
}) catch &caption_buf;

w is of type lib/compiler/Maker/Watch.zig which has a field dir_table which is a hash map where the keys are cache pathes and values are generation counts.

w.dir_count gets set at the end of the update method to:

w.dir_count = w.dir_table.count();

So I think you could change the maker to print the pathes in w.dir_table, instead of just the count, but I don’t think there is a pre-existing option to print the watched directories.

But I haven’t looked deeper than (yet), to know whether there would be any concerns while implementing that / whether you can freely access that hash table or need to lock some mutex etc..

Well maybe not print, but instead log the updated set of watched directories to some file, or using a scoped logger, either by adding a flag or locally modifying the maker?

1 Like