0

Make proto_library() actions depend directly on their dep's actions

Instead of on their source_set() targets, which blocks the actions on
compile steps that it doesn't need.

This necessitates removing visibility from the generation action, and
thus removing the need for "generator_visibility", which IMO provided
negative value.

Change-Id: I75abd295ee5a2943fcdd9c4a15d569c43056b872
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6505727
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Owners-Override: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1456968}
This commit is contained in:
Andrew Grieve
2025-05-07 06:57:13 -07:00
committed by Chromium LUCI CQ
parent bb99b54722
commit 01bb32f8ce
10 changed files with 29 additions and 53 deletions
base
test
tracing
protos
chrome/browser/ash/policy/tools
components
optimization_guide
policy
reporting
content/browser/resources/traces_internals
third_party
dom_distiller_js
libprotobuf-mutator
protobuf

@ -391,7 +391,6 @@ proto_library("test_proto_descriptor") {
generate_cc = false generate_cc = false
generate_python = false generate_python = false
generate_descriptor = "test_proto.descriptor" generate_descriptor = "test_proto.descriptor"
generator_visibility = [ "//base:base_test_proto_bundle_data" ]
} }
config("base_test_implementation") { config("base_test_implementation") {

@ -15,10 +15,6 @@ proto_library("chrome_track_event") {
generate_cc = false generate_cc = false
generate_python = false generate_python = false
generate_descriptor = "chrome_track_event.descriptor" generate_descriptor = "chrome_track_event.descriptor"
generator_visibility = [
":chrome_track_event_resources_grit",
"//base/test:gen_cc_chrome_track_event_descriptor",
]
deps = deps =
[ "//third_party/perfetto/protos/perfetto/trace/track_event:source_set" ] [ "//third_party/perfetto/protos/perfetto/trace/track_event:source_set" ]
} }

@ -40,7 +40,7 @@ action("device_policy_remover_generate") {
rebase_path(chrome_device_policy_pb2_dir, root_build_dir), rebase_path(chrome_device_policy_pb2_dir, root_build_dir),
] ]
public_deps = [ deps = [
"//components/policy/proto:proto_internal_gen", "//components/policy/proto:proto_internal_gen",
"//third_party/protobuf:py_proto", "//third_party/protobuf:py_proto",
] ]
@ -48,6 +48,6 @@ action("device_policy_remover_generate") {
static_library("device_policy_remover_generated") { static_library("device_policy_remover_generated") {
sources = [ device_policy_remover_path ] sources = [ device_policy_remover_path ]
deps = [ ":device_policy_remover_generate" ]
public_deps = [ ":device_policy_remover_generate" ] public_deps = [ "//components/policy/proto:proto_internal" ]
} }

@ -107,6 +107,5 @@ proto_library("optimization_guide_proto_descriptors") {
generate_cc = false generate_cc = false
generate_python = false generate_python = false
generate_descriptor = "optimization_guide_proto.descriptor" generate_descriptor = "optimization_guide_proto.descriptor"
generator_visibility = [ "//components/optimization_guide/core:on_device_model_execution_proto_generator" ]
import_dirs = [ "//third_party/metrics_proto/" ] import_dirs = [ "//third_party/metrics_proto/" ]
} }

@ -36,7 +36,10 @@ proto_library("policy_common_definitions_compile_proto") {
} }
proto_library("proto_internal") { proto_library("proto_internal") {
visibility = [ ":proto" ] visibility = [
":proto",
"//chrome/browser/ash/policy/tools:*",
]
sources = [ sources = [
"device_management_backend.proto", "device_management_backend.proto",
@ -68,10 +71,6 @@ proto_library("proto_internal") {
":policy_common_definitions_compile_proto", ":policy_common_definitions_compile_proto",
"//third_party/private_membership:private_membership_proto", "//third_party/private_membership:private_membership_proto",
] ]
generator_visibility =
[ "//chrome/browser/ash/policy/tools:device_policy_remover_generate" ]
cc_generator_options = "dllexport_decl=POLICY_PROTO_EXPORT:" cc_generator_options = "dllexport_decl=POLICY_PROTO_EXPORT:"
cc_include = "components/policy/proto/policy_proto_export.h" cc_include = "components/policy/proto/policy_proto_export.h"
component_build_force_source_set = true component_build_force_source_set = true

@ -13,8 +13,6 @@ fuzzable_proto_library("record_constants") {
generate_javascript = true generate_javascript = true
sources = [ "synced/record_constants.proto" ] sources = [ "synced/record_constants.proto" ]
generator_visibility = [ "//chrome/browser/resources/chromeos/contact_center_insights:reporting_protos" ]
} }
# Record definitions for reporting. # Record definitions for reporting.
@ -26,8 +24,6 @@ fuzzable_proto_library("record_proto") {
sources = [ "synced/record.proto" ] sources = [ "synced/record.proto" ]
generator_visibility = [ "//chrome/browser/resources/chromeos/contact_center_insights:reporting_protos" ]
deps = [ deps = [
":health_proto", ":health_proto",
":record_constants", ":record_constants",
@ -57,8 +53,6 @@ fuzzable_proto_library("health_proto") {
sources = [ "synced/health.proto" ] sources = [ "synced/health.proto" ]
generator_visibility = [ "//chrome/browser/resources/chromeos/contact_center_insights:reporting_protos" ]
deps = [ deps = [
":record_constants", ":record_constants",
":status_proto", ":status_proto",
@ -72,8 +66,6 @@ proto_library("session_affiliated_user_proto") {
generate_javascript = true generate_javascript = true
sources = [ "synced/session_affiliated_user.proto" ] sources = [ "synced/session_affiliated_user.proto" ]
generator_visibility = [ "//chrome/browser/resources/chromeos/contact_center_insights:reporting_protos" ]
} }
proto_library("test_proto") { proto_library("test_proto") {
@ -90,8 +82,6 @@ proto_library("metric_data_proto") {
sources = [ "synced/metric_data.proto" ] sources = [ "synced/metric_data.proto" ]
generator_visibility = [ "//chrome/browser/resources/chromeos/contact_center_insights:reporting_protos" ]
deps = [ deps = [
":session_affiliated_user_proto", ":session_affiliated_user_proto",
"//components/services/app_service/public/protos", "//components/services/app_service/public/protos",
@ -105,8 +95,6 @@ fuzzable_proto_library("status_proto") {
generate_javascript = true generate_javascript = true
sources = [ "synced/status.proto" ] sources = [ "synced/status.proto" ]
generator_visibility = [ "//chrome/browser/resources/chromeos/contact_center_insights:reporting_protos" ]
} }
fuzzable_proto_library("upload_tracker_proto") { fuzzable_proto_library("upload_tracker_proto") {

@ -39,7 +39,6 @@ generate_grd("bufbuild_grdp") {
} }
proto_library("config_proto") { proto_library("config_proto") {
generator_visibility = [ ":copy_mojo" ]
sources = sources =
[ "//third_party/perfetto/protos/perfetto/config/perfetto_config.proto" ] [ "//third_party/perfetto/protos/perfetto/config/perfetto_config.proto" ]
proto_in_dir = "//third_party/perfetto/" proto_in_dir = "//third_party/perfetto/"

@ -78,7 +78,6 @@ proto_library("dom_distiller_proto") {
# protoc_plugins by generating the json_converter.h file. # protoc_plugins by generating the json_converter.h file.
proto_library("json_values_converter_test_proto") { proto_library("json_values_converter_test_proto") {
visibility = [ ":*" ] visibility = [ ":*" ]
generator_visibility = [ ":json_values_converter_tests" ]
sources = [ "test_sample.proto" ] sources = [ "test_sample.proto" ]
link_deps = [ "//base" ] link_deps = [ "//base" ]
proto_out_dir = "third_party/dom_distiller_js" proto_out_dir = "third_party/dom_distiller_js"

@ -20,7 +20,8 @@ template("fuzzable_proto_library") {
# use LPM on (i.e. libFuzzer not on Chrome OS). # use LPM on (i.e. libFuzzer not on Chrome OS).
if (use_fuzzing_engine_with_lpm && if (use_fuzzing_engine_with_lpm &&
current_toolchain != "//build/toolchain/cros:target") { current_toolchain != "//build/toolchain/cros:target") {
proto_library("proto_library_" + target_name) { _proto_target_name = "${target_name}__proto"
proto_library(_proto_target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
"*", "*",
[ [
@ -33,7 +34,7 @@ template("fuzzable_proto_library") {
foreach(dep, invoker.deps) { foreach(dep, invoker.deps) {
dep_dir = get_label_info(dep, "dir") dep_dir = get_label_info(dep, "dir")
dep_name = get_label_info(dep, "name") dep_name = get_label_info(dep, "name")
deps += [ "${dep_dir}:proto_library_${dep_name}" ] deps += [ "${dep_dir}:${dep_name}__proto" ]
} }
} }
@ -46,9 +47,12 @@ template("fuzzable_proto_library") {
extra_configs = [ "//third_party/protobuf:protobuf_config" ] extra_configs = [ "//third_party/protobuf:protobuf_config" ]
} }
# This is to work with proto_library template in proto_library.gni. # These groups are required by proto_library template in proto_library.gni.
group("${target_name}_input_group") { group("${target_name}_input_group") {
public_deps = [ ":proto_library_${target_name}" ] public_deps = [ ":${_proto_target_name}_input_group" ]
}
group("${target_name}_gen") {
public_deps = [ ":${_proto_target_name}_gen" ]
} }
# Inspired by proto_library.gni's handling of # Inspired by proto_library.gni's handling of
@ -68,7 +72,7 @@ template("fuzzable_proto_library") {
} }
sources = [ "//third_party/libprotobuf-mutator/dummy.cc" ] sources = [ "//third_party/libprotobuf-mutator/dummy.cc" ]
public_deps = [ public_deps = [
":proto_library_" + target_name, ":$_proto_target_name",
"//third_party/libprotobuf-mutator:protobuf_full", "//third_party/libprotobuf-mutator:protobuf_full",
] ]
} }

@ -91,10 +91,6 @@
# absolute paths, such as for third_party or generated .proto files. # absolute paths, such as for third_party or generated .proto files.
# http://crbug.com/691451 tracks fixing this. # http://crbug.com/691451 tracks fixing this.
# #
# generator_visiblility (optional)
# This is added to visibility of code generation target so that other
# targets can depend on them to have generated codes as their inputs.
#
# Parameters for compiling the generated code: # Parameters for compiling the generated code:
# #
# force_source_set (Default=false) # force_source_set (Default=false)
@ -446,24 +442,26 @@ template("proto_library") {
# This is to propagate input deps for imported proto to ancestor targets. # This is to propagate input deps for imported proto to ancestor targets.
foreach(_dep, invoker.deps) { foreach(_dep, invoker.deps) {
_dep = get_label_info(_dep, "label_no_toolchain") _dep = get_label_info(_dep, "label_no_toolchain")
public_deps += [ "${_dep}_input_group" ]
# TODO(agrieve): Update perfetto to follow naming scheme.
if (filter_exclude([ _dep ], [ "//third_party/perfetto/*" ]) == []) {
# Protozero does not follow the naming scheme.
public_deps += [
"${_dep}_input_group",
_dep,
]
} else {
# Depend directly on the _gen targets so as to not unnecessarily block
# on compile (by depending on source_set targets).
public_deps += [ "${_dep}_gen" ]
}
} }
} }
} }
# Generate protobuf stubs. # Generate protobuf stubs.
_action_name = "${target_name}_gen" _action_name = "${target_name}_gen"
_template_name = target_name
action(_action_name) { action(_action_name) {
visibility = [
":$_template_name",
":${_template_name}_js",
":${_template_name}_py_runtime",
":${_template_name}_ts",
]
if (defined(invoker.generator_visibility)) {
visibility += invoker.generator_visibility
}
script = "//tools/protoc_wrapper/protoc_wrapper.py" script = "//tools/protoc_wrapper/protoc_wrapper.py"
sources = _sources sources = _sources
inputs = [ inputs = [
@ -498,11 +496,6 @@ template("proto_library") {
public_deps = [ ":$_input_group_name" ] public_deps = [ ":$_input_group_name" ]
# |deps| must be other proto_library() targets.
if (defined(invoker.deps)) {
public_deps += invoker.deps
}
args = _relative_sources + [ args = _relative_sources + [
# Wrapper should never pick a system protoc. # Wrapper should never pick a system protoc.
# Path should be rebased because |root_build_dir| for current toolchain # Path should be rebased because |root_build_dir| for current toolchain