build.zig improvements
This commit is contained in:
parent
d123f3ce84
commit
961de327fe
@ -49,17 +49,19 @@ pub fn build(b: *std.Build) void {
|
||||
|
||||
const run_unit_tests = b.addRunArtifact(unit_tests);
|
||||
|
||||
if (setcap and sudo == null) {
|
||||
// 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.", .{});
|
||||
}
|
||||
|
||||
if (setcap) {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user