diff --git a/build.zig b/build.zig index 187ed27..c2c4530 100644 --- a/build.zig +++ b/build.zig @@ -169,7 +169,8 @@ fn makeCompileStep( ) ?*Build.Step.Compile { const name = comptime source.name(); const path = comptime source.path(); - if (std.mem.eql(u8, name, "night-shift") or std.mem.eql(u8, name, "dark-mode") or std.mem.eql(u8, name, "pidof")) { + const is_darwin = target.result.isDarwin(); + if (std.mem.eql(u8, name, "night-shift") or std.mem.eql(u8, name, "dark-mode")) { // if (target.getOsTag() != .macos) { if (is_ci) { // zig build -Dtarget=aarch64-macos will throw error @@ -199,7 +200,15 @@ fn makeCompileStep( exe.linkFramework("SkyLight"); } else if (std.mem.eql(u8, name, "tcp-proxy")) { exe.linkLibC(); + } else if (std.mem.eql(u8, name, "pidof")) { + // only build for macOS + if (is_darwin) { + exe.linkLibC(); + } else { + return null; + } } + const install_step = b.step("install-" ++ name, "Install " ++ name); install_step.dependOn(&b.addInstallArtifact(exe, .{}).step); return exe; diff --git a/src/bin/pidof.zig b/src/bin/pidof.zig index 0bd047b..660d4e2 100644 --- a/src/bin/pidof.zig +++ b/src/bin/pidof.zig @@ -89,12 +89,12 @@ pub fn main() !void { const opt = try simargs.parse(allocator, Options, "[program]", util.get_build_info()); defer opt.deinit(); - if (opt.positional_args.items.len == 0) { + if (opt.positional_args.len == 0) { std.debug.print("program is not given", .{}); std.posix.exit(1); } - const program = opt.positional_args.items[0]; + const program = opt.positional_args[0]; const pids = try findPids(allocator, opt.args, program); if (pids.items.len == 0) {