Skip to content

Commit 38be678

Browse files
committed
fix pidof
1 parent 9e01903 commit 38be678

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

build.zig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ fn makeCompileStep(
169169
) ?*Build.Step.Compile {
170170
const name = comptime source.name();
171171
const path = comptime source.path();
172-
if (std.mem.eql(u8, name, "night-shift") or std.mem.eql(u8, name, "dark-mode") or std.mem.eql(u8, name, "pidof")) {
172+
const is_darwin = target.result.isDarwin();
173+
if (std.mem.eql(u8, name, "night-shift") or std.mem.eql(u8, name, "dark-mode")) {
173174
// if (target.getOsTag() != .macos) {
174175
if (is_ci) {
175176
// zig build -Dtarget=aarch64-macos will throw error
@@ -199,7 +200,15 @@ fn makeCompileStep(
199200
exe.linkFramework("SkyLight");
200201
} else if (std.mem.eql(u8, name, "tcp-proxy")) {
201202
exe.linkLibC();
203+
} else if (std.mem.eql(u8, name, "pidof")) {
204+
// only build for macOS
205+
if (is_darwin) {
206+
exe.linkLibC();
207+
} else {
208+
return null;
209+
}
202210
}
211+
203212
const install_step = b.step("install-" ++ name, "Install " ++ name);
204213
install_step.dependOn(&b.addInstallArtifact(exe, .{}).step);
205214
return exe;

src/bin/pidof.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ pub fn main() !void {
8989
const opt = try simargs.parse(allocator, Options, "[program]", util.get_build_info());
9090
defer opt.deinit();
9191

92-
if (opt.positional_args.items.len == 0) {
92+
if (opt.positional_args.len == 0) {
9393
std.debug.print("program is not given", .{});
9494
std.posix.exit(1);
9595
}
9696

97-
const program = opt.positional_args.items[0];
97+
const program = opt.positional_args[0];
9898

9999
const pids = try findPids(allocator, opt.args, program);
100100
if (pids.items.len == 0) {

0 commit comments

Comments
 (0)