Merge multiple compat_config.xml's.

Previously, the compat configs from static dependencies were all written
to compat/compat_config.xml, putting at the mercy of jar file merging and
so potentially losing some config.

Now the annotation processor writes a compat_config.xml for each Java
class that exports config, we we merge them together here with a new
tool.

Test: m
Change-Id: I28c12ff648a01aaad214701fca4f09743638b11b
This commit is contained in:
Mathew Inwood 2019-12-16 12:55:26 +00:00
parent 572aeed6a4
commit 2471c086ac
1 changed files with 2 additions and 21 deletions

View File

@ -41,30 +41,11 @@ func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleCon
p.configFile = android.PathForModuleOut(ctx, configFileName).OutputPath
path := android.PathForModuleSrc(ctx, String(p.properties.Src))
// Use the empty config if the compat config file idoesn't exist (can happen if @ChangeId
// annotation is not used).
emptyConfig := `'<?xml version="1.0" encoding="UTF-8" standalone="no"?><config/>'`
configPath := `compat/compat_config.xml`
rule.Command().
Text(`unzip`).
Flag(`-l`).
BuiltTool(ctx, "process-compat-config").
Input(path).
Text(`| grep`).
Flag(`-q`).
Text(configPath).
Text(`; if [ "$?" = "0" ] ; then`).
Text(`unzip`).
Flag(`-qp`).
Input(path).
Text(configPath).
Text(`>`).
Output(p.configFile).
Text(`; else echo `).
Text(emptyConfig).
Text(`>`).
Output(p.configFile).
Text(`; fi`)
Output(p.configFile)
p.installDirPath = android.PathForModuleInstall(ctx, "etc", "compatconfig")
rule.Build(pctx, ctx, configFileName, "Extract compat/compat_config.xml and install it")