diff --git a/modules/psmisc/23.7/MODULE.bazel b/modules/psmisc/23.7/MODULE.bazel new file mode 100644 index 00000000000..12d7c438c5f --- /dev/null +++ b/modules/psmisc/23.7/MODULE.bazel @@ -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") diff --git a/modules/psmisc/23.7/overlay/BUILD.bazel b/modules/psmisc/23.7/overlay/BUILD.bazel new file mode 100644 index 00000000000..a0dcf443b95 --- /dev/null +++ b/modules/psmisc/23.7/overlay/BUILD.bazel @@ -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"], +) diff --git a/modules/psmisc/23.7/overlay/MODULE.bazel b/modules/psmisc/23.7/overlay/MODULE.bazel new file mode 120000 index 00000000000..9b599e3ad9c --- /dev/null +++ b/modules/psmisc/23.7/overlay/MODULE.bazel @@ -0,0 +1 @@ +../MODULE.bazel \ No newline at end of file diff --git a/modules/psmisc/23.7/overlay/defs.bzl b/modules/psmisc/23.7/overlay/defs.bzl new file mode 100644 index 00000000000..afcd7f0cf84 --- /dev/null +++ b/modules/psmisc/23.7/overlay/defs.bzl @@ -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 ") + 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"], +) diff --git a/modules/psmisc/23.7/presubmit.yml b/modules/psmisc/23.7/presubmit.yml new file mode 100644 index 00000000000..8dc23995173 --- /dev/null +++ b/modules/psmisc/23.7/presubmit.yml @@ -0,0 +1,8 @@ +matrix: + platform: ["macos", "ubuntu2204"] + bazel: ["6.x", "7.x"] +tasks: + verify_targets: + platform: ${{ platform }} + bazel: ${{ bazel }} + build_targets: [//...] diff --git a/modules/psmisc/23.7/source.json b/modules/psmisc/23.7/source.json new file mode 100644 index 00000000000..745d4a2e55b --- /dev/null +++ b/modules/psmisc/23.7/source.json @@ -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=" + } +} diff --git a/modules/psmisc/metadata.json b/modules/psmisc/metadata.json new file mode 100644 index 00000000000..d9031e1c65a --- /dev/null +++ b/modules/psmisc/metadata.json @@ -0,0 +1,14 @@ +{ + "homepage": "https://psmisc.sf.net/", + "maintainers": [ + { + "email": "bcr-maintainers@bazel.build", + "name": "No Maintainer Specified" + } + ], + "repository": [], + "versions": [ + "23.7" + ], + "yanked_versions": {} +}