Remove installFiles from ModuleBase.
This is to limit the direct accesses to the internal fields of a
module in order to better support incremental caching. To access
the install files data from singleton context or other modules'
context use providers thru the provided wrapper; to access it
from the same module inside GenerateBuildActions use ctx which is
short-lived only inside this method.
Bug: 358425833
Test: CI
Change-Id: I337b07a2ef95fb2a898ac2f9277160a3f76a603c
diff --git a/android/module.go b/android/module.go
index 63df6f7..d548b83 100644
--- a/android/module.go
+++ b/android/module.go
@@ -112,7 +112,6 @@
HostRequiredModuleNames() []string
TargetRequiredModuleNames() []string
- FilesToInstall() InstallPaths
PackagingSpecs() []PackagingSpec
// TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive
@@ -760,6 +759,14 @@
m.base().commonProperties.CreateCommonOSVariant = true
}
+func ModuleFilesToInstall(ctx OtherModuleProviderContext, m blueprint.Module) InstallPaths {
+ var filesToInstall InstallPaths
+ if info, ok := OtherModuleProvider(ctx, m, InstallFilesProvider); ok {
+ filesToInstall = info.InstallFiles
+ }
+ return filesToInstall
+}
+
// A ModuleBase object contains the properties that are common to all Android
// modules. It should be included as an anonymous field in every module
// struct definition. InitAndroidModule should then be called from the module's
@@ -832,7 +839,6 @@
primaryLicensesProperty applicableLicensesProperty
noAddressSanitizer bool
- installFiles InstallPaths
installFilesDepSet *DepSet[InstallPath]
checkbuildFiles Paths
packagingSpecs []PackagingSpec
@@ -1476,10 +1482,6 @@
return IsInstallDepNeededTag(tag)
}
-func (m *ModuleBase) FilesToInstall() InstallPaths {
- return m.installFiles
-}
-
func (m *ModuleBase) PackagingSpecs() []PackagingSpec {
return m.packagingSpecs
}
@@ -1615,12 +1617,16 @@
m.licenseInstallMap = append(m.licenseInstallMap, installMap...)
}
-func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
+func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) {
var allInstalledFiles InstallPaths
var allCheckbuildFiles Paths
ctx.VisitAllModuleVariants(func(module Module) {
a := module.base()
- allInstalledFiles = append(allInstalledFiles, a.installFiles...)
+ if a == m {
+ allInstalledFiles = append(allInstalledFiles, ctx.installFiles...)
+ } else {
+ allInstalledFiles = append(allInstalledFiles, ModuleFilesToInstall(ctx, module)...)
+ }
// A module's -checkbuild phony targets should
// not be created if the module is not exported to make.
// Those could depend on the build target and fail to compile
@@ -1763,6 +1769,12 @@
}
+type InstallFilesInfo struct {
+ InstallFiles InstallPaths
+}
+
+var InstallFilesProvider = blueprint.NewProvider[InstallFilesInfo]()
+
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
ctx := &moduleContext{
module: m.module,
@@ -1944,12 +1956,15 @@
return
}
- m.installFiles = append(m.installFiles, ctx.installFiles...)
m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...)
m.packagingSpecs = append(m.packagingSpecs, ctx.packagingSpecs...)
m.katiInstalls = append(m.katiInstalls, ctx.katiInstalls...)
m.katiSymlinks = append(m.katiSymlinks, ctx.katiSymlinks...)
m.testData = append(m.testData, ctx.testData...)
+
+ SetProvider(ctx, InstallFilesProvider, InstallFilesInfo{
+ InstallFiles: ctx.installFiles,
+ })
} else if ctx.Config().AllowMissingDependencies() {
// If the module is not enabled it will not create any build rules, nothing will call
// ctx.GetMissingDependencies(), and blueprint will consider the missing dependencies to be unhandled
@@ -1965,7 +1980,7 @@
}
}
- m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, m.installFiles, dependencyInstallFiles)
+ m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles)
m.packagingSpecsDepSet = NewDepSet[PackagingSpec](TOPOLOGICAL, m.packagingSpecs, dependencyPackagingSpecs)
buildLicenseMetadata(ctx, m.licenseMetadataFile)