Convert computeInstallDeps and buildLicenseMetadata to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I63da95a938404b9d56cea65143479a961b82e051
diff --git a/android/license_metadata.go b/android/license_metadata.go
index 3df36e6..d15dfa8 100644
--- a/android/license_metadata.go
+++ b/android/license_metadata.go
@@ -15,11 +15,11 @@
package android
import (
- "github.com/google/blueprint/depset"
"sort"
"strings"
"github.com/google/blueprint"
+ "github.com/google/blueprint/depset"
"github.com/google/blueprint/proptools"
)
@@ -64,8 +64,8 @@
var allDepOutputFiles Paths
var allDepMetadataDepSets []depset.DepSet[Path]
- ctx.VisitDirectDeps(func(dep Module) {
- if !dep.Enabled(ctx) {
+ ctx.VisitDirectDepsProxy(func(dep ModuleProxy) {
+ if !OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoKey).Enabled {
return
}
@@ -81,7 +81,7 @@
if info, ok := OtherModuleProvider(ctx, dep, LicenseMetadataProvider); ok {
allDepMetadataFiles = append(allDepMetadataFiles, info.LicenseMetadataPath)
- if isContainer || isInstallDepNeeded(dep, ctx.OtherModuleDependencyTag(dep)) {
+ if isContainer || isInstallDepNeeded(ctx, dep) {
allDepMetadataDepSets = append(allDepMetadataDepSets, info.LicenseMetadataDepSet)
}
diff --git a/android/module.go b/android/module.go
index c2f4342..72dba04 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1475,12 +1475,13 @@
func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]depset.DepSet[InstallPath], []depset.DepSet[PackagingSpec]) {
var installDeps []depset.DepSet[InstallPath]
var packagingSpecs []depset.DepSet[PackagingSpec]
- ctx.VisitDirectDeps(func(dep Module) {
- if isInstallDepNeeded(dep, ctx.OtherModuleDependencyTag(dep)) {
+ ctx.VisitDirectDepsProxy(func(dep ModuleProxy) {
+ if isInstallDepNeeded(ctx, dep) {
// Installation is still handled by Make, so anything hidden from Make is not
// installable.
info := OtherModuleProviderOrDefault(ctx, dep, InstallFilesProvider)
- if !dep.IsHideFromMake() && !dep.IsSkipInstall() {
+ commonInfo := OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoKey)
+ if !commonInfo.HideFromMake && !commonInfo.SkipInstall {
installDeps = append(installDeps, info.TransitiveInstallFiles)
}
// Add packaging deps even when the dependency is not installed so that uninstallable
@@ -1494,13 +1495,13 @@
// isInstallDepNeeded returns true if installing the output files of the current module
// should also install the output files of the given dependency and dependency tag.
-func isInstallDepNeeded(dep Module, tag blueprint.DependencyTag) bool {
+func isInstallDepNeeded(ctx ModuleContext, dep ModuleProxy) bool {
// Don't add a dependency from the platform to a library provided by an apex.
- if dep.base().commonProperties.UninstallableApexPlatformVariant {
+ if OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoKey).UninstallableApexPlatformVariant {
return false
}
// Only install modules if the dependency tag is an InstallDepNeeded tag.
- return IsInstallDepNeededTag(tag)
+ return IsInstallDepNeededTag(ctx.OtherModuleDependencyTag(dep))
}
func (m *ModuleBase) NoAddressSanitizer() bool {
@@ -1873,6 +1874,13 @@
CanHaveApexVariants bool
MinSdkVersion string
NotAvailableForPlatform bool
+ // UninstallableApexPlatformVariant is set by MakeUninstallable called by the apex
+ // mutator. MakeUninstallable also sets HideFromMake. UninstallableApexPlatformVariant
+ // is used to avoid adding install or packaging dependencies into libraries provided
+ // by apexes.
+ UninstallableApexPlatformVariant bool
+ HideFromMake bool
+ SkipInstall bool
}
var CommonModuleInfoKey = blueprint.NewProvider[CommonModuleInfo]()
@@ -2138,10 +2146,13 @@
buildComplianceMetadataProvider(ctx, m)
commonData := CommonModuleInfo{
- ReplacedByPrebuilt: m.commonProperties.ReplacedByPrebuilt,
- CompileTarget: m.commonProperties.CompileTarget,
- SkipAndroidMkProcessing: shouldSkipAndroidMkProcessing(ctx, m),
- BaseModuleName: m.BaseModuleName(),
+ ReplacedByPrebuilt: m.commonProperties.ReplacedByPrebuilt,
+ CompileTarget: m.commonProperties.CompileTarget,
+ SkipAndroidMkProcessing: shouldSkipAndroidMkProcessing(ctx, m),
+ BaseModuleName: m.BaseModuleName(),
+ UninstallableApexPlatformVariant: m.commonProperties.UninstallableApexPlatformVariant,
+ HideFromMake: m.commonProperties.HideFromMake,
+ SkipInstall: m.commonProperties.SkipInstall,
}
if mm, ok := m.module.(interface {
MinSdkVersion(ctx EarlyModuleContext) ApiLevel
@@ -2737,6 +2748,7 @@
if octx, ok := ctx.(OutputFilesProviderModuleContext); ok {
if octx.EqualModules(octx.Module(), module) {
+ // It is the current module, we can access the srcs through interface
if sourceFileProducer, ok := module.(SourceFileProducer); ok {
return sourceFileProducer.Srcs(), nil
}