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
This commit is contained in:
@@ -861,6 +861,7 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *
|
|||||||
}
|
}
|
||||||
|
|
||||||
data := provider.AndroidMk()
|
data := provider.AndroidMk()
|
||||||
|
|
||||||
if data.Include == "" {
|
if data.Include == "" {
|
||||||
data.Include = "$(BUILD_PREBUILT)"
|
data.Include = "$(BUILD_PREBUILT)"
|
||||||
}
|
}
|
||||||
|
@@ -160,7 +160,7 @@ var (
|
|||||||
// buildComplianceMetadataProvider starts with the ModuleContext.ComplianceMetadataInfo() and fills in more common metadata
|
// buildComplianceMetadataProvider starts with the ModuleContext.ComplianceMetadataInfo() and fills in more common metadata
|
||||||
// for different module types without accessing their private fields but through android.Module interface
|
// for different module types without accessing their private fields but through android.Module interface
|
||||||
// and public/private fields of package android. The final metadata is stored to a module's ComplianceMetadataProvider.
|
// and public/private fields of package android. The final metadata is stored to a module's ComplianceMetadataProvider.
|
||||||
func buildComplianceMetadataProvider(ctx ModuleContext, m *ModuleBase) {
|
func buildComplianceMetadataProvider(ctx *moduleContext, m *ModuleBase) {
|
||||||
complianceMetadataInfo := ctx.ComplianceMetadataInfo()
|
complianceMetadataInfo := ctx.ComplianceMetadataInfo()
|
||||||
complianceMetadataInfo.SetStringValue(ComplianceMetadataProp.NAME, m.Name())
|
complianceMetadataInfo.SetStringValue(ComplianceMetadataProp.NAME, m.Name())
|
||||||
complianceMetadataInfo.SetStringValue(ComplianceMetadataProp.PACKAGE, ctx.ModuleDir())
|
complianceMetadataInfo.SetStringValue(ComplianceMetadataProp.PACKAGE, ctx.ModuleDir())
|
||||||
@@ -186,7 +186,7 @@ func buildComplianceMetadataProvider(ctx ModuleContext, m *ModuleBase) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var installed InstallPaths
|
var installed InstallPaths
|
||||||
installed = append(installed, m.module.FilesToInstall()...)
|
installed = append(installed, ctx.installFiles...)
|
||||||
installed = append(installed, m.katiInstalls.InstallPaths()...)
|
installed = append(installed, m.katiInstalls.InstallPaths()...)
|
||||||
installed = append(installed, m.katiSymlinks.InstallPaths()...)
|
installed = append(installed, m.katiSymlinks.InstallPaths()...)
|
||||||
installed = append(installed, m.katiInitRcInstalls.InstallPaths()...)
|
installed = append(installed, m.katiInitRcInstalls.InstallPaths()...)
|
||||||
|
@@ -33,7 +33,7 @@ var (
|
|||||||
}, "args")
|
}, "args")
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) {
|
func buildLicenseMetadata(ctx *moduleContext, licenseMetadataFile WritablePath) {
|
||||||
base := ctx.Module().base()
|
base := ctx.Module().base()
|
||||||
|
|
||||||
if !base.Enabled(ctx) {
|
if !base.Enabled(ctx) {
|
||||||
@@ -52,8 +52,8 @@ func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) {
|
|||||||
// Only pass the last installed file to isContainerFromFileExtensions so a *.zip file in test data
|
// Only pass the last installed file to isContainerFromFileExtensions so a *.zip file in test data
|
||||||
// doesn't mark the whole module as a container.
|
// doesn't mark the whole module as a container.
|
||||||
var installFiles InstallPaths
|
var installFiles InstallPaths
|
||||||
if len(base.installFiles) > 0 {
|
if len(ctx.installFiles) > 0 {
|
||||||
installFiles = InstallPaths{base.installFiles[len(base.installFiles)-1]}
|
installFiles = InstallPaths{ctx.installFiles[len(ctx.installFiles)-1]}
|
||||||
}
|
}
|
||||||
|
|
||||||
isContainer := isContainerFromFileExtensions(installFiles, outputFiles)
|
isContainer := isContainerFromFileExtensions(installFiles, outputFiles)
|
||||||
@@ -92,7 +92,7 @@ func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) {
|
|||||||
|
|
||||||
allDepMetadataArgs = append(allDepMetadataArgs, info.LicenseMetadataPath.String()+depAnnotations)
|
allDepMetadataArgs = append(allDepMetadataArgs, info.LicenseMetadataPath.String()+depAnnotations)
|
||||||
|
|
||||||
if depInstallFiles := dep.base().installFiles; len(depInstallFiles) > 0 {
|
if depInstallFiles := ModuleFilesToInstall(ctx, dep); len(depInstallFiles) > 0 {
|
||||||
allDepOutputFiles = append(allDepOutputFiles, depInstallFiles.Paths()...)
|
allDepOutputFiles = append(allDepOutputFiles, depInstallFiles.Paths()...)
|
||||||
} else if depOutputFiles, err := outputFilesForModule(ctx, dep, ""); err == nil {
|
} else if depOutputFiles, err := outputFilesForModule(ctx, dep, ""); err == nil {
|
||||||
depOutputFiles = PathsIfNonNil(depOutputFiles...)
|
depOutputFiles = PathsIfNonNil(depOutputFiles...)
|
||||||
@@ -162,7 +162,7 @@ func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) {
|
|||||||
|
|
||||||
// Installed files
|
// Installed files
|
||||||
args = append(args,
|
args = append(args,
|
||||||
JoinWithPrefix(proptools.NinjaAndShellEscapeListIncludingSpaces(base.installFiles.Strings()), "-i "))
|
JoinWithPrefix(proptools.NinjaAndShellEscapeListIncludingSpaces(ctx.installFiles.Strings()), "-i "))
|
||||||
|
|
||||||
if isContainer {
|
if isContainer {
|
||||||
args = append(args, "--is_container")
|
args = append(args, "--is_container")
|
||||||
|
@@ -112,7 +112,6 @@ type Module interface {
|
|||||||
HostRequiredModuleNames() []string
|
HostRequiredModuleNames() []string
|
||||||
TargetRequiredModuleNames() []string
|
TargetRequiredModuleNames() []string
|
||||||
|
|
||||||
FilesToInstall() InstallPaths
|
|
||||||
PackagingSpecs() []PackagingSpec
|
PackagingSpecs() []PackagingSpec
|
||||||
|
|
||||||
// TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive
|
// TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive
|
||||||
@@ -760,6 +759,14 @@ func InitCommonOSAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupport
|
|||||||
m.base().commonProperties.CreateCommonOSVariant = true
|
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
|
// A ModuleBase object contains the properties that are common to all Android
|
||||||
// modules. It should be included as an anonymous field in every module
|
// modules. It should be included as an anonymous field in every module
|
||||||
// struct definition. InitAndroidModule should then be called from the module's
|
// struct definition. InitAndroidModule should then be called from the module's
|
||||||
@@ -832,7 +839,6 @@ type ModuleBase struct {
|
|||||||
primaryLicensesProperty applicableLicensesProperty
|
primaryLicensesProperty applicableLicensesProperty
|
||||||
|
|
||||||
noAddressSanitizer bool
|
noAddressSanitizer bool
|
||||||
installFiles InstallPaths
|
|
||||||
installFilesDepSet *DepSet[InstallPath]
|
installFilesDepSet *DepSet[InstallPath]
|
||||||
checkbuildFiles Paths
|
checkbuildFiles Paths
|
||||||
packagingSpecs []PackagingSpec
|
packagingSpecs []PackagingSpec
|
||||||
@@ -1476,10 +1482,6 @@ func isInstallDepNeeded(dep Module, tag blueprint.DependencyTag) bool {
|
|||||||
return IsInstallDepNeededTag(tag)
|
return IsInstallDepNeededTag(tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) FilesToInstall() InstallPaths {
|
|
||||||
return m.installFiles
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ModuleBase) PackagingSpecs() []PackagingSpec {
|
func (m *ModuleBase) PackagingSpecs() []PackagingSpec {
|
||||||
return m.packagingSpecs
|
return m.packagingSpecs
|
||||||
}
|
}
|
||||||
@@ -1615,12 +1617,16 @@ func (m *ModuleBase) SetLicenseInstallMap(installMap []string) {
|
|||||||
m.licenseInstallMap = append(m.licenseInstallMap, installMap...)
|
m.licenseInstallMap = append(m.licenseInstallMap, installMap...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
|
func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) {
|
||||||
var allInstalledFiles InstallPaths
|
var allInstalledFiles InstallPaths
|
||||||
var allCheckbuildFiles Paths
|
var allCheckbuildFiles Paths
|
||||||
ctx.VisitAllModuleVariants(func(module Module) {
|
ctx.VisitAllModuleVariants(func(module Module) {
|
||||||
a := module.base()
|
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
|
// A module's -checkbuild phony targets should
|
||||||
// not be created if the module is not exported to make.
|
// not be created if the module is not exported to make.
|
||||||
// Those could depend on the build target and fail to compile
|
// Those could depend on the build target and fail to compile
|
||||||
@@ -1763,6 +1769,12 @@ func (m *ModuleBase) archModuleContextFactory(ctx archModuleContextFactoryContex
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type InstallFilesInfo struct {
|
||||||
|
InstallFiles InstallPaths
|
||||||
|
}
|
||||||
|
|
||||||
|
var InstallFilesProvider = blueprint.NewProvider[InstallFilesInfo]()
|
||||||
|
|
||||||
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
||||||
ctx := &moduleContext{
|
ctx := &moduleContext{
|
||||||
module: m.module,
|
module: m.module,
|
||||||
@@ -1944,12 +1956,15 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.installFiles = append(m.installFiles, ctx.installFiles...)
|
|
||||||
m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...)
|
m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...)
|
||||||
m.packagingSpecs = append(m.packagingSpecs, ctx.packagingSpecs...)
|
m.packagingSpecs = append(m.packagingSpecs, ctx.packagingSpecs...)
|
||||||
m.katiInstalls = append(m.katiInstalls, ctx.katiInstalls...)
|
m.katiInstalls = append(m.katiInstalls, ctx.katiInstalls...)
|
||||||
m.katiSymlinks = append(m.katiSymlinks, ctx.katiSymlinks...)
|
m.katiSymlinks = append(m.katiSymlinks, ctx.katiSymlinks...)
|
||||||
m.testData = append(m.testData, ctx.testData...)
|
m.testData = append(m.testData, ctx.testData...)
|
||||||
|
|
||||||
|
SetProvider(ctx, InstallFilesProvider, InstallFilesInfo{
|
||||||
|
InstallFiles: ctx.installFiles,
|
||||||
|
})
|
||||||
} else if ctx.Config().AllowMissingDependencies() {
|
} else if ctx.Config().AllowMissingDependencies() {
|
||||||
// If the module is not enabled it will not create any build rules, nothing will call
|
// 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
|
// ctx.GetMissingDependencies(), and blueprint will consider the missing dependencies to be unhandled
|
||||||
@@ -1965,7 +1980,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, m.installFiles, dependencyInstallFiles)
|
m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles)
|
||||||
m.packagingSpecsDepSet = NewDepSet[PackagingSpec](TOPOLOGICAL, m.packagingSpecs, dependencyPackagingSpecs)
|
m.packagingSpecsDepSet = NewDepSet[PackagingSpec](TOPOLOGICAL, m.packagingSpecs, dependencyPackagingSpecs)
|
||||||
|
|
||||||
buildLicenseMetadata(ctx, m.licenseMetadataFile)
|
buildLicenseMetadata(ctx, m.licenseMetadataFile)
|
||||||
|
@@ -47,7 +47,7 @@ func (t *testSuiteFiles) GenerateBuildActions(ctx SingletonContext) {
|
|||||||
files[testSuite] = make(map[string]InstallPaths)
|
files[testSuite] = make(map[string]InstallPaths)
|
||||||
}
|
}
|
||||||
name := ctx.ModuleName(m)
|
name := ctx.ModuleName(m)
|
||||||
files[testSuite][name] = append(files[testSuite][name], tsm.FilesToInstall()...)
|
files[testSuite][name] = append(files[testSuite][name], ModuleFilesToInstall(ctx, tsm)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -46,6 +46,9 @@ type sdkRepoHost struct {
|
|||||||
|
|
||||||
outputBaseName string
|
outputBaseName string
|
||||||
outputFile android.OptionalPath
|
outputFile android.OptionalPath
|
||||||
|
|
||||||
|
// TODO(b/357908583): Temp field, remove this once we support Android Mk providers
|
||||||
|
installFile android.InstallPath
|
||||||
}
|
}
|
||||||
|
|
||||||
type remapProperties struct {
|
type remapProperties struct {
|
||||||
@@ -234,14 +237,18 @@ func (s *sdkRepoHost) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
s.outputBaseName = name
|
s.outputBaseName = name
|
||||||
s.outputFile = android.OptionalPathForPath(outputZipFile)
|
s.outputFile = android.OptionalPathForPath(outputZipFile)
|
||||||
ctx.InstallFile(android.PathForModuleInstall(ctx, "sdk-repo"), name+".zip", outputZipFile)
|
installPath := android.PathForModuleInstall(ctx, "sdk-repo")
|
||||||
|
name = name + ".zip"
|
||||||
|
ctx.InstallFile(installPath, name, outputZipFile)
|
||||||
|
// TODO(b/357908583): Temp field, remove this once we support Android Mk providers
|
||||||
|
s.installFile = installPath.Join(ctx, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sdkRepoHost) AndroidMk() android.AndroidMkData {
|
func (s *sdkRepoHost) AndroidMk() android.AndroidMkData {
|
||||||
return android.AndroidMkData{
|
return android.AndroidMkData{
|
||||||
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
||||||
fmt.Fprintln(w, ".PHONY:", name, "sdk_repo", "sdk-repo-"+name)
|
fmt.Fprintln(w, ".PHONY:", name, "sdk_repo", "sdk-repo-"+name)
|
||||||
fmt.Fprintln(w, "sdk_repo", "sdk-repo-"+name+":", strings.Join(s.FilesToInstall().Strings(), " "))
|
fmt.Fprintln(w, "sdk_repo", "sdk-repo-"+name+":", s.installFile.String())
|
||||||
|
|
||||||
fmt.Fprintf(w, "$(call dist-for-goals,sdk_repo sdk-repo-%s,%s:%s-FILE_NAME_TAG_PLACEHOLDER.zip)\n\n", s.BaseModuleName(), s.outputFile.String(), s.outputBaseName)
|
fmt.Fprintf(w, "$(call dist-for-goals,sdk_repo sdk-repo-%s,%s:%s-FILE_NAME_TAG_PLACEHOLDER.zip)\n\n", s.BaseModuleName(), s.outputFile.String(), s.outputBaseName)
|
||||||
},
|
},
|
||||||
|
@@ -476,7 +476,7 @@ func (m *CmakeSnapshot) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
var prebuiltsList android.Paths
|
var prebuiltsList android.Paths
|
||||||
|
|
||||||
ctx.VisitDirectDepsWithTag(cmakeSnapshotPrebuiltTag, func(dep android.Module) {
|
ctx.VisitDirectDepsWithTag(cmakeSnapshotPrebuiltTag, func(dep android.Module) {
|
||||||
for _, file := range dep.FilesToInstall() {
|
for _, file := range android.ModuleFilesToInstall(ctx, dep) {
|
||||||
prebuiltsList = append(prebuiltsList, file)
|
prebuiltsList = append(prebuiltsList, file)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -1109,7 +1109,7 @@ func collectJniDeps(ctx android.ModuleContext,
|
|||||||
coverageFile: dep.CoverageOutputFile(),
|
coverageFile: dep.CoverageOutputFile(),
|
||||||
unstrippedFile: dep.UnstrippedOutputFile(),
|
unstrippedFile: dep.UnstrippedOutputFile(),
|
||||||
partition: dep.Partition(),
|
partition: dep.Partition(),
|
||||||
installPaths: dep.FilesToInstall(),
|
installPaths: android.ModuleFilesToInstall(ctx, dep),
|
||||||
})
|
})
|
||||||
} else if ctx.Config().AllowMissingDependencies() {
|
} else if ctx.Config().AllowMissingDependencies() {
|
||||||
ctx.AddMissingDependencies([]string{otherName})
|
ctx.AddMissingDependencies([]string{otherName})
|
||||||
|
@@ -152,7 +152,7 @@ func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
var runtimeJniModuleNames map[string]bool
|
var runtimeJniModuleNames map[string]bool
|
||||||
|
|
||||||
if utils := ctx.GetDirectDepsWithTag(ravenwoodUtilsTag)[0]; utils != nil {
|
if utils := ctx.GetDirectDepsWithTag(ravenwoodUtilsTag)[0]; utils != nil {
|
||||||
for _, installFile := range utils.FilesToInstall() {
|
for _, installFile := range android.ModuleFilesToInstall(ctx, utils) {
|
||||||
installDeps = append(installDeps, installFile)
|
installDeps = append(installDeps, installFile)
|
||||||
}
|
}
|
||||||
jniDeps, ok := android.OtherModuleProvider(ctx, utils, ravenwoodLibgroupJniDepProvider)
|
jniDeps, ok := android.OtherModuleProvider(ctx, utils, ravenwoodLibgroupJniDepProvider)
|
||||||
@@ -162,7 +162,7 @@ func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if runtime := ctx.GetDirectDepsWithTag(ravenwoodRuntimeTag)[0]; runtime != nil {
|
if runtime := ctx.GetDirectDepsWithTag(ravenwoodRuntimeTag)[0]; runtime != nil {
|
||||||
for _, installFile := range runtime.FilesToInstall() {
|
for _, installFile := range android.ModuleFilesToInstall(ctx, runtime) {
|
||||||
installDeps = append(installDeps, installFile)
|
installDeps = append(installDeps, installFile)
|
||||||
}
|
}
|
||||||
jniDeps, ok := android.OtherModuleProvider(ctx, runtime, ravenwoodLibgroupJniDepProvider)
|
jniDeps, ok := android.OtherModuleProvider(ctx, runtime, ravenwoodLibgroupJniDepProvider)
|
||||||
@@ -191,7 +191,7 @@ func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
resApkInstallPath := installPath.Join(ctx, "ravenwood-res-apks")
|
resApkInstallPath := installPath.Join(ctx, "ravenwood-res-apks")
|
||||||
if resApk := ctx.GetDirectDepsWithTag(ravenwoodTestResourceApkTag); len(resApk) > 0 {
|
if resApk := ctx.GetDirectDepsWithTag(ravenwoodTestResourceApkTag); len(resApk) > 0 {
|
||||||
for _, installFile := range resApk[0].FilesToInstall() {
|
for _, installFile := range android.ModuleFilesToInstall(ctx, resApk[0]) {
|
||||||
installResApk := ctx.InstallFile(resApkInstallPath, "ravenwood-res.apk", installFile)
|
installResApk := ctx.InstallFile(resApkInstallPath, "ravenwood-res.apk", installFile)
|
||||||
installDeps = append(installDeps, installResApk)
|
installDeps = append(installDeps, installResApk)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user