perfetto: fix support for proto_descriptor targets
Since a source_set was being generated for these targets with the
same name as the target, these descriptors were not being regenerated
correctly when the proto changed.
Fix this by making the action directly be depended on when generating
descriptors.
Change-Id: Ibaf5cdc91f73654a0e73b31a076335a9b6be703d
diff --git a/BUILD.gn b/BUILD.gn
index 846d132..c808460 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -72,6 +72,10 @@
"tools/proto_to_cpp",
"tools/trace_to_text",
"tools/trace_to_text:trace_to_text_lite_host($host_toolchain)",
+
+ # The diff testing framework depends on these descriptors.
+ "protos/perfetto/metrics:descriptor",
+ "protos/perfetto/trace:descriptor",
]
if (is_linux || is_android) {
deps += [ "tools/skippy" ]
diff --git a/gn/standalone/proto_library.gni b/gn/standalone/proto_library.gni
index d2ffe54..e496fd0 100644
--- a/gn/standalone/proto_library.gni
+++ b/gn/standalone/proto_library.gni
@@ -105,8 +105,12 @@
}
config_name = "${target_name}_config"
- action_name = "${target_name}_gen"
- source_set_name = target_name
+ if (generate_descriptor == "") {
+ action_name = "${target_name}_gen"
+ source_set_name = target_name
+ } else {
+ action_name = target_name
+ }
config(config_name) {
include_dirs = [ cc_out_dir ]
@@ -114,7 +118,9 @@
# The XXX_gen action that generates the .pb.{cc,h} files.
action(action_name) {
- visibility = [ ":$source_set_name" ]
+ if (generate_descriptor == "") {
+ visibility = [ ":$source_set_name" ]
+ }
script = "//gn/standalone/build_tool_wrapper.py"
sources = proto_sources
outputs = get_path_info(protogens, "abspath")
@@ -184,50 +190,52 @@
if (defined(invoker.deps)) {
deps += invoker.deps
}
- } # action "${target_name}_gen"
+ } # action(action_name)
# The source_set that builds the generated .pb.cc files.
- source_set(target_name) {
- forward_variables_from(invoker,
- [
- "defines",
- "include_dirs",
- "public_configs",
- "testonly",
- "visibility",
- ])
+ if (generate_descriptor == "") {
+ source_set(source_set_name) {
+ forward_variables_from(invoker,
+ [
+ "defines",
+ "include_dirs",
+ "public_configs",
+ "testonly",
+ "visibility",
+ ])
- sources = get_target_outputs(":$action_name")
+ sources = get_target_outputs(":$action_name")
- configs -= [ "//gn/standalone:extra_warnings" ]
- if (defined(invoker.extra_configs)) {
- configs += invoker.extra_configs
- }
+ configs -= [ "//gn/standalone:extra_warnings" ]
+ if (defined(invoker.extra_configs)) {
+ configs += invoker.extra_configs
+ }
- if (!defined(invoker.public_configs)) {
- public_configs = []
- }
+ if (!defined(invoker.public_configs)) {
+ public_configs = []
+ }
- public_configs += [
- "//buildtools:protobuf_gen_config",
- ":$config_name",
- ]
-
- # Use protobuf_full only for tests.
- if (defined(invoker.use_protobuf_full) &&
- invoker.use_protobuf_full == true) {
- deps = [
- "//buildtools:protobuf_full",
+ public_configs += [
+ "//buildtools:protobuf_gen_config",
+ ":$config_name",
]
- } else {
- deps = [
- "//buildtools:protobuf_lite",
- ]
- }
- deps += [ ":$action_name" ]
- if (defined(invoker.deps)) {
- deps += invoker.deps
- }
- } # source_set(target_name)
+ # Use protobuf_full only for tests.
+ if (defined(invoker.use_protobuf_full) &&
+ invoker.use_protobuf_full == true) {
+ deps = [
+ "//buildtools:protobuf_full",
+ ]
+ } else {
+ deps = [
+ "//buildtools:protobuf_lite",
+ ]
+ }
+
+ deps += [ ":$action_name" ]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ } # source_set(source_set_name)
+ }
} # template
diff --git a/src/trace_processor/BUILD.gn b/src/trace_processor/BUILD.gn
index 6ef7285..a908fe7 100644
--- a/src/trace_processor/BUILD.gn
+++ b/src/trace_processor/BUILD.gn
@@ -212,12 +212,6 @@
"../../buildtools:linenoise",
"../../gn/standalone:gen_git_revision",
]
-
- # Build the descriptors as the diff testing framework depends on this.
- deps += [
- "../../protos/perfetto/metrics:descriptor",
- "../../protos/perfetto/trace:descriptor",
- ]
}
sources = [
diff --git a/tools/diff_test_trace_processor.py b/tools/diff_test_trace_processor.py
index 08e15f5..4933100 100755
--- a/tools/diff_test_trace_processor.py
+++ b/tools/diff_test_trace_processor.py
@@ -144,7 +144,7 @@
else:
out_path = os.path.dirname(args.trace_processor)
trace_protos_path = os.path.join(
- out_path, "gcc_like_host", "gen", "protos", "trace")
+ out_path, "gen", "protos", "trace")
trace_descriptor_path = os.path.join(trace_protos_path, "trace.descriptor")
if args.metrics_descriptor:
@@ -152,7 +152,7 @@
else:
out_path = os.path.dirname(args.trace_processor)
metrics_protos_path = os.path.join(
- out_path, "gcc_like_host", "gen", "protos", "perfetto", "metrics")
+ out_path, "gen", "protos", "perfetto", "metrics")
metrics_descriptor_path = os.path.join(metrics_protos_path,
"metrics.descriptor")