Update Soong docs generator for blueprint changes

bootstrap.ModuleTypeDocs needs a mapping of module types to factories
to support factories that are wrapped in ModuleFactoryAdapter closures.

It also returns ModuleType objects grouped into Package objects.

Bug: 67909957
Test: m soong_docs
Change-Id: I70eac9f0f0e13075580da92d4219792ca0b18fbf
This commit is contained in:
Colin Cross
2019-01-25 22:43:35 -08:00
committed by Jaewoong Jung
parent 1b16b0e031
commit 7089c27c07
3 changed files with 32 additions and 7 deletions

View File

@@ -19,18 +19,33 @@ import (
"bytes"
"html/template"
"io/ioutil"
"reflect"
"sort"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/bootstrap/bpdoc"
)
func writeDocs(ctx *android.Context, filename string) error {
moduleTypeList, err := bootstrap.ModuleTypeDocs(ctx.Context)
moduleTypeFactories := android.ModuleTypeFactories()
bpModuleTypeFactories := make(map[string]reflect.Value)
for moduleType, factory := range moduleTypeFactories {
bpModuleTypeFactories[moduleType] = reflect.ValueOf(factory)
}
packages, err := bootstrap.ModuleTypeDocs(ctx.Context, bpModuleTypeFactories)
if err != nil {
return err
}
buf := &bytes.Buffer{}
var moduleTypeList []*bpdoc.ModuleType
for _, pkg := range packages {
moduleTypeList = append(moduleTypeList, pkg.ModuleTypes...)
}
sort.Slice(moduleTypeList, func(i, j int) bool { return moduleTypeList[i].Name < moduleTypeList[j].Name })
unique := 0
tmpl, err := template.New("file").Funcs(map[string]interface{}{