Streamline AndroidMk generation
Add AndroidMkEmitAssignList to emit a line to assign the items from the given list of string arrays. Test: treehugger Change-Id: Id5acbef38ea4e91349bd2461f226db352d4b8123
This commit is contained in:
@@ -489,11 +489,11 @@ func (a *AndroidMkEntries) GetDistForGoals(mod blueprint.Module) []string {
|
||||
// Write the license variables to Make for AndroidMkData.Custom(..) methods that do not call WriteAndroidMkData(..)
|
||||
// It's required to propagate the license metadata even for module types that have non-standard interfaces to Make.
|
||||
func (a *AndroidMkEntries) WriteLicenseVariables(w io.Writer) {
|
||||
fmt.Fprintln(w, "LOCAL_LICENSE_KINDS :=", strings.Join(a.EntryMap["LOCAL_LICENSE_KINDS"], " "))
|
||||
fmt.Fprintln(w, "LOCAL_LICENSE_CONDITIONS :=", strings.Join(a.EntryMap["LOCAL_LICENSE_CONDITIONS"], " "))
|
||||
fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", strings.Join(a.EntryMap["LOCAL_NOTICE_FILE"], " "))
|
||||
AndroidMkEmitAssignList(w, "LOCAL_LICENSE_KINDS", a.EntryMap["LOCAL_LICENSE_KINDS"])
|
||||
AndroidMkEmitAssignList(w, "LOCAL_LICENSE_CONDITIONS", a.EntryMap["LOCAL_LICENSE_CONDITIONS"])
|
||||
AndroidMkEmitAssignList(w, "LOCAL_NOTICE_FILE", a.EntryMap["LOCAL_NOTICE_FILE"])
|
||||
if pn, ok := a.EntryMap["LOCAL_LICENSE_PACKAGE_NAME"]; ok {
|
||||
fmt.Fprintln(w, "LOCAL_LICENSE_PACKAGE_NAME :=", strings.Join(pn, " "))
|
||||
AndroidMkEmitAssignList(w, "LOCAL_LICENSE_PACKAGE_NAME", pn)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,7 +672,7 @@ func (a *AndroidMkEntries) write(w io.Writer) {
|
||||
|
||||
w.Write(a.header.Bytes())
|
||||
for _, name := range a.entryOrder {
|
||||
fmt.Fprintln(w, name+" := "+strings.Join(a.EntryMap[name], " "))
|
||||
AndroidMkEmitAssignList(w, name, a.EntryMap[name])
|
||||
}
|
||||
w.Write(a.footer.Bytes())
|
||||
}
|
||||
@@ -972,3 +972,28 @@ func AndroidMkDataPaths(data []DataPath) []string {
|
||||
}
|
||||
return testFiles
|
||||
}
|
||||
|
||||
// AndroidMkEmitAssignList emits the line
|
||||
//
|
||||
// VAR := ITEM ...
|
||||
//
|
||||
// Items are the elements to the given set of lists
|
||||
// If all the passed lists are empty, no line will be emitted
|
||||
func AndroidMkEmitAssignList(w io.Writer, varName string, lists ...[]string) {
|
||||
doPrint := false
|
||||
for _, l := range lists {
|
||||
if doPrint = len(l) > 0; doPrint {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !doPrint {
|
||||
return
|
||||
}
|
||||
fmt.Fprint(w, varName, " :=")
|
||||
for _, l := range lists {
|
||||
for _, item := range l {
|
||||
fmt.Fprint(w, " ", item)
|
||||
}
|
||||
}
|
||||
fmt.Fprintln(w)
|
||||
}
|
||||
|
Reference in New Issue
Block a user