tp: move metrics descriptor generation to build time
This is necessary because generating the descriptor at check-in time was
leading to conflicts in G3 where the third_party/perfetto prefix is
present for extensions defined in Google3 but not the builtin
descriptors.
This CL ensures that wherever we build, we get a consistent generation
of the builtin metric descriptor.
Change-Id: I94be63dae7960edc8aabac8f47686a82daa4796e
diff --git a/BUILD b/BUILD
index 3c09997..7d4e73e 100644
--- a/BUILD
+++ b/BUILD
@@ -20,12 +20,14 @@
"perfetto_cc_binary",
"perfetto_cc_ipc_library",
"perfetto_cc_library",
+ "perfetto_cc_proto_descriptor",
"perfetto_cc_proto_library",
"perfetto_cc_protocpp_library",
"perfetto_cc_protozero_library",
"perfetto_java_proto_library",
"perfetto_java_lite_proto_library",
"perfetto_proto_library",
+ "perfetto_proto_descriptor",
"perfetto_py_binary",
"perfetto_py_library",
"perfetto_gensignature_internal_only",
@@ -745,6 +747,16 @@
],
)
+perfetto_cc_proto_descriptor(
+ name = "src_trace_processor_metrics_gen_cc_metrics_descriptor",
+ deps = [
+ ":protos_perfetto_metrics_descriptor",
+ ],
+ outs = [
+ "src/trace_processor/metrics/metrics.descriptor.h",
+ ],
+)
+
genrule(
name = "src_trace_processor_metrics_gen_merged_sql_metrics",
srcs = [
@@ -812,7 +824,6 @@
srcs = [
"src/trace_processor/metrics/chrome/all_chrome_metrics.descriptor.h",
"src/trace_processor/metrics/metrics.cc",
- "src/trace_processor/metrics/metrics.descriptor.h",
"src/trace_processor/metrics/metrics.h",
],
)
@@ -2069,6 +2080,62 @@
visibility = PERFETTO_CONFIG.public_visibility,
)
+# GN target: //protos/perfetto/metrics/android:source_set
+perfetto_proto_library(
+ name = "protos_perfetto_metrics_android_source_set_protos",
+ srcs = [
+ "protos/perfetto/metrics/android/batt_metric.proto",
+ "protos/perfetto/metrics/android/cpu_metric.proto",
+ "protos/perfetto/metrics/android/display_metrics.proto",
+ "protos/perfetto/metrics/android/gpu_metric.proto",
+ "protos/perfetto/metrics/android/heap_profile_callsites.proto",
+ "protos/perfetto/metrics/android/hwui_metric.proto",
+ "protos/perfetto/metrics/android/ion_metric.proto",
+ "protos/perfetto/metrics/android/java_heap_histogram.proto",
+ "protos/perfetto/metrics/android/java_heap_stats.proto",
+ "protos/perfetto/metrics/android/lmk_metric.proto",
+ "protos/perfetto/metrics/android/lmk_reason_metric.proto",
+ "protos/perfetto/metrics/android/mem_metric.proto",
+ "protos/perfetto/metrics/android/mem_unagg_metric.proto",
+ "protos/perfetto/metrics/android/package_list.proto",
+ "protos/perfetto/metrics/android/powrails_metric.proto",
+ "protos/perfetto/metrics/android/process_metadata.proto",
+ "protos/perfetto/metrics/android/startup_metric.proto",
+ "protos/perfetto/metrics/android/surfaceflinger.proto",
+ "protos/perfetto/metrics/android/task_names.proto",
+ "protos/perfetto/metrics/android/thread_time_in_state_metric.proto",
+ "protos/perfetto/metrics/android/unsymbolized_frames.proto",
+ ],
+ visibility = [
+ PERFETTO_CONFIG.proto_library_visibility,
+ ],
+)
+
+# GN target: //protos/perfetto/metrics:descriptor
+perfetto_proto_descriptor(
+ name = "protos_perfetto_metrics_descriptor",
+ deps = [
+ ":protos_perfetto_metrics_descriptor_protos",
+ ],
+ outs = [
+ "protos_perfetto_metrics_descriptor.bin",
+ ],
+)
+
+# GN target: //protos/perfetto/metrics:descriptor
+perfetto_proto_library(
+ name = "protos_perfetto_metrics_descriptor_protos",
+ srcs = [
+ "protos/perfetto/metrics/metrics.proto",
+ ],
+ visibility = [
+ PERFETTO_CONFIG.proto_library_visibility,
+ ],
+ deps = [
+ ":protos_perfetto_metrics_android_source_set_protos",
+ ],
+)
+
# GN target: //protos/perfetto/metrics:lite
perfetto_cc_proto_library(
name = "protos_perfetto_metrics_lite",
@@ -2964,6 +3031,7 @@
":protos_perfetto_trace_sys_stats_zero",
":protos_perfetto_trace_system_info_zero",
":protos_perfetto_trace_track_event_zero",
+ ":src_trace_processor_metrics_gen_cc_metrics_descriptor",
] + PERFETTO_CONFIG.deps.jsoncpp +
PERFETTO_CONFIG.deps.sqlite +
PERFETTO_CONFIG.deps.sqlite_ext_percentile +
@@ -3046,6 +3114,7 @@
":protos_perfetto_trace_sys_stats_zero",
":protos_perfetto_trace_system_info_zero",
":protos_perfetto_trace_track_event_zero",
+ ":src_trace_processor_metrics_gen_cc_metrics_descriptor",
] + PERFETTO_CONFIG.deps.jsoncpp +
PERFETTO_CONFIG.deps.linenoise +
PERFETTO_CONFIG.deps.protoc_lib +
@@ -3216,6 +3285,7 @@
":protos_perfetto_trace_system_info_zero",
":protos_perfetto_trace_track_event_zero",
":protos_third_party_pprof_zero",
+ ":src_trace_processor_metrics_gen_cc_metrics_descriptor",
] + PERFETTO_CONFIG.deps.jsoncpp +
PERFETTO_CONFIG.deps.protobuf_full +
PERFETTO_CONFIG.deps.sqlite +
@@ -3251,6 +3321,15 @@
python_version = "PY3",
)
+perfetto_py_binary(
+ name = "gen_cc_proto_descriptor_py",
+ srcs = [
+ "tools/gen_cc_proto_descriptor.py",
+ ],
+ main = "tools/gen_cc_proto_descriptor.py",
+ python_version = "PY3",
+)
+
perfetto_java_proto_library(
name = "protos_perfetto_metrics_java",
deps = [