diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-07-08 23:42:20 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-07-12 00:14:07 -0700 |
| commit | bbd90a562efd6e802ed41df2649a05fad763a4de (patch) | |
| tree | c5276879ad6ade65af80393019ac649f9e6c1734 /lib/std/Build.zig | |
| parent | deea36250ffe458d92b32b1ad090b8a958ba8082 (diff) | |
| download | zig-bbd90a562efd6e802ed41df2649a05fad763a4de.tar.gz zig-bbd90a562efd6e802ed41df2649a05fad763a4de.zip | |
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.
Diffstat (limited to 'lib/std/Build.zig')
| -rw-r--r-- | lib/std/Build.zig | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/lib/std/Build.zig b/lib/std/Build.zig index bfab90971c..e46f3ea0ba 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -119,61 +119,6 @@ pub const Graph = struct { needed_lazy_dependencies: std.StringArrayHashMapUnmanaged(void) = .{}, /// Information about the native target. Computed before build() is invoked. host: ResolvedTarget, - /// When `--watch` is provided, collects the set of files that should be - /// watched and the state to required to poll the system for changes. - watch: ?*Watch, -}; - -pub const Watch = struct { - table: Table, - - pub const init: Watch = .{ - .table = .{}, - }; - - /// Key is the directory to watch which contains one or more files we are - /// interested in noticing changes to. - pub const Table = std.ArrayHashMapUnmanaged(Cache.Path, ReactionSet, TableContext, false); - - const Hash = std.hash.Wyhash; - - pub const TableContext = struct { - pub fn hash(self: TableContext, a: Cache.Path) u32 { - _ = self; - const seed: u32 = @bitCast(a.root_dir.handle.fd); - return @truncate(Hash.hash(seed, a.sub_path)); - } - pub fn eql(self: TableContext, a: Cache.Path, b: Cache.Path, b_index: usize) bool { - _ = self; - _ = b_index; - return a.eql(b); - } - }; - - pub const ReactionSet = std.ArrayHashMapUnmanaged(Match, void, Match.Context, false); - - pub const Match = struct { - /// Relative to the watched directory, the file path that triggers this - /// match. - basename: []const u8, - /// The step to re-run when file corresponding to `basename` is changed. - step: *Step, - - pub const Context = struct { - pub fn hash(self: Context, a: Match) u32 { - _ = self; - var hasher = Hash.init(0); - std.hash.autoHash(&hasher, a.step); - hasher.update(a.basename); - return @truncate(hasher.final()); - } - pub fn eql(self: Context, a: Match, b: Match, b_index: usize) bool { - _ = self; - _ = b_index; - return a.step == b.step and mem.eql(u8, a.basename, b.basename); - } - }; - }; }; const AvailableDeps = []const struct { []const u8, []const u8 }; |
