Merge "Add aconfig annotations for java_aconfig_library" into main

This commit is contained in:
Treehugger Robot 2023-08-28 13:03:56 +00:00 committed by Gerrit Code Review
commit 01f70e8d0e
3 changed files with 26 additions and 0 deletions

View file

@ -52,6 +52,9 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) DepsMutator(module *ja
} else {
ctx.AddDependency(ctx.Module(), declarationsTag, declarations)
}
// Add aconfig-annotations-lib as a dependency for the optimization / code stripping annotations
module.AddSharedLibrary("aconfig-annotations-lib")
}
func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuildActions(module *java.GeneratedJavaLibraryModule, ctx android.ModuleContext) android.Path {

View file

@ -22,6 +22,10 @@ type GeneratedJavaLibraryModule struct {
Library
callbacks GeneratedJavaLibraryCallbacks
moduleName string
// true if we've already called DepsMutator. Can't call AddLibrary or AddSharedLibrary
// after DepsMutator.
depsMutatorDone bool
}
type GeneratedJavaLibraryCallbacks interface {
@ -59,8 +63,25 @@ func GeneratedJavaLibraryModuleFactory(moduleName string, callbacks GeneratedJav
return module
}
// Add a java shared library as a dependency, as if they had said `libs: [ "name" ]`
func (module *GeneratedJavaLibraryModule) AddSharedLibrary(name string) {
if module.depsMutatorDone {
panic("GeneratedJavaLibraryModule.AddLibrary called after DepsMutator")
}
module.Library.properties.Libs = append(module.Library.properties.Libs, name)
}
// Add a java shared library as a dependency, as if they had said `libs: [ "name" ]`
func (module *GeneratedJavaLibraryModule) AddStaticLibrary(name string) {
if module.depsMutatorDone {
panic("GeneratedJavaLibraryModule.AddStaticLibrary called after DepsMutator")
}
module.Library.properties.Static_libs = append(module.Library.properties.Static_libs, name)
}
func (module *GeneratedJavaLibraryModule) DepsMutator(ctx android.BottomUpMutatorContext) {
module.callbacks.DepsMutator(module, ctx)
module.depsMutatorDone = true
module.Library.DepsMutator(ctx)
}

View file

@ -385,6 +385,8 @@ func gatherRequiredDepsForTest() string {
"kotlin-stdlib-jdk8",
"kotlin-annotations",
"stub-annotations",
"aconfig-annotations-lib",
}
for _, extra := range extraModules {