Capture the build command that executed the build system.
We need to capture the user build command to understand what additional
arguments is passed in to Soong. This data is useful to know which
targets are being executed and have statistics on top build targets
are specified.
Bug: b/169453712
Test: ran "m blueprint_tools", "m nothing", "lunch 1" and checked
in soong_metrics proto.
Change-Id: I7ab94dcf037211f1abffe6afd012b03ffbf99756
diff --git a/ui/metrics/metrics.go b/ui/metrics/metrics.go
index 7a3726b..9434924 100644
--- a/ui/metrics/metrics.go
+++ b/ui/metrics/metrics.go
@@ -18,6 +18,7 @@
"io/ioutil"
"os"
"runtime"
+ "strings"
"time"
"github.com/golang/protobuf/proto"
@@ -142,6 +143,10 @@
m.metrics.BuildDateTimestamp = proto.Int64(buildTimestamp.UnixNano() / int64(time.Second))
}
+func (m *Metrics) SetBuildCommand(cmd []string) {
+ m.metrics.BuildCommand = proto.String(strings.Join(cmd, " "))
+}
+
// exports the output to the file at outputPath
func (m *Metrics) Dump(outputPath string) error {
// ignore the error if the hostname could not be retrieved as it