perfetto_cmd: Teach perfetto_cmd to parse pbtxt configs

Adds the ability for perfetto_cmd to understand pbtxt configs
(this is controlled by the -t/--txt flag). This is somewhat complicated
by perfetto_cmd only having access to protobuf lite.

- Add a cut down version of descriptor.proto
- Use this to generate a (lite) descriptor.pb.h/descriptor.pb.cc
- Convert perfetto_config.proto into a FileSetDescriptor
  (perfetto_config.descriptor)
- Encode perfetto_config.descriptor as a C++ constant named
  kPerfettoConfigDescriptor (perfetto_config.descriptor.h)
- Use descriptor.pb.h to parse the kPerfettoConfigDescriptor
- Manually parse the incoming config based on the descriptor and
  use protozero to write the proto encoding into a buffer which is then
  parsed as normal.

Converting perfetto_config.proto to a descriptor happens at commit time
to avoid having to teach google3 and Android build systems how to
convert a proto descriptor into a .h file of the correct format.

This is not a stable API. Backwards and forwards compatible proto format changes
such as renaming a field or removing an optional field are breaking changes to
the proto text format (we can't distinguish between a typo'ed field and an
optional field) so this format is only really designed for local testing.

Several smaller clean ups:
- Move scattered_stream_memory_delegate.{h,cc} to be part of protozero
  proper
- Remove the (now empty) src/protozero:test_support target
- Remove unused code in tools/gen_merged_protos
- Remove trailing whitespace in PRESUBMIT.py

Change-Id: Ic59b1338bd83421f68d4e12b4e01b9aaf5aa99be
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 2d54a34..9a4902f 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -81,6 +81,21 @@
     return []
 
 
+def CheckBinaryDescriptors(input_api, output_api):
+    tool = 'tools/gen_binary_descriptors'
+    file_filter = lambda x: input_api.FilterSourceFile(
+          x,
+          white_list=('.*[.]h$', '.*[.]proto$', tool))
+    if not input_api.AffectedSourceFiles(file_filter):
+        return []
+    if subprocess.call([tool, '--check-only']):
+        return [
+            output_api.PresubmitError(
+                'Please run ' + tool + ' to update binary descriptors.')
+        ]
+    return []
+
+
 def CheckMergedTraceConfigProto(input_api, output_api):
     tool = 'tools/gen_merged_protos'
     build_file_filter = lambda x: input_api.FilterSourceFile(
@@ -102,7 +117,7 @@
   for f in input_api.AffectedFiles():
     if f.LocalPath() != 'tools/ftrace_proto_gen/event_whitelist':
       continue
-    if any((not new_line.startswith('removed')) 
+    if any((not new_line.startswith('removed'))
             and new_line != old_line for old_line, new_line
            in itertools.izip(f.OldContents(), f.NewContents())):
       return [