diff options
author | Colin Cross | 2019-01-26 00:43:35 -0600 |
---|---|---|
committer | Jaewoong Jung | 2019-02-13 14:39:26 -0600 |
commit | 7089c27c07afef014b49455e41dc586f6d418b3f (patch) | |
tree | 821ac6eff0bc2f7afb3249f878129acb9ac60b8e /cmd | |
parent | 1b16b0e031e747bbeed103df08f0441ccf342069 (diff) | |
download | platform-build-soong-7089c27c07afef014b49455e41dc586f6d418b3f.tar.gz platform-build-soong-7089c27c07afef014b49455e41dc586f6d418b3f.tar.xz platform-build-soong-7089c27c07afef014b49455e41dc586f6d418b3f.zip |
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
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/soong_build/main.go | 6 | ||||
-rw-r--r-- | cmd/soong_build/writedocs.go | 17 |
2 files changed, 21 insertions, 2 deletions
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index a4c6898d..1f6002ee 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go | |||
@@ -75,6 +75,10 @@ func main() { | |||
75 | bootstrap.Main(ctx.Context, configuration, configuration.ConfigFileName, configuration.ProductVariablesFileName) | 75 | bootstrap.Main(ctx.Context, configuration, configuration.ConfigFileName, configuration.ProductVariablesFileName) |
76 | 76 | ||
77 | if docFile != "" { | 77 | if docFile != "" { |
78 | writeDocs(ctx, docFile) | 78 | err := writeDocs(ctx, docFile) |
79 | if err != nil { | ||
80 | fmt.Fprintf(os.Stderr, "%s", err) | ||
81 | os.Exit(1) | ||
82 | } | ||
79 | } | 83 | } |
80 | } | 84 | } |
diff --git a/cmd/soong_build/writedocs.go b/cmd/soong_build/writedocs.go index a6686c0d..8f86b332 100644 --- a/cmd/soong_build/writedocs.go +++ b/cmd/soong_build/writedocs.go | |||
@@ -19,18 +19,33 @@ import ( | |||
19 | "bytes" | 19 | "bytes" |
20 | "html/template" | 20 | "html/template" |
21 | "io/ioutil" | 21 | "io/ioutil" |
22 | "reflect" | ||
23 | "sort" | ||
22 | 24 | ||
23 | "github.com/google/blueprint/bootstrap" | 25 | "github.com/google/blueprint/bootstrap" |
26 | "github.com/google/blueprint/bootstrap/bpdoc" | ||
24 | ) | 27 | ) |
25 | 28 | ||
26 | func writeDocs(ctx *android.Context, filename string) error { | 29 | func writeDocs(ctx *android.Context, filename string) error { |
27 | moduleTypeList, err := bootstrap.ModuleTypeDocs(ctx.Context) | 30 | moduleTypeFactories := android.ModuleTypeFactories() |
31 | bpModuleTypeFactories := make(map[string]reflect.Value) | ||
32 | for moduleType, factory := range moduleTypeFactories { | ||
33 | bpModuleTypeFactories[moduleType] = reflect.ValueOf(factory) | ||
34 | } | ||
35 | |||
36 | packages, err := bootstrap.ModuleTypeDocs(ctx.Context, bpModuleTypeFactories) | ||
28 | if err != nil { | 37 | if err != nil { |
29 | return err | 38 | return err |
30 | } | 39 | } |
31 | 40 | ||
32 | buf := &bytes.Buffer{} | 41 | buf := &bytes.Buffer{} |
33 | 42 | ||
43 | var moduleTypeList []*bpdoc.ModuleType | ||
44 | for _, pkg := range packages { | ||
45 | moduleTypeList = append(moduleTypeList, pkg.ModuleTypes...) | ||
46 | } | ||
47 | sort.Slice(moduleTypeList, func(i, j int) bool { return moduleTypeList[i].Name < moduleTypeList[j].Name }) | ||
48 | |||
34 | unique := 0 | 49 | unique := 0 |
35 | 50 | ||
36 | tmpl, err := template.New("file").Funcs(map[string]interface{}{ | 51 | tmpl, err := template.New("file").Funcs(map[string]interface{}{ |