Always record kati stats into soong log

Pass --dump-stats to ckati, but filter out the '*kati*' lines so that
they only end up in our verbose output. That way we've always got access
to the statistics.

Bug: 36182021
Test: m nothing; cat out/soong.log
Change-Id: Iaf7a814fc67f3e475c913faf69924a7f4e2ae3b3
diff --git a/ui/build/kati.go b/ui/build/kati.go
index c58621e..7bb721d 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -77,6 +77,7 @@
 		"--color_warnings",
 		"--gen_all_targets",
 		"--werror_find_emulator",
+		"--kati_stats",
 		"-f", "build/make/core/main.mk",
 	}
 
@@ -109,6 +110,7 @@
 }
 
 var katiIncludeRe = regexp.MustCompile(`^(\[\d+/\d+] )?including [^ ]+ ...$`)
+var katiLogRe = regexp.MustCompile(`^\*kati\*: `)
 
 func katiRewriteOutput(ctx Context, pipe io.ReadCloser) {
 	haveBlankLine := true
@@ -119,6 +121,12 @@
 		line := scanner.Text()
 		verbose := katiIncludeRe.MatchString(line)
 
+		// Only put kati debug/stat lines in our verbose log
+		if katiLogRe.MatchString(line) {
+			ctx.Verbose(line)
+			continue
+		}
+
 		// For verbose lines, write them on the current line without a newline,
 		// then overwrite them if the next thing we're printing is another
 		// verbose line.