Stop generating data-source specific C++ classes in tracing/core
We generate C++ classes from proto for a bunch of core classes
like DataSourceConfig, DataSourceDescriptor etc. This is to
prevent spreading protobuf dependencies all over the places.
However, at some point in the past we started adding data-source
specific sub-messages to DataSourceConfig and doing to required
to generate C++ classes for things that don't really belong to
tracing/core (e.g. FtraceConfig, SysStatsConfig, etc).
This CL introduces a decoupling using a proto annotation [lazy=true].
When fields are annotated as such, the generated C++ stub exposes
the field as a raw byte array. This allows to break the dependency
between tracing/core and those configs and pushes the decoding
responsibility to the actual data sources.
This is a step towards getting rid of libprotobuf dependencies
in tracing/core for the client library.
Note that at the moment the generated classes still depend on
libprotobuf for the FromProto / ToProto conversions.
Bug: 132880619
Change-Id: I29751565277e7cb60928571e3eaf513477cf9968
diff --git a/src/tracing/core/test_config.cc b/src/tracing/core/test_config.cc
index 582128a..02ba732 100644
--- a/src/tracing/core/test_config.cc
+++ b/src/tracing/core/test_config.cc
@@ -49,6 +49,12 @@
}
#pragma GCC diagnostic pop
+void TestConfig::ParseRawProto(const std::string& raw) {
+ perfetto::protos::TestConfig proto;
+ proto.ParseFromString(raw);
+ FromProto(proto);
+}
+
void TestConfig::FromProto(const perfetto::protos::TestConfig& proto) {
static_assert(sizeof(message_count_) == sizeof(proto.message_count()),
"size mismatch");
@@ -142,6 +148,12 @@
}
#pragma GCC diagnostic pop
+void TestConfig::DummyFields::ParseRawProto(const std::string& raw) {
+ perfetto::protos::TestConfig_DummyFields proto;
+ proto.ParseFromString(raw);
+ FromProto(proto);
+}
+
void TestConfig::DummyFields::FromProto(
const perfetto::protos::TestConfig_DummyFields& proto) {
static_assert(sizeof(field_uint32_) == sizeof(proto.field_uint32()),