Collect metrics from inside soong_build

Collect the number of modules and variants and some basic statistics
on memory usage inside soong_build by writing out a proto that is
read back in by soong_ui.

Test: examine soong.log
Change-Id: I6926876377a4f6229cf41fdbf166ae03c885ea55
diff --git a/ui/metrics/metrics_proto/metrics.proto b/ui/metrics/metrics_proto/metrics.proto
index 194aa6b..50810eb 100644
--- a/ui/metrics/metrics_proto/metrics.proto
+++ b/ui/metrics/metrics_proto/metrics.proto
@@ -92,6 +92,8 @@
 
   // The metrics for the whole build
   optional PerfInfo total = 21;
+
+  optional SoongBuildMetrics soong_build_metrics = 22;
 }
 
 message PerfInfo {
@@ -140,4 +142,21 @@
 message CriticalUserJourneysMetrics {
   // A set of metrics from a run of the critical user journey tests.
   repeated CriticalUserJourneyMetrics cujs = 1;
+}
+
+message SoongBuildMetrics {
+  // The number of modules handled by soong_build.
+  optional uint32 modules = 1;
+
+  // The total number of variants handled by soong_build.
+  optional uint32 variants = 2;
+
+  // The total number of allocations in soong_build.
+  optional uint64 total_alloc_count = 3;
+
+  // The total size of allocations in soong_build in bytes.
+  optional uint64 total_alloc_size = 4;
+
+  // The approximate maximum size of the heap in soong_build in bytes.
+  optional uint64 max_heap_size = 5;
 }
\ No newline at end of file