From 5c4729df937924426ffac330531b64f409ceec29 Mon Sep 17 00:00:00 2001 From: Sasha Smundak Date: Thu, 1 Dec 2022 10:49:23 -0800 Subject: [PATCH] Show module type in a module section of the Android-TARGET.mk The first line of each section will be ``` include $(CLEAR_VARS) # ... ``` Bug: 257037252 Test: treehugger Change-Id: Iba586155b682fe4e1e5817d8397eda8f9d9c8789 --- android/androidmk.go | 3 ++- apex/androidmk.go | 6 +++--- bpf/bpf.go | 4 ++-- java/robolectric.go | 2 +- phony/phony.go | 2 +- sysprop/sysprop_library.go | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/android/androidmk.go b/android/androidmk.go index 18e3e7ac4..846d5061c 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -504,6 +504,7 @@ type fillInEntriesContext interface { Config() Config ModuleProvider(module blueprint.Module, provider blueprint.ProviderKey) interface{} ModuleHasProvider(module blueprint.Module, provider blueprint.ProviderKey) bool + ModuleType(module blueprint.Module) string } func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint.Module) { @@ -527,7 +528,7 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint fmt.Fprintf(&a.header, distString) } - fmt.Fprintln(&a.header, "\ninclude $(CLEAR_VARS)") + fmt.Fprintln(&a.header, "\ninclude $(CLEAR_VARS) # "+ctx.ModuleType(mod)) // Collect make variable assignment entries. a.SetString("LOCAL_PATH", ctx.ModuleDir(mod)) diff --git a/apex/androidmk.go b/apex/androidmk.go index 3373211a0..0fc971bb0 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -134,7 +134,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo continue } - fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") + fmt.Fprintln(w, "\ninclude $(CLEAR_VARS) # apex.apexBundle.files") if fi.moduleDir != "" { fmt.Fprintln(w, "LOCAL_PATH :=", fi.moduleDir) } else { @@ -348,7 +348,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { if apexType == flattenedApex { // Only image APEXes can be flattened. - fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") + fmt.Fprintln(w, "\ninclude $(CLEAR_VARS) # apex.apexBundle.flat") fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) fmt.Fprintln(w, "LOCAL_MODULE :=", name+a.suffix) data.Entries.WriteLicenseVariables(w) @@ -356,7 +356,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)") } else { - fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") + fmt.Fprintln(w, "\ninclude $(CLEAR_VARS) # apex.apexBundle") fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) fmt.Fprintln(w, "LOCAL_MODULE :=", name+a.suffix) data.Entries.WriteLicenseVariables(w) diff --git a/bpf/bpf.go b/bpf/bpf.go index a840fa3df..d91180b91 100644 --- a/bpf/bpf.go +++ b/bpf/bpf.go @@ -227,7 +227,7 @@ func (bpf *bpf) AndroidMk() android.AndroidMkData { for _, obj := range bpf.objs { objName := name + "_" + obj.Base() names = append(names, objName) - fmt.Fprintln(w, "include $(CLEAR_VARS)") + fmt.Fprintln(w, "include $(CLEAR_VARS)", " # bpf.bpf.obj") fmt.Fprintln(w, "LOCAL_MODULE := ", objName) data.Entries.WriteLicenseVariables(w) fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", obj.String()) @@ -237,7 +237,7 @@ func (bpf *bpf) AndroidMk() android.AndroidMkData { fmt.Fprintln(w, "include $(BUILD_PREBUILT)") fmt.Fprintln(w) } - fmt.Fprintln(w, "include $(CLEAR_VARS)") + fmt.Fprintln(w, "include $(CLEAR_VARS)", " # bpf.bpf") fmt.Fprintln(w, "LOCAL_MODULE := ", name) data.Entries.WriteLicenseVariables(w) fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(names, " ")) diff --git a/java/robolectric.go b/java/robolectric.go index 2cb07981e..1d567083d 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -327,7 +327,7 @@ func (r *robolectricTest) AndroidMkEntries() []android.AndroidMkEntries { func (r *robolectricTest) writeTestRunner(w io.Writer, module, name string, tests []string) { fmt.Fprintln(w, "") - fmt.Fprintln(w, "include $(CLEAR_VARS)") + fmt.Fprintln(w, "include $(CLEAR_VARS)", " # java.robolectricTest") fmt.Fprintln(w, "LOCAL_MODULE :=", name) fmt.Fprintln(w, "LOCAL_JAVA_LIBRARIES :=", module) fmt.Fprintln(w, "LOCAL_JAVA_LIBRARIES += ", strings.Join(r.libs, " ")) diff --git a/phony/phony.go b/phony/phony.go index a31d402af..760b79b8a 100644 --- a/phony/phony.go +++ b/phony/phony.go @@ -49,7 +49,7 @@ func (p *phony) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (p *phony) AndroidMk() android.AndroidMkData { return android.AndroidMkData{ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { - fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") + fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)", " # phony.phony") fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) fmt.Fprintln(w, "LOCAL_MODULE :=", name) data.Entries.WriteLicenseVariables(w) diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go index 1f0d28d56..0edbb7c37 100644 --- a/sysprop/sysprop_library.go +++ b/sysprop/sysprop_library.go @@ -336,8 +336,8 @@ func (m *syspropLibrary) AndroidMk() android.AndroidMkData { Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { // sysprop_library module itself is defined as a FAKE module to perform API check. // Actual implementation libraries are created on LoadHookMutator - fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)") - fmt.Fprintf(w, "LOCAL_MODULE := %s\n", m.Name()) + fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)", " # sysprop.syspropLibrary") + fmt.Fprintln(w, "LOCAL_MODULE :=", m.Name()) data.Entries.WriteLicenseVariables(w) fmt.Fprintf(w, "LOCAL_MODULE_CLASS := FAKE\n") fmt.Fprintf(w, "LOCAL_MODULE_TAGS := optional\n")