From 51d848ed014e9d43dc44bbd0d189ac7f4a64fa70 Mon Sep 17 00:00:00 2001 From: Loris Cro Date: Thu, 24 Oct 2024 16:25:00 +0200 Subject: [PATCH] wip --- src/exes/server/Reloader.zig | 3 +++ src/exes/server/watcher/WindowsWatcher.zig | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/exes/server/Reloader.zig b/src/exes/server/Reloader.zig index a04dd24..a7da247 100644 --- a/src/exes/server/Reloader.zig +++ b/src/exes/server/Reloader.zig @@ -85,6 +85,9 @@ pub fn onInputChange(self: *Reloader, path: []const u8, name: []const u8) void { log.err("unable to run zig build: {s}", .{@errorName(err)}); return; }; + + log.debug("done rebuilding", .{}); + defer { self.gpa.free(result.stdout); self.gpa.free(result.stderr); diff --git a/src/exes/server/watcher/WindowsWatcher.zig b/src/exes/server/watcher/WindowsWatcher.zig index b842d98..7b20844 100644 --- a/src/exes/server/watcher/WindowsWatcher.zig +++ b/src/exes/server/watcher/WindowsWatcher.zig @@ -166,6 +166,7 @@ pub fn listen( .buf = self.read_buffer[entry.buf_idx..][0..ReadBufferEntrySize], }; var path_buf: [windows.MAX_PATH]u8 = undefined; + var must_rebuild = false; while (info_iter.next()) |info| { const filename: []const u8 = blk: { const n = try std.unicode.utf16LeToUtf8( @@ -185,10 +186,10 @@ pub fn listen( else => log.debug("Unknown Action ({s}) {s}/{s}", args), } - // switch (entry.kind) { - // .input => reloader.onInputChange(entry.dir_path, filename), - // .output => reloader.onOutputChange(entry.dir_path, filename), - // } + switch (entry.kind) { + .input => must_rebuild = true, + .output => reloader.onOutputChange(entry.dir_path, filename), + } } // Re-queue the directory entry @@ -205,6 +206,10 @@ pub fn listen( log.err("ReadDirectoryChanges error: {s}", .{@tagName(windows.kernel32.GetLastError())}); return Error.QueueFailed; } + + if (must_rebuild) { + reloader.onInputChange(entry.dir_path, ""); + } } }