Enforce one aconfig_declaration per aconfig package
Bug: b/319121098 Change-Id: Ibe3f1587ed7754f00f464cf385ce51ee9a142412
This commit is contained in:
@@ -16,6 +16,7 @@ package aconfig
|
||||
|
||||
import (
|
||||
"android/soong/android"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// A singleton module that collects all of the aconfig flags declared in the
|
||||
@@ -35,6 +36,7 @@ type allAconfigDeclarationsSingleton struct {
|
||||
|
||||
func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
// Find all of the aconfig_declarations modules
|
||||
var packages = make(map[string]int)
|
||||
var cacheFiles android.Paths
|
||||
ctx.VisitAllModules(func(module android.Module) {
|
||||
decl, ok := android.SingletonModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey)
|
||||
@@ -42,8 +44,21 @@ func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.Si
|
||||
return
|
||||
}
|
||||
cacheFiles = append(cacheFiles, decl.IntermediateCacheOutputPath)
|
||||
packages[decl.Package]++
|
||||
})
|
||||
|
||||
var numOffendingPkg = 0
|
||||
for pkg, cnt := range packages {
|
||||
if cnt > 1 {
|
||||
fmt.Printf("%d aconfig_declarations found for package %s\n", cnt, pkg)
|
||||
numOffendingPkg++
|
||||
}
|
||||
}
|
||||
|
||||
if numOffendingPkg > 0 {
|
||||
panic(fmt.Errorf("Only one aconfig_declarations allowed for each package."))
|
||||
}
|
||||
|
||||
// Generate build action for aconfig
|
||||
this.intermediatePath = android.PathForIntermediates(ctx, "all_aconfig_declarations.pb")
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
|
Reference in New Issue
Block a user