From 5340bcac3e811852f1e0bd79f60772822fd38733 Mon Sep 17 00:00:00 2001 From: 0xfff Date: Thu, 16 Apr 2026 18:24:14 +0200 Subject: [PATCH] add -Dxev option so we do not misuse b.lazyDependency --- build.zig | 66 +++++++++++++++++++++++++++++-------------------------- justfile | 4 ++-- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/build.zig b/build.zig index 5fde1c9..97f698d 100644 --- a/build.zig +++ b/build.zig @@ -162,36 +162,40 @@ pub fn build(b: *std.Build) void { ); conformance_client_full_step.dependOn(&conformance_client_full_script.step); - if (b.lazyDependency("libxev", .{})) |xev_dep| { - const xev_echo = b.addExecutable(.{ - .name = "xev-echo", - .root_module = b.createModule(.{ - .root_source_file = b.path("examples/xev-echo.zig"), - .target = target, - .optimize = optimize, - .imports = &.{ - .{ .name = "websocket", .module = mod }, - .{ .name = "xev", .module = xev_dep.module("xev") }, - }, - }), - }); - const xev_install = b.addInstallArtifact(xev_echo, .{}); - examples_step.dependOn(&xev_install.step); - - const xev_conformance = b.addSystemCommand(&.{ - "nu", - run_autobahn, - b.getInstallPath(.bin, "xev-echo"), - "9003", - "xev-echo", - "fast", - }); - xev_conformance.step.dependOn(&xev_install.step); - - const xev_conf_step = b.step( - "conformance-xev", - "Run Autobahn against xev echo server", - ); - xev_conf_step.dependOn(&xev_conformance.step); + const xev_echo = b.addExecutable(.{ + .name = "xev-echo", + .root_module = b.createModule(.{ + .root_source_file = b.path("examples/xev-echo.zig"), + .target = target, + .optimize = optimize, + .imports = &.{ + .{ .name = "websocket", .module = mod }, + }, + }), + }); + const xev_install = b.addInstallArtifact(xev_echo, .{}); + examples_step.dependOn(&xev_install.step); + + const xev_conformance = b.addSystemCommand(&.{ + "nu", + run_autobahn, + b.getInstallPath(.bin, "xev-echo"), + "9003", + "xev-echo", + "fast", + }); + xev_conformance.step.dependOn(&xev_install.step); + + const xev_conf_step = b.step( + "conformance-xev", + "Run Autobahn against xev echo server", + ); + xev_conf_step.dependOn(&xev_conformance.step); + + const pull_xev = b.option(bool, "xev", "set this if libxev need to be used") orelse false; + if (pull_xev) { + if (b.lazyDependency("libxev", .{})) |xev_dep| { + xev_echo.root_module.addImport("xev", xev_dep.module("xev")); + } } } diff --git a/justfile b/justfile index c6515a1..4ab2403 100644 --- a/justfile +++ b/justfile @@ -23,7 +23,7 @@ check: fmt-check lint [doc("Build all examples")] examples: - zig build examples + zig build examples -Dxev [doc("Install the native Autobahn TestSuite into the local PyPy environment")] autobahn-setup: @@ -55,7 +55,7 @@ conformance-client-full: autobahn-setup [doc("Run the fast Autobahn suite against the xev echo server")] conformance-xev: autobahn-setup - zig build conformance-xev + zig build conformance-xev -Dxev [doc("Run all checks: format, lint, test, full conformance")] ci: check test conformance-full