Merge "perfetto: fix descriptor naming to prevent double proto gen"
diff --git a/Android.bp b/Android.bp
index 52bb3b0..8d92551 100644
--- a/Android.bp
+++ b/Android.bp
@@ -6549,6 +6549,44 @@
     ],
 }
 
+// GN: //protos/perfetto/trace/track_event:descriptor
+genrule {
+    name: "perfetto_protos_perfetto_trace_track_event_descriptor",
+    srcs: [
+        "protos/perfetto/trace/track_event/chrome_application_state_info.proto",
+        "protos/perfetto/trace/track_event/chrome_compositor_scheduler_state.proto",
+        "protos/perfetto/trace/track_event/chrome_content_settings_event_info.proto",
+        "protos/perfetto/trace/track_event/chrome_frame_reporter.proto",
+        "protos/perfetto/trace/track_event/chrome_histogram_sample.proto",
+        "protos/perfetto/trace/track_event/chrome_keyed_service.proto",
+        "protos/perfetto/trace/track_event/chrome_latency_info.proto",
+        "protos/perfetto/trace/track_event/chrome_legacy_ipc.proto",
+        "protos/perfetto/trace/track_event/chrome_message_pump.proto",
+        "protos/perfetto/trace/track_event/chrome_mojo_event_info.proto",
+        "protos/perfetto/trace/track_event/chrome_process_descriptor.proto",
+        "protos/perfetto/trace/track_event/chrome_renderer_scheduler_state.proto",
+        "protos/perfetto/trace/track_event/chrome_thread_descriptor.proto",
+        "protos/perfetto/trace/track_event/chrome_user_event.proto",
+        "protos/perfetto/trace/track_event/chrome_window_handle_event_info.proto",
+        "protos/perfetto/trace/track_event/counter_descriptor.proto",
+        "protos/perfetto/trace/track_event/debug_annotation.proto",
+        "protos/perfetto/trace/track_event/log_message.proto",
+        "protos/perfetto/trace/track_event/process_descriptor.proto",
+        "protos/perfetto/trace/track_event/source_location.proto",
+        "protos/perfetto/trace/track_event/task_execution.proto",
+        "protos/perfetto/trace/track_event/thread_descriptor.proto",
+        "protos/perfetto/trace/track_event/track_descriptor.proto",
+        "protos/perfetto/trace/track_event/track_event.proto",
+    ],
+    tools: [
+        "aprotoc",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --descriptor_set_out=$(out) $(in)",
+    out: [
+        "perfetto_protos_perfetto_trace_track_event_descriptor.bin",
+    ],
+}
+
 // GN: //protos/perfetto/trace/track_event:lite
 genrule {
     name: "perfetto_protos_perfetto_trace_track_event_lite_gen",
@@ -6675,44 +6713,6 @@
     ],
 }
 
-// GN: //protos/perfetto/trace/track_event:track_event_descriptor
-genrule {
-    name: "perfetto_protos_perfetto_trace_track_event_track_event_descriptor",
-    srcs: [
-        "protos/perfetto/trace/track_event/chrome_application_state_info.proto",
-        "protos/perfetto/trace/track_event/chrome_compositor_scheduler_state.proto",
-        "protos/perfetto/trace/track_event/chrome_content_settings_event_info.proto",
-        "protos/perfetto/trace/track_event/chrome_frame_reporter.proto",
-        "protos/perfetto/trace/track_event/chrome_histogram_sample.proto",
-        "protos/perfetto/trace/track_event/chrome_keyed_service.proto",
-        "protos/perfetto/trace/track_event/chrome_latency_info.proto",
-        "protos/perfetto/trace/track_event/chrome_legacy_ipc.proto",
-        "protos/perfetto/trace/track_event/chrome_message_pump.proto",
-        "protos/perfetto/trace/track_event/chrome_mojo_event_info.proto",
-        "protos/perfetto/trace/track_event/chrome_process_descriptor.proto",
-        "protos/perfetto/trace/track_event/chrome_renderer_scheduler_state.proto",
-        "protos/perfetto/trace/track_event/chrome_thread_descriptor.proto",
-        "protos/perfetto/trace/track_event/chrome_user_event.proto",
-        "protos/perfetto/trace/track_event/chrome_window_handle_event_info.proto",
-        "protos/perfetto/trace/track_event/counter_descriptor.proto",
-        "protos/perfetto/trace/track_event/debug_annotation.proto",
-        "protos/perfetto/trace/track_event/log_message.proto",
-        "protos/perfetto/trace/track_event/process_descriptor.proto",
-        "protos/perfetto/trace/track_event/source_location.proto",
-        "protos/perfetto/trace/track_event/task_execution.proto",
-        "protos/perfetto/trace/track_event/thread_descriptor.proto",
-        "protos/perfetto/trace/track_event/track_descriptor.proto",
-        "protos/perfetto/trace/track_event/track_event.proto",
-    ],
-    tools: [
-        "aprotoc",
-    ],
-    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --descriptor_set_out=$(out) $(in)",
-    out: [
-        "perfetto_protos_perfetto_trace_track_event_track_event_descriptor.bin",
-    ],
-}
-
 // GN: //protos/perfetto/trace/track_event:zero
 genrule {
     name: "perfetto_protos_perfetto_trace_track_event_zero_gen",
@@ -6841,9 +6841,9 @@
     ],
 }
 
-// GN: //protos/third_party/chromium:chrome_track_event_descriptor
+// GN: //protos/third_party/chromium:descriptor
 genrule {
-    name: "perfetto_protos_third_party_chromium_chrome_track_event_descriptor",
+    name: "perfetto_protos_third_party_chromium_descriptor",
     srcs: [
         "protos/perfetto/trace/track_event/chrome_application_state_info.proto",
         "protos/perfetto/trace/track_event/chrome_compositor_scheduler_state.proto",
@@ -6876,7 +6876,7 @@
     ],
     cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --descriptor_set_out=$(out) $(in)",
     out: [
-        "perfetto_protos_third_party_chromium_chrome_track_event_descriptor.bin",
+        "perfetto_protos_third_party_chromium_descriptor.bin",
     ],
 }
 
@@ -8002,7 +8002,7 @@
 genrule {
     name: "perfetto_src_trace_processor_importers_gen_cc_chrome_track_event_descriptor",
     srcs: [
-        ":perfetto_protos_third_party_chromium_chrome_track_event_descriptor",
+        ":perfetto_protos_third_party_chromium_descriptor",
     ],
     cmd: "$(location tools/gen_cc_proto_descriptor.py) --gen_dir=$(genDir) --cpp_out=$(out) $(in)",
     out: [
@@ -8032,7 +8032,7 @@
 genrule {
     name: "perfetto_src_trace_processor_importers_gen_cc_track_event_descriptor",
     srcs: [
-        ":perfetto_protos_perfetto_trace_track_event_track_event_descriptor",
+        ":perfetto_protos_perfetto_trace_track_event_descriptor",
     ],
     cmd: "$(location tools/gen_cc_proto_descriptor.py) --gen_dir=$(genDir) --cpp_out=$(out) $(in)",
     out: [
diff --git a/BUILD b/BUILD
index 4ad79e7..9d48d47 100644
--- a/BUILD
+++ b/BUILD
@@ -1005,7 +1005,7 @@
 perfetto_cc_proto_descriptor(
     name = "src_trace_processor_importers_gen_cc_chrome_track_event_descriptor",
     deps = [
-        ":protos_third_party_chromium_chrome_track_event_descriptor",
+        ":protos_third_party_chromium_descriptor",
     ],
     outs = [
         "src/trace_processor/importers/chrome_track_event.descriptor.h",
@@ -1025,7 +1025,7 @@
 perfetto_cc_proto_descriptor(
     name = "src_trace_processor_importers_gen_cc_track_event_descriptor",
     deps = [
-        ":protos_perfetto_trace_track_event_track_event_descriptor",
+        ":protos_perfetto_trace_track_event_descriptor",
     ],
     outs = [
         "src/trace_processor/importers/track_event.descriptor.h",
@@ -3410,6 +3410,17 @@
     ],
 )
 
+# GN target: //protos/perfetto/trace/track_event:descriptor
+perfetto_proto_descriptor(
+    name = "protos_perfetto_trace_track_event_descriptor",
+    deps = [
+        ":protos_perfetto_trace_track_event_protos",
+    ],
+    outs = [
+        "protos_perfetto_trace_track_event_descriptor.bin",
+    ],
+)
+
 # GN target: //protos/perfetto/trace/track_event:lite
 perfetto_cc_proto_library(
     name = "protos_perfetto_trace_track_event_lite",
@@ -3452,31 +3463,6 @@
     ],
 )
 
-# GN target: //protos/perfetto/trace/track_event:track_event_descriptor
-perfetto_proto_descriptor(
-    name = "protos_perfetto_trace_track_event_track_event_descriptor",
-    deps = [
-        ":protos_perfetto_trace_track_event_track_event_protos",
-    ],
-    outs = [
-        "protos_perfetto_trace_track_event_track_event_descriptor.bin",
-    ],
-)
-
-# GN target: //protos/perfetto/trace/track_event:track_event_descriptor
-perfetto_proto_library(
-    name = "protos_perfetto_trace_track_event_track_event_protos",
-    srcs = [
-        "protos/perfetto/trace/track_event/track_event.proto",
-    ],
-    visibility = [
-        PERFETTO_CONFIG.proto_library_visibility,
-    ],
-    deps = [
-        ":protos_perfetto_trace_track_event_protos",
-    ],
-)
-
 # GN target: //protos/perfetto/trace/track_event:zero
 perfetto_cc_protozero_library(
     name = "protos_perfetto_trace_track_event_zero",
@@ -3485,28 +3471,14 @@
     ],
 )
 
-# GN target: //protos/third_party/chromium:chrome_track_event_descriptor
+# GN target: //protos/third_party/chromium:descriptor
 perfetto_proto_descriptor(
-    name = "protos_third_party_chromium_chrome_track_event_descriptor",
+    name = "protos_third_party_chromium_descriptor",
     deps = [
-        ":protos_third_party_chromium_chrome_track_event_protos",
+        ":protos_third_party_chromium_protos",
     ],
     outs = [
-        "protos_third_party_chromium_chrome_track_event_descriptor.bin",
-    ],
-)
-
-# GN target: //protos/third_party/chromium:chrome_track_event_descriptor
-perfetto_proto_library(
-    name = "protos_third_party_chromium_chrome_track_event_protos",
-    srcs = [
-        "protos/third_party/chromium/chrome_track_event.proto",
-    ],
-    visibility = [
-        PERFETTO_CONFIG.proto_library_visibility,
-    ],
-    deps = [
-        ":protos_perfetto_trace_track_event_protos",
+        "protos_third_party_chromium_descriptor.bin",
     ],
 )
 
@@ -3518,7 +3490,7 @@
     ],
 )
 
-# GN target: //protos/third_party/chromium:lite
+# GN target: //protos/third_party/chromium:source_set
 perfetto_proto_library(
     name = "protos_third_party_chromium_protos",
     srcs = [
diff --git a/protos/perfetto/trace/track_event/BUILD.gn b/protos/perfetto/trace/track_event/BUILD.gn
index d1a8177..ab9d273 100644
--- a/protos/perfetto/trace/track_event/BUILD.gn
+++ b/protos/perfetto/trace/track_event/BUILD.gn
@@ -43,7 +43,7 @@
   ]
 }
 
-perfetto_proto_library("track_event_@TYPE@") {
+perfetto_proto_library("@TYPE@") {
   proto_generators = [ "descriptor" ]
   generate_descriptor = "track_event.descriptor"
   sources = [ "track_event.proto" ]
diff --git a/protos/third_party/chromium/BUILD.gn b/protos/third_party/chromium/BUILD.gn
index 83228a6..568900c 100644
--- a/protos/third_party/chromium/BUILD.gn
+++ b/protos/third_party/chromium/BUILD.gn
@@ -7,11 +7,11 @@
   deps = [ "../../perfetto/trace/track_event:@TYPE@" ]
 }
 
-perfetto_proto_library("chrome_track_event_@TYPE@") {
+perfetto_proto_library("@TYPE@") {
   proto_generators = [ "descriptor" ]
   sources = chrome_track_event_sources
   generate_descriptor = "chrome_track_event.descriptor"
-  deps = [ "../../perfetto/trace/track_event:source_set" ]
+  deps = [ ":source_set" ]
 
   # When rolled into Chrome, extension descriptor is going to be linked into
   # binary, therefore increasing its size. Including imports means that the
diff --git a/src/trace_processor/importers/BUILD.gn b/src/trace_processor/importers/BUILD.gn
index fceb53f..908ae8d 100644
--- a/src/trace_processor/importers/BUILD.gn
+++ b/src/trace_processor/importers/BUILD.gn
@@ -21,12 +21,10 @@
 
 perfetto_cc_proto_descriptor("gen_cc_chrome_track_event_descriptor") {
   descriptor_name = "chrome_track_event.descriptor"
-  descriptor_target =
-      "../../../protos/third_party/chromium:chrome_track_event_descriptor"
+  descriptor_target = "../../../protos/third_party/chromium:descriptor"
 }
 
 perfetto_cc_proto_descriptor("gen_cc_track_event_descriptor") {
   descriptor_name = "track_event.descriptor"
-  descriptor_target =
-      "../../../protos/perfetto/trace/track_event:track_event_descriptor"
+  descriptor_target = "../../../protos/perfetto/trace/track_event:descriptor"
 }