Build rules for compat config docs generation.
We add a compat config build rule to extract the merged config, and then update the droiddoc build rule to consume that. Test: m -j offline-sdk-docs Bug: 144927670 Change-Id: Ib1e85f97895c89227882e665572bda9bfc2a8cba Exempt-From-Owner-Approval: ag/10097965 approved internally, Colin requested to patch to aosp
This commit is contained in:
committed by
Anna Trostanetski
parent
db84575f84
commit
abd49ab4df
@@ -223,6 +223,9 @@ type DroiddocProperties struct {
|
|||||||
|
|
||||||
// if set to true, generate docs through Dokka instead of Doclava.
|
// if set to true, generate docs through Dokka instead of Doclava.
|
||||||
Dokka_enabled *bool
|
Dokka_enabled *bool
|
||||||
|
|
||||||
|
// Compat config XML. Generates compat change documentation if set.
|
||||||
|
Compat_config *string `android:"path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DroidstubsProperties struct {
|
type DroidstubsProperties struct {
|
||||||
@@ -1037,6 +1040,11 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
cmd.Flag(d.Javadoc.args).Implicits(d.Javadoc.argFiles)
|
cmd.Flag(d.Javadoc.args).Implicits(d.Javadoc.argFiles)
|
||||||
|
|
||||||
|
if d.properties.Compat_config != nil {
|
||||||
|
compatConfig := android.PathForModuleSrc(ctx, String(d.properties.Compat_config))
|
||||||
|
cmd.FlagWithInput("-compatconfig ", compatConfig)
|
||||||
|
}
|
||||||
|
|
||||||
var desc string
|
var desc string
|
||||||
if Bool(d.properties.Dokka_enabled) {
|
if Bool(d.properties.Dokka_enabled) {
|
||||||
desc = "dokka"
|
desc = "dokka"
|
||||||
|
@@ -16,11 +16,17 @@ package java
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterSingletonType("platform_compat_config_singleton", platformCompatConfigSingletonFactory)
|
android.RegisterSingletonType("platform_compat_config_singleton", platformCompatConfigSingletonFactory)
|
||||||
android.RegisterModuleType("platform_compat_config", platformCompatConfigFactory)
|
android.RegisterModuleType("platform_compat_config", platformCompatConfigFactory)
|
||||||
|
android.RegisterModuleType("global_compat_config", globalCompatConfigFactory)
|
||||||
|
}
|
||||||
|
|
||||||
|
func platformCompatConfigPath(ctx android.PathContext) android.OutputPath {
|
||||||
|
return android.PathForOutput(ctx, "compat_config", "merged_compat_config.xml")
|
||||||
}
|
}
|
||||||
|
|
||||||
type platformCompatConfigSingleton struct {
|
type platformCompatConfigSingleton struct {
|
||||||
@@ -68,7 +74,7 @@ func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.Singlet
|
|||||||
}
|
}
|
||||||
|
|
||||||
rule := android.NewRuleBuilder()
|
rule := android.NewRuleBuilder()
|
||||||
outputPath := android.PathForOutput(ctx, "compat_config", "merged_compat_config.xml")
|
outputPath := platformCompatConfigPath(ctx)
|
||||||
|
|
||||||
rule.Command().
|
rule.Command().
|
||||||
BuiltTool(ctx, "process-compat-config").
|
BuiltTool(ctx, "process-compat-config").
|
||||||
@@ -130,3 +136,49 @@ func platformCompatConfigFactory() android.Module {
|
|||||||
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============== merged_compat_config =================
|
||||||
|
type globalCompatConfigProperties struct {
|
||||||
|
// name of the file into which the metadata will be copied.
|
||||||
|
Filename *string
|
||||||
|
}
|
||||||
|
|
||||||
|
type globalCompatConfig struct {
|
||||||
|
android.ModuleBase
|
||||||
|
|
||||||
|
properties globalCompatConfigProperties
|
||||||
|
|
||||||
|
outputFilePath android.OutputPath
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *globalCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
filename := String(c.properties.Filename)
|
||||||
|
|
||||||
|
inputPath := platformCompatConfigPath(ctx)
|
||||||
|
c.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
|
||||||
|
|
||||||
|
// This ensures that outputFilePath has the correct name for others to
|
||||||
|
// use, as the source file may have a different name.
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: android.Cp,
|
||||||
|
Output: c.outputFilePath,
|
||||||
|
Input: inputPath,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *globalCompatConfig) OutputFiles(tag string) (android.Paths, error) {
|
||||||
|
switch tag {
|
||||||
|
case "":
|
||||||
|
return android.Paths{h.outputFilePath}, nil
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// global_compat_config provides access to the merged compat config xml file generated by the build.
|
||||||
|
func globalCompatConfigFactory() android.Module {
|
||||||
|
module := &globalCompatConfig{}
|
||||||
|
module.AddProperties(&module.properties)
|
||||||
|
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user