From 961de327fe2542f90e40fb83d2954247d68372b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 17 Oct 2024 23:06:44 +0300 Subject: [PATCH] build.zig improvements --- build.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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