diff options
author | 2025-01-15 20:57:49 +0000 | |
---|---|---|
committer | 2025-01-15 20:57:49 +0000 | |
commit | cbb50c29b75b52e03c0b366034a563ba8dedcc65 (patch) | |
tree | 08873055dafb0e550dab56771789565d561e734a | |
parent | 2da9d9abca8e1a355f8b9fcbb3ae550bfb40a8b6 (diff) |
Convert AndroidLibrary.GenerateAndroidBuildActions,
ApiLibrry.GenerateAndroidBuildActions, Binary.GenerateAndroidBuildActions and collectDepProguardSpecInfo to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I2d9a09ee6797d9cb2a7d696571784fcfcea7aff7
-rw-r--r-- | java/aar.go | 2 | ||||
-rw-r--r-- | java/base.go | 2 | ||||
-rw-r--r-- | java/droidstubs.go | 11 | ||||
-rw-r--r-- | java/java.go | 14 |
4 files changed, 20 insertions, 9 deletions
diff --git a/java/aar.go b/java/aar.go index b982b9571..3479f9376 100644 --- a/java/aar.go +++ b/java/aar.go @@ -1040,7 +1040,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) } prebuiltJniPackages := android.Paths{} - ctx.VisitDirectDeps(func(module android.Module) { + ctx.VisitDirectDepsProxy(func(module android.ModuleProxy) { if info, ok := android.OtherModuleProvider(ctx, module, JniPackageProvider); ok { prebuiltJniPackages = append(prebuiltJniPackages, info.JniPackages...) } diff --git a/java/base.go b/java/base.go index 8e013b954..0b896d815 100644 --- a/java/base.go +++ b/java/base.go @@ -1978,7 +1978,7 @@ func (j *Module) useCompose(ctx android.BaseModuleContext) bool { } func collectDepProguardSpecInfo(ctx android.ModuleContext) (transitiveProguardFlags, transitiveUnconditionalExportedFlags []depset.DepSet[android.Path]) { - ctx.VisitDirectDeps(func(m android.Module) { + ctx.VisitDirectDepsProxy(func(m android.ModuleProxy) { depProguardInfo, _ := android.OtherModuleProvider(ctx, m, ProguardSpecInfoProvider) depTag := ctx.OtherModuleDependencyTag(m) diff --git a/java/droidstubs.go b/java/droidstubs.go index fa1fb8649..17c39fcaa 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -20,6 +20,7 @@ import ( "regexp" "strings" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" "android/soong/android" @@ -27,6 +28,12 @@ import ( "android/soong/remoteexec" ) +type DroidStubsInfo struct { + CurrentApiTimestamp android.Path +} + +var DroidStubsInfoProvider = blueprint.NewProvider[DroidStubsInfo]() + // The values allowed for Droidstubs' Api_levels_sdk_type var allowedApiLevelSdkTypes = []string{"public", "system", "module-lib", "system-server"} @@ -1340,6 +1347,10 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { rule.Build("nullabilityWarningsCheck", "nullability warnings check") } + android.SetProvider(ctx, DroidStubsInfoProvider, DroidStubsInfo{ + CurrentApiTimestamp: d.CurrentApiTimestamp(), + }) + d.setOutputFiles(ctx) } diff --git a/java/java.go b/java/java.go index 0a9381dad..b2d8b72a1 100644 --- a/java/java.go +++ b/java/java.go @@ -1958,13 +1958,13 @@ func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) { // Set the jniLibs of this binary. // These will be added to `LOCAL_REQUIRED_MODULES`, and the kati packaging system will // install these alongside the java binary. - ctx.VisitDirectDepsWithTag(jniInstallTag, func(jni android.Module) { + ctx.VisitDirectDepsProxyWithTag(jniInstallTag, func(jni android.ModuleProxy) { // Use the BaseModuleName of the dependency (without any prebuilt_ prefix) - bmn, _ := jni.(interface{ BaseModuleName() string }) - j.androidMkNamesOfJniLibs = append(j.androidMkNamesOfJniLibs, bmn.BaseModuleName()+":"+jni.Target().Arch.ArchType.Bitness()) + commonInfo, _ := android.OtherModuleProvider(ctx, jni, android.CommonModuleInfoKey) + j.androidMkNamesOfJniLibs = append(j.androidMkNamesOfJniLibs, commonInfo.BaseModuleName+":"+commonInfo.Target.Arch.ArchType.Bitness()) }) // Check that native libraries are not listed in `required`. Prompt users to use `jni_libs` instead. - ctx.VisitDirectDepsWithTag(android.RequiredDepTag, func(dep android.Module) { + ctx.VisitDirectDepsProxyWithTag(android.RequiredDepTag, func(dep android.ModuleProxy) { if _, hasSharedLibraryInfo := android.OtherModuleProvider(ctx, dep, cc.SharedLibraryInfoProvider); hasSharedLibraryInfo { ctx.ModuleErrorf("cc_library %s is no longer supported in `required` of java_binary modules. Please use jni_libs instead.", dep.Name()) } @@ -2355,7 +2355,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { var bootclassPaths android.Paths var staticLibs android.Paths var systemModulesPaths android.Paths - ctx.VisitDirectDeps(func(dep android.Module) { + ctx.VisitDirectDepsProxy(func(dep android.ModuleProxy) { tag := ctx.OtherModuleDependencyTag(dep) switch tag { case javaApiContributionTag: @@ -2384,8 +2384,8 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { systemModulesPaths = append(systemModulesPaths, sm.HeaderJars...) } case metalavaCurrentApiTimestampTag: - if currentApiTimestampProvider, ok := dep.(currentApiTimestampProvider); ok { - al.validationPaths = append(al.validationPaths, currentApiTimestampProvider.CurrentApiTimestamp()) + if currentApiTimestampProvider, ok := android.OtherModuleProvider(ctx, dep, DroidStubsInfoProvider); ok { + al.validationPaths = append(al.validationPaths, currentApiTimestampProvider.CurrentApiTimestamp) } case aconfigDeclarationTag: if provider, ok := android.OtherModuleProvider(ctx, dep, android.AconfigDeclarationsProviderKey); ok { |