Generate merged trace config for use in the Android tree

This solves two problems:
1) Including > 1 .proto from the android tree is too complex due
   to the unusual way protoc handles relative include paths
   (foo/../external/proto.proto and external/proto.proto are
   considered distinct and then collide on multiple redefinitions).
2) We really don't want to expose the datasource-specific config to
   the rest of the tree. That causes just unnecessary mainteinance
   pain when trying to add new DataSourceConfig(s).

Bug: 71743564
Change-Id: I53f83ff69cc70a56f0d72383cac238100b554273
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 846927b..c8c22bf 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -29,6 +29,7 @@
     results += input.canned_checks.CheckPatchFormatted(input, output)
     results += input.canned_checks.CheckGNFormatted(input, output)
     results += CheckAndroidBlueprint(input, output)
+    results += CheckMergedTraceConfigProto(input, output)
     return results
 
 
@@ -60,3 +61,19 @@
                 'to update it.')
         ]
     return []
+
+
+def CheckMergedTraceConfigProto(input_api, output_api):
+    tool = 'tools/gen_merged_trace_config'
+    build_file_filter = lambda x: input_api.FilterSourceFile(
+          x,
+          white_list=('protos/perfetto/config/.*[.]proto$', tool))
+    if not input_api.AffectedSourceFiles(build_file_filter):
+        return []
+    if subprocess.call([tool, '--check-only']):
+        return [
+            output_api.PresubmitError(
+                'trace_config_merged.proto is out of date. Please run ' +
+                tool + ' to update it.')
+        ]
+    return []