From 70e17fa6a57e9df3b4c99c2fcfbdd680bb1bcdc8 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Mon, 25 Jul 2016 16:00:20 -0700 Subject: [PATCH] Dump Soong module type statistics to Make Make will combine this information with statistics gathered from the Make build, then dump it out to a build artifact. Change-Id: I2bd84d4f8a8d145c37e3a4c4fcc8fece99e2a1de --- android/androidmk.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/android/androidmk.go b/android/androidmk.go index 7d7707f52..232a599b7 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -96,12 +96,28 @@ func translateAndroidMk(ctx blueprint.SingletonContext, mkFile string, mods []Mo fmt.Fprintln(buf, "LOCAL_MODULE_MAKEFILE := $(lastword $(MAKEFILE_LIST))") + type_stats := make(map[string]int) for _, mod := range mods { err := translateAndroidMkModule(ctx, buf, mod) if err != nil { os.Remove(mkFile) return err } + + if ctx.PrimaryModule(mod) == mod { + type_stats[ctx.ModuleType(mod)] += 1 + } + } + + keys := []string{} + fmt.Fprintln(buf, "\nSTATS.SOONG_MODULE_TYPE :=") + for k := range type_stats { + keys = append(keys, k) + } + sort.Strings(keys) + for _, mod_type := range keys { + fmt.Fprintln(buf, "STATS.SOONG_MODULE_TYPE +=", mod_type) + fmt.Fprintf(buf, "STATS.SOONG_MODULE_TYPE.%s := %d\n", mod_type, type_stats[mod_type]) } // Don't write to the file if it hasn't changed