### Build Example with Zig Source: https://github.com/mitchellh/libxev/blob/main/README.md Command to build a specific example using the Zig build system. Replace `_basic.zig` with the desired example filename. ```bash $ zig build -Dexample-name=_basic.zig ``` -------------------------------- ### Zig Build File Integration for Libxev Source: https://github.com/mitchellh/libxev/blob/main/README.md Example of how to add libxev as a module in your `build.zig` file when using the Zig package manager. ```zig const xev = b.dependency("libxev", .{ .target = target, .optimize = optimize }); exe.addModule("xev", xev.module("xev")); ``` -------------------------------- ### Run 5s Timer in C with Libxev Source: https://github.com/mitchellh/libxev/blob/main/README.md Example of using libxev in C to set up and run a 5-second timer. Includes necessary headers and callback function. ```c #include #include #include xev_cb_action timerCallback(xev_loop* loop, xev_completion* c, int result, void *userdata) { return XEV_DISARM; } int main(void) { xev_loop loop; if (xev_loop_init(&loop) != 0) { printf("xev_loop_init failure\n"); return 1; } xev_watcher w; if (xev_timer_init(&w) != 0) { printf("xev_timer_init failure\n"); return 1; } xev_completion c; xev_timer_run(&w, &loop, &c, 5000, NULL, &timerCallback); xev_loop_run(&loop, XEV_RUN_UNTIL_DONE); xev_timer_deinit(&w); xev_loop_deinit(&loop); return 0; ``` -------------------------------- ### Run 5s Timer in Zig with Libxev Source: https://github.com/mitchellh/libxev/blob/main/README.md Example of using libxev in Zig to set up and run a 5-second timer. Requires importing the 'xev' module. ```zig const xev = @import("xev"); pub fn main() !void { var loop = try xev.Loop.init(.{}); defer loop.deinit(); const w = try xev.Timer.init(); defer w.deinit(); // 5s timer var c: xev.Completion = undefined; w.run(&loop, &c, 5000, void, null, &timerCallback); try loop.run(.until_done); } fn timerCallback( userdata: ?*void, loop: *xev.Loop, c: *xev.Completion, result: xev.Timer.RunError!void, ) xev.CallbackAction { _ = userdata; _ = loop; _ = c; _ = result catch unreachable; return .disarm; } ``` -------------------------------- ### Render Man Pages with scdoc Source: https://github.com/mitchellh/libxev/blob/main/README.md Command to render libxev man pages after building with `zig build -Dman-pages`. Requires `scdoc` to be installed. ```bash man zig-out/share/man/man7/xev.7 ``` -------------------------------- ### Run WASI Tests with Wasmtime Source: https://github.com/mitchellh/libxev/blob/main/README.md Execute tests for the WebAssembly System Interface (WASI) target. Requires wasmtime to be installed and configured. ```sh $ zig build test -Dtarget=wasm32-wasi -Dwasmtime ... ``` -------------------------------- ### Cross-Compile Tests for macOS Source: https://github.com/mitchellh/libxev/blob/main/README.md Build and compile tests for a different platform, such as macOS on ARM architecture, from a Linux host. This involves specifying the target and enabling test installation. ```sh $ zig build -Dtarget=aarch64-macos -Dinstall-tests ... $ file zig-out/bin/xev-test zig-out/bin/xev-test: Mach-O 64-bit arm64 executable ``` -------------------------------- ### Zig Build Configuration for Libxev Source: https://github.com/mitchellh/libxev/blob/main/README.md Configuration for `build.zig.zon` to include libxev as a dependency using the Zig package manager. Replace `` with the desired Git reference. ```zig .{ .name = "my-project", .version = "0.0.0", .dependencies = .{ .libxev = .{ .url = "https://github.com/mitchellh/libxev/archive/.tar.gz", .hash = "12208070233b17de6be05e32af096a6760682b48598323234824def41789e993432c", }, }, } ``` -------------------------------- ### Run Tests for Current Platform Source: https://github.com/mitchellh/libxev/blob/main/README.md Execute the test suite for all supported features on the current host platform. This command builds and runs the tests. ```sh $ zig build test ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.