From 779d41cf7c611ad03458f03a31a4eb964f4ca0ff Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 14 Jun 2024 11:14:33 -0700 Subject: [PATCH] Simplify aconfig_declarations_group Some of the getters were unused, which means that all the fields could be made into local variables. Test: m nothing --no-skip-soong-tests Change-Id: Iea38ed7f9da952803f54194c0c5a8fda9b6007f5 --- aconfig/codegen/aconfig_declarations_group.go | 55 +++++++------------ aconfig/codegen/java_aconfig_library.go | 8 +-- 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/aconfig/codegen/aconfig_declarations_group.go b/aconfig/codegen/aconfig_declarations_group.go index 33c20cdb2..13daf470b 100644 --- a/aconfig/codegen/aconfig_declarations_group.go +++ b/aconfig/codegen/aconfig_declarations_group.go @@ -39,11 +39,6 @@ type AconfigDeclarationsGroup struct { android.DefaultableModuleBase properties AconfigDeclarationsGroupProperties - - aconfigDeclarationNames []string - intermediateCacheOutputPaths android.Paths - javaSrcjars android.Paths - modeInfos map[string]android.ModeInfo } type AconfigDeclarationsGroupProperties struct { @@ -76,53 +71,45 @@ func (adg *AconfigDeclarationsGroup) DepsMutator(ctx android.BottomUpMutatorCont ctx.AddDependency(ctx.Module(), rustAconfigLibraryTag, adg.properties.Rust_aconfig_libraries...) } -func (adg *AconfigDeclarationsGroup) VisitDeps(ctx android.ModuleContext) { - adg.modeInfos = make(map[string]android.ModeInfo) +func (adg *AconfigDeclarationsGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) { + modeInfos := make(map[string]android.ModeInfo) + var aconfigDeclarationNames []string + var intermediateCacheOutputPaths android.Paths + var javaSrcjars android.Paths ctx.VisitDirectDeps(func(dep android.Module) { tag := ctx.OtherModuleDependencyTag(dep) 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...) - adg.intermediateCacheOutputPaths = append(adg.intermediateCacheOutputPaths, provider.IntermediateCacheOutputPaths...) + aconfigDeclarationNames = append(aconfigDeclarationNames, provider.AconfigDeclarations...) + intermediateCacheOutputPaths = append(intermediateCacheOutputPaths, provider.IntermediateCacheOutputPaths...) switch tag { 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) + javaSrcjars = append(javaSrcjars, provider.Srcjars...) + maps.Copy(modeInfos, provider.ModeInfos) case javaAconfigLibraryTag: - adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...) - maps.Copy(adg.modeInfos, provider.ModeInfos) + javaSrcjars = append(javaSrcjars, provider.Srcjars...) + maps.Copy(modeInfos, provider.ModeInfos) case ccAconfigLibraryTag: - maps.Copy(adg.modeInfos, provider.ModeInfos) + maps.Copy(modeInfos, provider.ModeInfos) case rustAconfigLibraryTag: - maps.Copy(adg.modeInfos, provider.ModeInfos) + maps.Copy(modeInfos, provider.ModeInfos) } } }) -} -func (adg *AconfigDeclarationsGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) { - adg.VisitDeps(ctx) - adg.aconfigDeclarationNames = android.FirstUniqueStrings(adg.aconfigDeclarationNames) - adg.intermediateCacheOutputPaths = android.FirstUniquePaths(adg.intermediateCacheOutputPaths) + aconfigDeclarationNames = android.FirstUniqueStrings(aconfigDeclarationNames) + intermediateCacheOutputPaths = android.FirstUniquePaths(intermediateCacheOutputPaths) android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{ - AconfigDeclarations: adg.aconfigDeclarationNames, - IntermediateCacheOutputPaths: adg.intermediateCacheOutputPaths, - Srcjars: adg.javaSrcjars, - ModeInfos: adg.modeInfos, + AconfigDeclarations: aconfigDeclarationNames, + IntermediateCacheOutputPaths: intermediateCacheOutputPaths, + Srcjars: javaSrcjars, + ModeInfos: modeInfos, }) - ctx.SetOutputFiles(adg.intermediateCacheOutputPaths, "") - ctx.SetOutputFiles(adg.javaSrcjars, ".srcjars") -} - -func (adg *AconfigDeclarationsGroup) Srcjars() android.Paths { - return adg.javaSrcjars -} - -func (adg *AconfigDeclarationsGroup) AconfigDeclarations() []string { - return adg.aconfigDeclarationNames + ctx.SetOutputFiles(intermediateCacheOutputPaths, "") + ctx.SetOutputFiles(javaSrcjars, ".srcjars") } diff --git a/aconfig/codegen/java_aconfig_library.go b/aconfig/codegen/java_aconfig_library.go index 9f42e21de..673ac2afe 100644 --- a/aconfig/codegen/java_aconfig_library.go +++ b/aconfig/codegen/java_aconfig_library.go @@ -15,8 +15,6 @@ package codegen import ( - "fmt" - "android/soong/android" "android/soong/java" @@ -80,7 +78,7 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuild // Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag declarationsModules := ctx.GetDirectDepsWithTag(declarationsTag) if len(declarationsModules) != 1 { - panic(fmt.Errorf("Exactly one aconfig_declarations property required")) + panic("Exactly one aconfig_declarations property required") } declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], android.AconfigDeclarationsProviderKey) @@ -133,10 +131,6 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuild return srcJarPath, declarations.IntermediateCacheOutputPath } -func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) AconfigDeclarations() *string { - return proptools.StringPtr(callbacks.properties.Aconfig_declarations) -} - func isModeSupported(mode string) bool { return android.InList(mode, aconfigSupportedModes) }