blob: 5e07c6e9923bc61e0d74064696f4fb5735c6766b [file]
# Copyright 2026 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
load("//build/bazel/rules/cc:fx_cc_binary.bzl", "fx_cc_binary")
load("//build/bazel/rules/cc:fx_cc_library.bzl", "fx_cc_library")
package(default_applicable_licenses = ["//:license"])
# Includes unguarded Zircon headers (<zircon/types.h>) with no Fuchsia-only
# library deps from which Bazel would infer platform compatibility.
fx_cc_library(
name = "object-utils",
srcs = ["object-utils.cc"],
hdrs = ["object-utils.h"],
target_compatible_with = ["@platforms//os:fuchsia"],
visibility = ["//visibility:private"],
alwayslink = True,
)
# Includes unguarded Zircon syscall headers (<zircon/syscalls.h>) with no
# Fuchsia-only library deps from which Bazel would infer platform compatibility.
fx_cc_library(
name = "vmo-utils",
srcs = ["vmo-utils.c"],
hdrs = ["vmo-utils.h"],
target_compatible_with = ["@platforms//os:fuchsia"],
visibility = ["//visibility:private"],
alwayslink = True,
)
fx_cc_library(
name = "ps_internal",
srcs = ["ps_internal.c"],
hdrs = ["ps_internal.h"],
implementation_deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/task-utils",
],
visibility = ["//zircon/system/utest/psutils:__pkg__"],
alwayslink = True,
)
fx_cc_library(
name = "handles_internal",
srcs = ["handles-internal.cc"],
hdrs = ["handles-internal.h"],
implementation_deps = [
":object-utils",
"//sdk/lib/fdio",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/task-utils",
],
visibility = ["//zircon/system/utest/psutils:__pkg__"],
alwayslink = True,
)
# GN places this legacy Zircon binary under $root_out_dir/zircon-migrated.
# @bazel2gn:raw_attribute:output_dir = "$root_out_dir/zircon-migrated"
fx_cc_binary(
name = "ps",
srcs = ["ps.c"],
visibility = ["//visibility:private"],
deps = [
":ps_internal",
"//sdk/lib/fdio",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/task-utils",
],
)
fx_cc_binary(
name = "top",
srcs = ["top.c"],
visibility = ["//visibility:private"],
deps = [
"//sdk/lib/fdio",
"//src/lib/listnode",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/task-utils",
],
)
fx_cc_binary(
name = "kill",
srcs = ["kill.c"],
visibility = ["//visibility:private"],
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/task-utils",
],
)
fx_cc_binary(
name = "killall",
srcs = ["killall.c"],
visibility = ["//visibility:private"],
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/task-utils",
],
)
fx_cc_binary(
name = "vmaps",
srcs = ["vmaps.c"],
visibility = ["//visibility:private"],
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/task-utils",
],
)
fx_cc_binary(
name = "vmos",
srcs = ["vmos.cc"],
visibility = ["//visibility:private"],
deps = [
":vmo-utils",
"//sdk/lib/fdio",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/task-utils",
],
)
fx_cc_library(
name = "resources",
srcs = ["resources.cc"],
hdrs = ["resources.h"],
implementation_deps = [
"//sdk/fidl/fuchsia.kernel:fuchsia.kernel_cpp",
"//sdk/lib/component/incoming/cpp",
"//sdk/lib/fdio",
],
visibility = ["//visibility:private"],
alwayslink = True,
)
fx_cc_library(
name = "memgraph_internal",
srcs = ["memgraph_internal.cc"],
hdrs = ["memgraph_internal.h"],
implementation_deps = [
":object-utils",
":vmo-utils",
"//sdk/lib/fdio",
],
visibility = ["//zircon/system/utest/psutils:__pkg__"],
deps = [
"//zircon/system/ulib/task-utils",
],
alwayslink = True,
)
# GN exposes the generated memgraph-schema.h via `include_dirs = [ target_gen_dir ]`
# and `deps += [ ":gen-memgraph-schema" ]`, whereas Bazel compiles against the
# genrule output via `srcs` and `includes`.
# TODO(https://fxbug.dev/570694755): Support `includes` and generated header `srcs` on `fx_cc_binary` in bazel2gn.
# @bazel2gn:raw_attribute:include_dirs = [ target_gen_dir ]
# @bazel2gn:raw_attribute:deps += [ ":gen-memgraph-schema" ]
fx_cc_binary(
name = "memgraph",
srcs = [
"memgraph.cc",
# GN depends on `:gen-memgraph-schema` in `deps` instead of `srcs`.
# TODO(https://fxbug.dev/570694755): Support generated header `srcs` on `fx_cc_binary` in bazel2gn.
":gen-memgraph-schema", # @bazel2gn:skip
],
# bazel2gn does not translate `includes` on `fx_cc_binary`; GN uses
# `include_dirs = [ target_gen_dir ]` via `@bazel2gn:raw_attribute` above.
# TODO(https://fxbug.dev/570694755): Support `includes` on `fx_cc_binary` in bazel2gn.
# @bazel2gn:skip
includes = ["."],
visibility = ["//visibility:private"],
deps = [
":memgraph_internal",
":resources",
"//sdk/lib/fdio",
"//zircon/system/ulib/task-utils",
],
)
# Generate an include file that contains the schema JSON.
genrule(
name = "gen-memgraph-schema",
srcs = ["memgraph-schema.json"],
outs = [
# GN action() outputs require an explicit $target_gen_dir prefix.
"memgraph-schema.h", # @bazel2gn:path_overwrite:$target_gen_dir/memgraph-schema.h
],
cmd = "$(location :gen-memgraph-schema-header.sh) $@ $<",
tools = [":gen-memgraph-schema-header.sh"],
visibility = ["//visibility:private"],
)
fx_cc_binary(
name = "kstats",
srcs = ["kstats.c"],
visibility = ["//visibility:private"],
deps = [
":resources",
"//sdk/lib/fdio",
"//zircon/system/ulib/pretty",
],
)
fx_cc_binary(
name = "threads",
srcs = ["threads.cc"],
# TODO(https://fxbug.dev/42085293): delete the below and fix compiler warnings
copts = ["-Wno-vla-cxx-extension"],
visibility = ["//visibility:private"],
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/fzl",
"//zircon/system/ulib/inspector",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/sync",
"//zircon/system/ulib/task-utils",
"//zircon/system/ulib/zx",
],
)
fx_cc_binary(
name = "signal",
srcs = ["signal.c"],
visibility = ["//visibility:private"],
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/task-utils",
],
)
# GN places this legacy Zircon binary under $root_out_dir/zircon-migrated.
# @bazel2gn:raw_attribute:output_dir = "$root_out_dir/zircon-migrated"
fx_cc_binary(
name = "handles",
srcs = ["handles.cc"],
visibility = ["//visibility:private"],
deps = [
":handles_internal",
"//sdk/lib/fdio",
"//zircon/system/ulib/task-utils",
],
)