diff --git a/build.zig b/build.zig index a16583e..7c1148b 100644 --- a/build.zig +++ b/build.zig @@ -49,17 +49,19 @@ pub fn build(b: *std.Build) void { const run_unit_tests = b.addRunArtifact(unit_tests); - if (setcap and sudo == null) { - std.log.warn("non-null setcap and no sudo command probably won't work. Add sudo.", .{}); - } - + // TODO learn `zig build` and complain only during unit tests. if (setcap) { + if (sudo == null) { + std.log.warn("non-null setcap and no sudo command probably won't work. Add sudo.", .{}); + } const set_cap_cmd = b.addSystemCommand(if (sudo) |cmd| &.{ cmd, "setcap", "cap_net_admin=+ep" } else &.{ "setcap", "cap_net_admin=+ep" }); set_cap_cmd.addArtifactArg(unit_tests); run_unit_tests.step.dependOn(&set_cap_cmd.step); + } else { + std.log.warn("-Dsetcap not set. Unit tests will probably fail.", .{}); } // Similar to creating the run step earlier, this exposes a `test` step to