Validate aconfig libs are built with the correct modes.
Bug: 323071835 Test: Unit tests and manual tests. Change-Id: I32de90826c7c8bb4d8495608e959d554820ab9a2
This commit is contained in:
@@ -15,9 +15,10 @@
|
||||
package codegen
|
||||
|
||||
import (
|
||||
"android/soong/aconfig"
|
||||
"android/soong/android"
|
||||
"fmt"
|
||||
"maps"
|
||||
|
||||
"android/soong/android"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
)
|
||||
@@ -43,6 +44,7 @@ type AconfigDeclarationsGroup struct {
|
||||
aconfigDeclarationNames []string
|
||||
intermediateCacheOutputPaths android.Paths
|
||||
javaSrcjars android.Paths
|
||||
modeInfos map[string]android.ModeInfo
|
||||
}
|
||||
|
||||
type AconfigDeclarationsGroupProperties struct {
|
||||
@@ -76,9 +78,10 @@ func (adg *AconfigDeclarationsGroup) DepsMutator(ctx android.BottomUpMutatorCont
|
||||
}
|
||||
|
||||
func (adg *AconfigDeclarationsGroup) VisitDeps(ctx android.ModuleContext) {
|
||||
adg.modeInfos = make(map[string]android.ModeInfo)
|
||||
ctx.VisitDirectDeps(func(dep android.Module) {
|
||||
tag := ctx.OtherModuleDependencyTag(dep)
|
||||
if provider, ok := android.OtherModuleProvider(ctx, dep, aconfig.CodegenInfoProvider); ok {
|
||||
if provider, ok := android.OtherModuleProvider(ctx, dep, android.CodegenInfoProvider); ok {
|
||||
|
||||
// aconfig declaration names and cache files are collected for all aconfig library dependencies
|
||||
adg.aconfigDeclarationNames = append(adg.aconfigDeclarationNames, provider.AconfigDeclarations...)
|
||||
@@ -88,8 +91,14 @@ func (adg *AconfigDeclarationsGroup) VisitDeps(ctx android.ModuleContext) {
|
||||
case aconfigDeclarationsGroupTag:
|
||||
// Will retrieve outputs from another language codegen modules when support is added
|
||||
adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
|
||||
maps.Copy(adg.modeInfos, provider.ModeInfos)
|
||||
case javaAconfigLibraryTag:
|
||||
adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
|
||||
maps.Copy(adg.modeInfos, provider.ModeInfos)
|
||||
case ccAconfigLibraryTag:
|
||||
maps.Copy(adg.modeInfos, provider.ModeInfos)
|
||||
case rustAconfigLibraryTag:
|
||||
maps.Copy(adg.modeInfos, provider.ModeInfos)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -100,10 +109,11 @@ func (adg *AconfigDeclarationsGroup) GenerateAndroidBuildActions(ctx android.Mod
|
||||
adg.aconfigDeclarationNames = android.FirstUniqueStrings(adg.aconfigDeclarationNames)
|
||||
adg.intermediateCacheOutputPaths = android.FirstUniquePaths(adg.intermediateCacheOutputPaths)
|
||||
|
||||
android.SetProvider(ctx, aconfig.CodegenInfoProvider, aconfig.CodegenInfo{
|
||||
android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
|
||||
AconfigDeclarations: adg.aconfigDeclarationNames,
|
||||
IntermediateCacheOutputPaths: adg.intermediateCacheOutputPaths,
|
||||
Srcjars: adg.javaSrcjars,
|
||||
ModeInfos: adg.modeInfos,
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -146,4 +146,12 @@ func (this *CcAconfigLibraryCallbacks) GeneratorBuildActions(ctx cc.ModuleContex
|
||||
"mode": mode,
|
||||
},
|
||||
})
|
||||
|
||||
android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
|
||||
ModeInfos: map[string]android.ModeInfo{
|
||||
ctx.ModuleName(): {
|
||||
Container: declarations.Container,
|
||||
Mode: mode,
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@ package codegen
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"android/soong/aconfig"
|
||||
"android/soong/android"
|
||||
"android/soong/java"
|
||||
|
||||
@@ -119,10 +118,15 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuild
|
||||
module.AddJarJarRenameRule(declarations.Package+".FakeFeatureFlagsImpl", "")
|
||||
}
|
||||
|
||||
android.SetProvider(ctx, aconfig.CodegenInfoProvider, aconfig.CodegenInfo{
|
||||
android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
|
||||
AconfigDeclarations: []string{declarationsModules[0].Name()},
|
||||
IntermediateCacheOutputPaths: android.Paths{declarations.IntermediateCacheOutputPath},
|
||||
Srcjars: android.Paths{srcJarPath},
|
||||
ModeInfos: map[string]android.ModeInfo{
|
||||
ctx.ModuleName(): {
|
||||
Container: declarations.Container,
|
||||
Mode: mode,
|
||||
}},
|
||||
})
|
||||
|
||||
return srcJarPath
|
||||
|
@@ -85,6 +85,15 @@ func (a *aconfigDecorator) GenerateSource(ctx rust.ModuleContext, deps rust.Path
|
||||
},
|
||||
})
|
||||
a.BaseSourceProvider.OutputFiles = android.Paths{generatedSource}
|
||||
|
||||
android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
|
||||
ModeInfos: map[string]android.ModeInfo{
|
||||
ctx.ModuleName(): {
|
||||
Container: declarations.Container,
|
||||
Mode: mode,
|
||||
}},
|
||||
})
|
||||
|
||||
return generatedSource
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user