build: allow selecting a backend at comptime instead of via a build flag

This commit is contained in:
CJ van den Berg 2026-03-09 10:46:29 +01:00
parent 6930adae7f
commit aa4e2920dd
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
6 changed files with 457 additions and 372 deletions

View file

@ -3,8 +3,9 @@ const builtin = @import("builtin");
const nightwatch = @import("nightwatch");
const is_posix = switch (builtin.os.tag) {
.linux, .macos, .freebsd => true,
else => false,
.linux, .macos, .freebsd, .openbsd, .netbsd, .dragonfly => true,
.windows => false,
else => @compileError("unsupported OS"),
};
// Self-pipe: signal handler writes a byte so poll() / read() unblocks cleanly.
@ -22,7 +23,6 @@ const CliHandler = struct {
const vtable = nightwatch.Handler.VTable{
.change = change_cb,
.rename = rename_cb,
.wait_readable = if (nightwatch.linux_poll_mode) wait_readable_cb else {},
};
fn change_cb(h: *nightwatch.Handler, path: []const u8, event_type: nightwatch.EventType, object_type: nightwatch.ObjectType) error{HandlerFailed}!void {
@ -215,7 +215,7 @@ pub fn main() !void {
.ignore = ignore_list.items,
};
var watcher = try nightwatch.init(allocator, &cli_handler.handler);
var watcher = try nightwatch.Default.init(allocator, &cli_handler.handler);
defer watcher.deinit();
for (watch_paths.items) |path| {