Skip to content

Commit

Permalink
fix pidof
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Oct 30, 2024
1 parent 9e01903 commit 38be678
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/bin/pidof.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 38be678

Please sign in to comment.