Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoff-it committed Oct 24, 2024
1 parent 4d6fbbf commit 51d848e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/exes/server/Reloader.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 9 additions & 4 deletions src/exes/server/watcher/WindowsWatcher.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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, "");
}
}
}

Expand Down

0 comments on commit 51d848e

Please sign in to comment.