Remove more internal fields from ModuleBase.
Bug: 358425833
Test: Manual compare the generated ninja and mk files and CI.
Change-Id: I4edd0dc646ac035594f47cd9044cc4eb5f710e64
diff --git a/android/androidmk.go b/android/androidmk.go
index f88a226..081bca9 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -536,13 +536,14 @@
a.AddStrings("LOCAL_SOONG_MODULE_TYPE", ctx.ModuleType(amod))
// If the install rule was generated by Soong tell Make about it.
- if len(base.katiInstalls) > 0 {
+ info := OtherModuleProviderOrDefault(ctx, mod, InstallFilesProvider)
+ if len(info.KatiInstalls) > 0 {
// Assume the primary install file is last since it probably needs to depend on any other
// installed files. If that is not the case we can add a method to specify the primary
// installed file.
- a.SetPath("LOCAL_SOONG_INSTALLED_MODULE", base.katiInstalls[len(base.katiInstalls)-1].to)
- a.SetString("LOCAL_SOONG_INSTALL_PAIRS", base.katiInstalls.BuiltInstalled())
- a.SetPaths("LOCAL_SOONG_INSTALL_SYMLINKS", base.katiSymlinks.InstallPaths().Paths())
+ a.SetPath("LOCAL_SOONG_INSTALLED_MODULE", info.KatiInstalls[len(info.KatiInstalls)-1].to)
+ a.SetString("LOCAL_SOONG_INSTALL_PAIRS", info.KatiInstalls.BuiltInstalled())
+ a.SetPaths("LOCAL_SOONG_INSTALL_SYMLINKS", info.KatiSymlinks.InstallPaths().Paths())
} else {
// Soong may not have generated the install rule also when `no_full_install: true`.
// Mark this module as uninstallable in order to prevent Make from creating an
@@ -550,8 +551,8 @@
a.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", proptools.Bool(base.commonProperties.No_full_install))
}
- if len(base.testData) > 0 {
- a.AddStrings("LOCAL_TEST_DATA", androidMkDataPaths(base.testData)...)
+ if len(info.TestData) > 0 {
+ a.AddStrings("LOCAL_TEST_DATA", androidMkDataPaths(info.TestData)...)
}
if am, ok := mod.(ApexModule); ok {
diff --git a/android/compliance_metadata.go b/android/compliance_metadata.go
index 5cdd302..4c92f71 100644
--- a/android/compliance_metadata.go
+++ b/android/compliance_metadata.go
@@ -187,8 +187,8 @@
var installed InstallPaths
installed = append(installed, ctx.installFiles...)
- installed = append(installed, m.katiInstalls.InstallPaths()...)
- installed = append(installed, m.katiSymlinks.InstallPaths()...)
+ installed = append(installed, ctx.katiInstalls.InstallPaths()...)
+ installed = append(installed, ctx.katiSymlinks.InstallPaths()...)
installed = append(installed, m.katiInitRcInstalls.InstallPaths()...)
installed = append(installed, m.katiVintfInstalls.InstallPaths()...)
complianceMetadataInfo.SetListValue(ComplianceMetadataProp.INSTALLED_FILES, FirstUniqueStrings(installed.Strings()))
diff --git a/android/license_metadata.go b/android/license_metadata.go
index c12a01c..cd69749 100644
--- a/android/license_metadata.go
+++ b/android/license_metadata.go
@@ -92,7 +92,7 @@
allDepMetadataArgs = append(allDepMetadataArgs, info.LicenseMetadataPath.String()+depAnnotations)
- if depInstallFiles := ModuleFilesToInstall(ctx, dep); len(depInstallFiles) > 0 {
+ if depInstallFiles := OtherModuleProviderOrDefault(ctx, dep, InstallFilesProvider).InstallFiles; len(depInstallFiles) > 0 {
allDepOutputFiles = append(allDepOutputFiles, depInstallFiles.Paths()...)
} else if depOutputFiles, err := outputFilesForModule(ctx, dep, ""); err == nil {
depOutputFiles = PathsIfNonNil(depOutputFiles...)
diff --git a/android/makevars.go b/android/makevars.go
index ff43cc5..810eb38 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -279,10 +279,11 @@
}
if m.ExportedToMake() {
- katiInstalls = append(katiInstalls, m.base().katiInstalls...)
+ info := OtherModuleProviderOrDefault(ctx, m, InstallFilesProvider)
+ katiInstalls = append(katiInstalls, info.KatiInstalls...)
katiInitRcInstalls = append(katiInitRcInstalls, m.base().katiInitRcInstalls...)
katiVintfManifestInstalls = append(katiVintfManifestInstalls, m.base().katiVintfInstalls...)
- katiSymlinks = append(katiSymlinks, m.base().katiSymlinks...)
+ katiSymlinks = append(katiSymlinks, info.KatiSymlinks...)
}
})
diff --git a/android/module.go b/android/module.go
index d548b83..e9a36ab 100644
--- a/android/module.go
+++ b/android/module.go
@@ -112,8 +112,6 @@
HostRequiredModuleNames() []string
TargetRequiredModuleNames() []string
- PackagingSpecs() []PackagingSpec
-
// TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive
// dependencies with dependency tags for which IsInstallDepNeeded() returns true.
TransitivePackagingSpecs() []PackagingSpec
@@ -759,14 +757,6 @@
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
@@ -840,18 +830,11 @@
noAddressSanitizer bool
installFilesDepSet *DepSet[InstallPath]
- checkbuildFiles Paths
- packagingSpecs []PackagingSpec
packagingSpecsDepSet *DepSet[PackagingSpec]
- // katiInstalls tracks the install rules that were created by Soong but are being exported
- // to Make to convert to ninja rules so that Make can add additional dependencies.
- katiInstalls katiInstalls
// katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
// allowed to have duplicates across modules and variants.
katiInitRcInstalls katiInstalls
katiVintfInstalls katiInstalls
- katiSymlinks katiInstalls
- testData []DataPath
// The files to copy to the dist as explicitly specified in the .bp file.
distFiles TaggedDistFiles
@@ -1482,10 +1465,6 @@
return IsInstallDepNeededTag(tag)
}
-func (m *ModuleBase) PackagingSpecs() []PackagingSpec {
- return m.packagingSpecs
-}
-
func (m *ModuleBase) TransitivePackagingSpecs() []PackagingSpec {
return m.packagingSpecsDepSet.ToList()
}
@@ -1622,17 +1601,21 @@
var allCheckbuildFiles Paths
ctx.VisitAllModuleVariants(func(module Module) {
a := module.base()
+ var checkBuilds Paths
if a == m {
allInstalledFiles = append(allInstalledFiles, ctx.installFiles...)
+ checkBuilds = ctx.checkbuildFiles
} else {
- allInstalledFiles = append(allInstalledFiles, ModuleFilesToInstall(ctx, module)...)
+ info := OtherModuleProviderOrDefault(ctx, module, InstallFilesProvider)
+ allInstalledFiles = append(allInstalledFiles, info.InstallFiles...)
+ checkBuilds = info.CheckbuildFiles
}
// 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
// for the current build target.
if !ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(ctx, a) {
- allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
+ allCheckbuildFiles = append(allCheckbuildFiles, checkBuilds...)
}
})
@@ -1770,7 +1753,14 @@
}
type InstallFilesInfo struct {
- InstallFiles InstallPaths
+ InstallFiles InstallPaths
+ CheckbuildFiles Paths
+ PackagingSpecs []PackagingSpec
+ // katiInstalls tracks the install rules that were created by Soong but are being exported
+ // to Make to convert to ninja rules so that Make can add additional dependencies.
+ KatiInstalls katiInstalls
+ KatiSymlinks katiInstalls
+ TestData []DataPath
}
var InstallFilesProvider = blueprint.NewProvider[InstallFilesInfo]()
@@ -1956,14 +1946,13 @@
return
}
- 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,
+ InstallFiles: ctx.installFiles,
+ CheckbuildFiles: ctx.checkbuildFiles,
+ PackagingSpecs: ctx.packagingSpecs,
+ KatiInstalls: ctx.katiInstalls,
+ KatiSymlinks: ctx.katiSymlinks,
+ TestData: ctx.testData,
})
} else if ctx.Config().AllowMissingDependencies() {
// If the module is not enabled it will not create any build rules, nothing will call
@@ -1981,14 +1970,14 @@
}
m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles)
- m.packagingSpecsDepSet = NewDepSet[PackagingSpec](TOPOLOGICAL, m.packagingSpecs, dependencyPackagingSpecs)
+ m.packagingSpecsDepSet = NewDepSet[PackagingSpec](TOPOLOGICAL, ctx.packagingSpecs, dependencyPackagingSpecs)
buildLicenseMetadata(ctx, m.licenseMetadataFile)
if m.moduleInfoJSON != nil {
var installed InstallPaths
- installed = append(installed, m.katiInstalls.InstallPaths()...)
- installed = append(installed, m.katiSymlinks.InstallPaths()...)
+ installed = append(installed, ctx.katiInstalls.InstallPaths()...)
+ installed = append(installed, ctx.katiSymlinks.InstallPaths()...)
installed = append(installed, m.katiInitRcInstalls.InstallPaths()...)
installed = append(installed, m.katiVintfInstalls.InstallPaths()...)
installedStrings := installed.Strings()
@@ -2001,7 +1990,7 @@
}
var data []string
- for _, d := range m.testData {
+ for _, d := range ctx.testData {
data = append(data, d.ToRelativeInstallPath())
}
@@ -2681,7 +2670,7 @@
ctx.VisitAllModules(func(module Module) {
if module.Enabled(ctx) {
key := osAndCross{os: module.Target().Os, hostCross: module.Target().HostCross}
- osDeps[key] = append(osDeps[key], module.base().checkbuildFiles...)
+ osDeps[key] = append(osDeps[key], OtherModuleProviderOrDefault(ctx, module, InstallFilesProvider).CheckbuildFiles...)
}
})
diff --git a/android/module_context.go b/android/module_context.go
index 253bebd..f619da2 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -231,8 +231,8 @@
module Module
phonies map[string]Paths
- katiInstalls []katiInstall
- katiSymlinks []katiInstall
+ katiInstalls katiInstalls
+ katiSymlinks katiInstalls
testData []DataPath
diff --git a/android/provider.go b/android/provider.go
index 327f224..5ded4cc 100644
--- a/android/provider.go
+++ b/android/provider.go
@@ -32,6 +32,11 @@
return value.(K), ok
}
+func OtherModuleProviderOrDefault[K any](ctx OtherModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) K {
+ value, _ := OtherModuleProvider(ctx, module, provider)
+ return value
+}
+
// ModuleProviderContext is a helper interface that is a subset of ModuleContext, BottomUpMutatorContext, or
// TopDownMutatorContext for use in ModuleProvider.
type ModuleProviderContext interface {
diff --git a/android/test_suites.go b/android/test_suites.go
index c0dc17e..936d2b6 100644
--- a/android/test_suites.go
+++ b/android/test_suites.go
@@ -47,7 +47,8 @@
files[testSuite] = make(map[string]InstallPaths)
}
name := ctx.ModuleName(m)
- files[testSuite][name] = append(files[testSuite][name], ModuleFilesToInstall(ctx, tsm)...)
+ files[testSuite][name] = append(files[testSuite][name],
+ OtherModuleProviderOrDefault(ctx, tsm, InstallFilesProvider).InstallFiles...)
}
}
})