Add GetOutputsFromModuleNames in Context

To build ninja hint including output path from module name

Test: m --ninja_weight_source=soong
Bug: 273282046
Change-Id: Ibb94c2c4efef4a6dedc973cbb90625231845d42e
This commit is contained in:
Jeongik Cha 2023-03-23 01:48:26 +09:00
parent bef8688e45
commit 4589dfd812

View file

@ -2705,6 +2705,30 @@ func getNinjaStringsWithNilPkgNames(nStrs []ninjaString) []string {
return strs
}
func (c *Context) GetOutputsFromModuleNames(moduleNames []string) map[string][]string {
modulesToOutputs := make(map[string][]string)
for _, m := range c.modulesSorted {
if inList(m.Name(), moduleNames) {
jmWithActions := jsonModuleWithActionsFromModuleInfo(m)
for _, a := range jmWithActions.Module["Actions"].([]JSONAction) {
modulesToOutputs[m.Name()] = append(modulesToOutputs[m.Name()], a.Outputs...)
}
// There could be several modules with the same name, so keep looping
}
}
return modulesToOutputs
}
func inList(s string, l []string) bool {
for _, element := range l {
if s == element {
return true
}
}
return false
}
// PrintJSONGraph prints info of modules in a JSON file.
func (c *Context) PrintJSONGraphAndActions(wGraph io.Writer, wActions io.Writer) {
modulesToGraph := make([]*JsonModule, 0)