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/src/perfetto_cmd/BUILD.gn b/src/perfetto_cmd/BUILD.gn
index d71b1ed..175d2b0 100644
--- a/src/perfetto_cmd/BUILD.gn
+++ b/src/perfetto_cmd/BUILD.gn
@@ -21,6 +21,7 @@
"../../include/perfetto/traced",
]
deps = [
+ "../../buildtools:protobuf_lite",
"../../gn:default_deps",
"../../protos/perfetto/config:lite",
"../base",
@@ -28,8 +29,11 @@
"../tracing:ipc_consumer",
]
sources = [
+ "pbtxt_to_pb.cc",
+ "pbtxt_to_pb.h",
"perfetto_cmd.cc",
"perfetto_cmd.h",
+ "perfetto_config.descriptor.h",
"rate_limiter.cc",
"rate_limiter.h",
]
@@ -39,6 +43,7 @@
generate_python = false
deps = []
sources = [
+ "descriptor.proto",
"perfetto_cmd_state.proto",
]
proto_in_dir = perfetto_root_path
@@ -53,8 +58,10 @@
"../../gn:default_deps",
"../../gn:gtest_deps",
"../../include/perfetto/base",
+ "../../protos/perfetto/config:lite",
]
sources = [
+ "pbtxt_to_pb_unittest.cc",
"rate_limiter_unittest.cc",
]
}