Skip to content

Commit

Permalink
Add psmisc (#2240)
Browse files Browse the repository at this point in the history
Add psmisc, using the new overlay format
(#1566)
  • Loading branch information
lalten authored Jun 27, 2024
1 parent 5251213 commit 9823b44
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/psmisc/23.7/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module(
name = "psmisc",
version = "23.7",
compatibility_level = 0,
)

bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "ncurses", version = "6.4.20221231")
88 changes: 88 additions & 0 deletions modules/psmisc/23.7/overlay/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//:defs.bzl", "make_signames")

VERSION = "23.7"

defines = [
"WITH_STATX",
"WITH_IPV6",
"HAVE_LOCALE_H",
"VERSION='\"{}\"'".format(VERSION),
]

make_signames(
name = "signames.h",
)

cc_binary(
name = "fuser",
srcs = [
"signames.h",
"src/comm.h",
"src/fuser.c",
"src/fuser.h",
"src/i18n.h",
"src/lists.h",
"src/signals.c",
"src/signals.h",
"src/statx.c",
"src/statx.h",
],
copts = [
"-Wno-unused-parameter",
"-Wno-format",
],
local_defines = defines,
visibility = ["//visibility:public"],
)

cc_binary(
name = "killall",
srcs = [
"signames.h",
"src/comm.h",
"src/i18n.h",
"src/killall.c",
"src/signals.c",
"src/signals.h",
],
copts = ["-Wno-format"],
linkopts = ["-ldl"],
local_defines = defines,
visibility = ["//visibility:public"],
)

cc_binary(
name = "pslog",
srcs = [
"src/i18n.h",
"src/pslog.c",
],
local_defines = defines,
visibility = ["//visibility:public"],
)

cc_binary(
name = "pstree",
srcs = [
"src/comm.h",
"src/i18n.h",
"src/pstree.c",
],
copts = ["-Wno-sign-compare"],
local_defines = defines,
visibility = ["//visibility:public"],
deps = ["@ncurses"],
)

cc_binary(
name = "prtstat",
srcs = [
"src/i18n.h",
"src/prtstat.c",
"src/prtstat.h",
],
copts = ["-Wno-format"],
local_defines = defines,
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions modules/psmisc/23.7/overlay/MODULE.bazel
36 changes: 36 additions & 0 deletions modules/psmisc/23.7/overlay/defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")

def _make_signames_impl(ctx):
cc_toolchain = find_cpp_toolchain(ctx)
conf = cc_common.configure_features(ctx = ctx, cc_toolchain = cc_toolchain)
cpp = cc_common.get_tool_for_action(feature_configuration = conf, action_name = ACTION_NAMES.c_compile)
signames_c = ctx.actions.declare_file("signames.c")
ctx.actions.write(signames_c, "#include <signal.h>")
script = ctx.actions.declare_file("gen_signames_h.sh")
ctx.actions.write(script, """\
#!/bin/sh
"$1" -dM -E "$2" |
tr -s ' ' ' ' |
sort -n -k 3 |
sed -E 's:#define SIG([A-Z][A-Z]*[0-9]*) ([0-9][0-9]*).*$$:{\\ \\2,"\\1" },:p;d' |
grep -v '[0-9][0-9][0-9]' \\
> "$3"
grep -q '{ 1,\"HUP\" },' "$3"
""")
signames_h = ctx.actions.declare_file(ctx.attr.name)
ctx.actions.run(
outputs = [signames_h],
inputs = depset(direct=[signames_c], transitive = [cc_toolchain.all_files]),
arguments = [cpp, signames_c.path, signames_h.path],
executable = script,
env = {"LC_ALL": "C"},
progress_message = "Generating signames",
)
return [DefaultInfo(files = depset([signames_h]))]

make_signames = rule(
implementation = _make_signames_impl,
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
fragments = ["cpp"],
)
8 changes: 8 additions & 0 deletions modules/psmisc/23.7/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
matrix:
platform: ["macos", "ubuntu2204"]
bazel: ["6.x", "7.x"]
tasks:
verify_targets:
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets: [//...]
10 changes: 10 additions & 0 deletions modules/psmisc/23.7/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"url": "https://gitlab.com/psmisc/psmisc/-/archive/v23.7/psmisc-v23.7.tar.gz",
"integrity": "sha256-jyUmznrG70l2RUzWMJX6EORn73Rc8z3E+R3wvXsQuQU=",
"strip_prefix": "psmisc-v23.7",
"overlay": {
"MODULE.bazel": "sha256-pyxtDrrDiFbiXmfvZS6fNnsGtNEBvxUCCGNhTf+GnCM=",
"BUILD.bazel": "sha256-BCHXRpf5PbfBOEBdkY3LsS7xvjwV8x7iPtkxEwDZqYk=",
"defs.bzl": "sha256-0dQ2N5ZD95eYEJfEFWPiqz97HDww6P/iTWEjsGo4yWo="
}
}
14 changes: 14 additions & 0 deletions modules/psmisc/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"homepage": "https://psmisc.sf.net/",
"maintainers": [
{
"email": "[email protected]",
"name": "No Maintainer Specified"
}
],
"repository": [],
"versions": [
"23.7"
],
"yanked_versions": {}
}

0 comments on commit 9823b44

Please sign in to comment.