Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/cvd/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ bazel_dep(name = "brotli")
bazel_dep(name = "crc32c")
bazel_dep(name = "curl")
bazel_dep(name = "cxx.rs", version = "1.0.194")
bazel_dep(name = "depend_on_what_you_use", version = "1.0.0")
bazel_dep(name = "fmt", version = "11.2.0.bcr.1")
bazel_dep(name = "freetype", version = "2.13.3.bcr.2")
bazel_dep(name = "gflags")
Expand Down
3 changes: 3 additions & 0 deletions base/cvd/allocd/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cf_cc_library(
name = "alloc_utils",
srcs = ["alloc_utils.cpp"],
hdrs = ["alloc_utils.h"],
depend_on_what_you_use_enabled = False,
deps = select({
":netlink": [":alloc_netlink"],
"//conditions:default": [":alloc_iproute2"],
Expand All @@ -52,6 +53,7 @@ cf_cc_library(
name = "alloc_iproute2",
srcs = ["alloc_iproute2.cpp"],
hdrs = ["alloc_driver.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/process:command_subprocess",
"//cuttlefish/result",
Expand All @@ -65,6 +67,7 @@ cf_cc_library(
name = "alloc_netlink",
srcs = ["alloc_netlink.cpp"],
hdrs = ["alloc_driver.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//allocd/net:netlink",
"//cuttlefish/common/libs/fs",
Expand Down
29 changes: 25 additions & 4 deletions base/cvd/cuttlefish/bazel/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load("@cc_compatibility_proxy//:proxy.bzl", "cc_binary", "cc_library", "cc_test"
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("@rules_shell//shell:sh_library.bzl", "sh_library")
load("//:build_variables.bzl", BUILD_VAR_COPTS = "COPTS", BUILD_VAR_LINKOPTS = "LINKOPTS")
load("//tools/lint:linters.bzl", "buildifier_test", "clang_tidy_test", "shellcheck_test")
load("//tools/lint:linters.bzl", "buildifier_test", "clang_tidy_test", "dwyu_rule", "shellcheck_test")

visibility(["//..."])

Expand Down Expand Up @@ -47,7 +47,7 @@ cf_build_test = macro(
implementation = _cf_build_test_implementation,
)

def _cf_cc_binary_implementation(name, clang_format_enabled, clang_tidy_enabled, copts, linkopts, **kwargs):
def _cf_cc_binary_implementation(name, clang_format_enabled, clang_tidy_enabled, copts, depend_on_what_you_use_enabled, linkopts, **kwargs):
if not clang_tidy_enabled and not kwargs["deprecation"]:
kwargs["deprecation"] = "Not covered by clang-tidy"
cc_binary(
Expand All @@ -71,19 +71,26 @@ def _cf_cc_binary_implementation(name, clang_format_enabled, clang_tidy_enabled,
tags = ["clang_tidy", "clang-tidy"],
visibility = ["//visibility:private"],
)
if depend_on_what_you_use_enabled:
dwyu_rule(
name = name + "_depend_on_what_you_use",
deps = [":" + name],
testonly = True,
)

cf_cc_binary = macro(
inherit_attrs = cc_binary,
attrs = {
"clang_format_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding format_test target is generated"),
"clang_tidy_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding clang_tidy_test target is generated"),
"copts": attr.string_list(configurable = False, default = []),
"depend_on_what_you_use_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding depend-on-what-you-use target is generated"),
"linkopts": attr.string_list(configurable = False, default = []),
},
implementation = _cf_cc_binary_implementation,
)

def _cf_cc_library_implementation(name, clang_format_enabled, clang_tidy_enabled, copts, **kwargs):
def _cf_cc_library_implementation(name, clang_format_enabled, clang_tidy_enabled, copts, depend_on_what_you_use_enabled, **kwargs):
if not clang_tidy_enabled and not kwargs["deprecation"]:
kwargs["deprecation"] = "Not covered by clang-tidy"
cc_library(
Expand All @@ -106,18 +113,25 @@ def _cf_cc_library_implementation(name, clang_format_enabled, clang_tidy_enabled
tags = ["clang_tidy", "clang-tidy"],
visibility = ["//visibility:private"],
)
if depend_on_what_you_use_enabled:
dwyu_rule(
name = name + "_depend_on_what_you_use",
deps = [":" + name],
testonly = True,
)

cf_cc_library = macro(
inherit_attrs = cc_library,
attrs = {
"clang_format_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding format_test target is generated"),
"clang_tidy_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding clang_tidy_test target is generated"),
"copts": attr.string_list(configurable = False, default = []),
"depend_on_what_you_use_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding depend-on-what-you-use target is generated"),
},
implementation = _cf_cc_library_implementation,
)

def _cf_cc_test_implementation(name, clang_format_enabled, clang_tidy_enabled, copts, deps, **kwargs):
def _cf_cc_test_implementation(name, clang_format_enabled, clang_tidy_enabled, copts, depend_on_what_you_use_enabled, deps, **kwargs):
if not clang_tidy_enabled and not kwargs["deprecation"]:
kwargs["deprecation"] = "Not covered by clang-tidy"
cc_test(
Expand All @@ -144,13 +158,20 @@ def _cf_cc_test_implementation(name, clang_format_enabled, clang_tidy_enabled, c
tags = ["clang_tidy", "clang-tidy"],
visibility = ["//visibility:private"],
)
if depend_on_what_you_use_enabled:
dwyu_rule(
name = name + "_depend_on_what_you_use",
deps = [":" + name],
testonly = True,
)

cf_cc_test = macro(
inherit_attrs = cc_test,
attrs = {
"clang_format_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding format_test target is generated"),
"clang_tidy_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding clang_tidy_test target is generated"),
"copts": attr.string_list(configurable = False, default = []),
"depend_on_what_you_use_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding depend-on-what-you-use target is generated"),
"deps": attr.label_list(configurable = False),
},
implementation = _cf_cc_test_implementation,
Expand Down
1 change: 1 addition & 0 deletions base/cvd/cuttlefish/common/libs/fs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ cf_cc_test(
srcs = [
"shared_fd_test.cpp",
],
depend_on_what_you_use_enabled = False,
deps = [
":fs",
"//libbase",
Expand Down
2 changes: 2 additions & 0 deletions base/cvd/cuttlefish/common/libs/key_equals_value/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cf_cc_library(
name = "key_equals_value",
srcs = ["key_equals_value.cc"],
hdrs = ["key_equals_value.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/common/libs/utils:contains",
Expand All @@ -21,6 +22,7 @@ cf_cc_library(
cf_cc_test(
name = "key_equals_value_test",
srcs = ["key_equals_value_test.cc"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/key_equals_value",
"//cuttlefish/result",
Expand Down
1 change: 1 addition & 0 deletions base/cvd/cuttlefish/common/libs/security/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cf_cc_library(
hdrs = [
"confui_sign.h",
],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/fs",
"//libbase",
Expand Down
1 change: 1 addition & 0 deletions base/cvd/cuttlefish/common/libs/transport/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cf_cc_library(
"channel.h",
"channel_sharedfd.h",
],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/result:expect",
Expand Down
17 changes: 17 additions & 0 deletions base/cvd/cuttlefish/common/libs/utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cf_cc_library(
name = "archive",
srcs = ["archive.cpp"],
hdrs = ["archive.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/process:command_subprocess",
"//cuttlefish/process:managed_stdio",
Expand Down Expand Up @@ -72,6 +73,7 @@ cf_cc_library(
name = "disk_usage",
srcs = ["disk_usage.cpp"],
hdrs = ["disk_usage.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/process:command_subprocess",
"//cuttlefish/process:managed_stdio",
Expand All @@ -91,6 +93,7 @@ cf_cc_library(
"environment.h",
"known_paths.h",
],
depend_on_what_you_use_enabled = False,
deps = [
"//libbase",
],
Expand All @@ -109,6 +112,7 @@ cf_cc_library(
name = "files",
srcs = ["files.cpp"],
hdrs = ["files.h"],
depend_on_what_you_use_enabled = False,
target_compatible_with = [
"@platforms//os:linux", # SEEK_DATA
],
Expand Down Expand Up @@ -156,6 +160,7 @@ cf_cc_library(
name = "gflags_xml_parser",
srcs = ["gflags_xml_parser.cpp"],
hdrs = ["gflags_xml_parser.h"],
depend_on_what_you_use_enabled = False,
features = ["-layering_check"],
deps = [
"//cuttlefish/result",
Expand All @@ -176,6 +181,7 @@ cf_cc_library(
name = "host_info",
srcs = ["host_info.cpp"],
hdrs = ["host_info.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//libbase",
"@abseil-cpp//absl/base:no_destructor",
Expand All @@ -194,6 +200,7 @@ cf_cc_library(
name = "inotify",
srcs = ["inotify.cpp"],
hdrs = ["inotify.h"],
depend_on_what_you_use_enabled = False,
target_compatible_with = [
"@platforms//os:linux",
],
Expand Down Expand Up @@ -227,6 +234,7 @@ cf_cc_library(
name = "network",
srcs = ["network.cpp"],
hdrs = ["network.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//libbase",
"@abseil-cpp//absl/log",
Expand Down Expand Up @@ -260,6 +268,7 @@ cf_cc_library(
cf_cc_test(
name = "proc_file_utils_test",
srcs = ["proc_file_utils_test.cpp"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/utils:contains",
"//cuttlefish/common/libs/utils:proc_file_utils",
Expand Down Expand Up @@ -291,6 +300,7 @@ cf_cc_library(
name = "semver",
srcs = ["semver.cpp"],
hdrs = ["semver.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/result",
"//cuttlefish/result:expect",
Expand All @@ -301,6 +311,7 @@ cf_cc_library(
cf_cc_test(
name = "semver_test",
srcs = ["semver_test.cpp"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/utils:semver",
"//cuttlefish/result:result_matchers",
Expand All @@ -312,6 +323,7 @@ cf_cc_library(
name = "signals",
srcs = ["signals.cpp"],
hdrs = ["signals.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//libbase",
"@abseil-cpp//absl/log:check",
Expand All @@ -327,6 +339,7 @@ cf_cc_library(
name = "socket2socket_proxy",
srcs = ["socket2socket_proxy.cpp"],
hdrs = ["socket2socket_proxy.h"],
depend_on_what_you_use_enabled = False,
target_compatible_with = [
"@platforms//os:linux",
],
Expand All @@ -341,6 +354,7 @@ cf_cc_library(
name = "tee_logging",
srcs = ["tee_logging.cpp"],
hdrs = ["tee_logging.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/common/libs/utils:contains",
Expand Down Expand Up @@ -381,6 +395,7 @@ cf_cc_library(
name = "unix_sockets",
srcs = ["unix_sockets.cpp"],
hdrs = ["unix_sockets.h"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/result",
Expand All @@ -393,6 +408,7 @@ cf_cc_library(
cf_cc_test(
name = "unix_sockets_test",
srcs = ["unix_sockets_test.cpp"],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/common/libs/utils:unix_sockets",
Expand All @@ -418,6 +434,7 @@ cf_cc_library(
srcs = ["vsock_connection.cpp"],
hdrs = ["vsock_connection.h"],
clang_tidy_enabled = False, # TODO: b/403278821 - fix warnings and re-enable after migration work
depend_on_what_you_use_enabled = False,
target_compatible_with = [
"@platforms//os:linux",
],
Expand Down
3 changes: 3 additions & 0 deletions base/cvd/cuttlefish/flag_parser/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ cf_cc_library(
"flag.h",
"gflags_compat.h",
],
depend_on_what_you_use_enabled = False,
deps = [
"//cuttlefish/common/libs/utils:contains",
"//cuttlefish/result",
Expand All @@ -39,6 +40,7 @@ cf_cc_test(
cf_cc_test(
name = "gflags_compat_test",
srcs = ["gflags_compat_test.cpp"],
depend_on_what_you_use_enabled = False,
# `layering_check` conflicts with the combination of the clang prebuilt and
# the cmake build rules used for @libxml2.
features = ["-layering_check"],
Expand All @@ -54,6 +56,7 @@ cf_cc_library(
name = "shared_fd_flag",
srcs = ["shared_fd_flag.cpp"],
hdrs = ["shared_fd_flag.h"],
depend_on_what_you_use_enabled = False,
deps = [
":flag_parser",
"//cuttlefish/common/libs/fs",
Expand Down
Loading
Loading