Revert "Remove installFilesDepSet, packagingSpecsDepSet and lice..."

Revert submission 28945194-Remove installFilesDepSet

Reason for revert: will resubmit from aosp

Reverted changes: /q/submissionid:28945194-Remove+installFilesDepSet

Change-Id: I2a04998774da71ad0415958d7e1633a0833293f9
This commit is contained in:
Yu Liu
2024-08-23 19:04:39 +00:00
committed by Android (Google) Code Review
parent 8e5db7d26c
commit c6335186a4
6 changed files with 72 additions and 74 deletions

View File

@@ -152,7 +152,7 @@ func buildLicenseMetadata(ctx *moduleContext, licenseMetadataFile WritablePath)
// Install map // Install map
args = append(args, args = append(args,
JoinWithPrefix(proptools.NinjaAndShellEscapeListIncludingSpaces(ctx.licenseInstallMap), "-m ")) JoinWithPrefix(proptools.NinjaAndShellEscapeListIncludingSpaces(base.licenseInstallMap), "-m "))
// Built files // Built files
if len(outputFiles) > 0 { if len(outputFiles) > 0 {

View File

@@ -113,6 +113,10 @@ type Module interface {
TargetRequiredModuleNames() []string TargetRequiredModuleNames() []string
VintfFragmentModuleNames(ctx ConfigAndErrorContext) []string VintfFragmentModuleNames(ctx ConfigAndErrorContext) []string
// TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive
// dependencies with dependency tags for which IsInstallDepNeeded() returns true.
TransitivePackagingSpecs() []PackagingSpec
ConfigurableEvaluator(ctx ConfigAndErrorContext) proptools.ConfigurableEvaluator ConfigurableEvaluator(ctx ConfigAndErrorContext) proptools.ConfigurableEvaluator
// Get the information about the containers this module belongs to. // Get the information about the containers this module belongs to.
@@ -832,6 +836,8 @@ type ModuleBase struct {
primaryLicensesProperty applicableLicensesProperty primaryLicensesProperty applicableLicensesProperty
noAddressSanitizer bool noAddressSanitizer bool
installFilesDepSet *DepSet[InstallPath]
packagingSpecsDepSet *DepSet[PackagingSpec]
// katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are // katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
// allowed to have duplicates across modules and variants. // allowed to have duplicates across modules and variants.
katiInitRcInstalls katiInstalls katiInitRcInstalls katiInstalls
@@ -858,6 +864,10 @@ type ModuleBase struct {
// Merged Aconfig files for all transitive deps. // Merged Aconfig files for all transitive deps.
aconfigFilePaths Paths aconfigFilePaths Paths
// set of dependency module:location mappings used to populate the license metadata for
// apex containers.
licenseInstallMap []string
// The path to the generated license metadata file for the module. // The path to the generated license metadata file for the module.
licenseMetadataFile WritablePath licenseMetadataFile WritablePath
@@ -1444,13 +1454,12 @@ func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]*DepSet[InstallPat
if isInstallDepNeeded(dep, ctx.OtherModuleDependencyTag(dep)) { if isInstallDepNeeded(dep, ctx.OtherModuleDependencyTag(dep)) {
// Installation is still handled by Make, so anything hidden from Make is not // Installation is still handled by Make, so anything hidden from Make is not
// installable. // installable.
info := OtherModuleProviderOrDefault(ctx, dep, InstallFilesProvider)
if !dep.IsHideFromMake() && !dep.IsSkipInstall() { if !dep.IsHideFromMake() && !dep.IsSkipInstall() {
installDeps = append(installDeps, info.TransitiveInstallFiles) installDeps = append(installDeps, dep.base().installFilesDepSet)
} }
// Add packaging deps even when the dependency is not installed so that uninstallable // Add packaging deps even when the dependency is not installed so that uninstallable
// modules can still be packaged. Often the package will be installed instead. // modules can still be packaged. Often the package will be installed instead.
packagingSpecs = append(packagingSpecs, info.TransitivePackagingSpecs) packagingSpecs = append(packagingSpecs, dep.base().packagingSpecsDepSet)
} }
}) })
@@ -1468,6 +1477,10 @@ func isInstallDepNeeded(dep Module, tag blueprint.DependencyTag) bool {
return IsInstallDepNeededTag(tag) return IsInstallDepNeededTag(tag)
} }
func (m *ModuleBase) TransitivePackagingSpecs() []PackagingSpec {
return m.packagingSpecsDepSet.ToList()
}
func (m *ModuleBase) NoAddressSanitizer() bool { func (m *ModuleBase) NoAddressSanitizer() bool {
return m.noAddressSanitizer return m.noAddressSanitizer
} }
@@ -1593,6 +1606,12 @@ func (m *ModuleBase) CompileMultilib() *string {
return m.base().commonProperties.Compile_multilib return m.base().commonProperties.Compile_multilib
} }
// SetLicenseInstallMap stores the set of dependency module:location mappings for files in an
// apex container for use when generation the license metadata file.
func (m *ModuleBase) SetLicenseInstallMap(installMap []string) {
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
@@ -1762,12 +1781,9 @@ type InstallFilesInfo struct {
KatiInstalls katiInstalls KatiInstalls katiInstalls
KatiSymlinks katiInstalls KatiSymlinks katiInstalls
TestData []DataPath TestData []DataPath
TransitiveInstallFiles *DepSet[InstallPath]
// This was private before, make it private again once we have better solution.
TransitivePackagingSpecs *DepSet[PackagingSpec]
} }
var InstallFilesProvider = blueprint.NewProvider[InstallFilesInfo]() var FinalModuleBuildTargetsProvider = blueprint.NewProvider[FinalModuleBuildTargetsInfo]()
type FinalModuleBuildTargetsInfo struct { type FinalModuleBuildTargetsInfo struct {
// Used by buildTargetSingleton to create checkbuild and per-directory build targets // Used by buildTargetSingleton to create checkbuild and per-directory build targets
@@ -1777,7 +1793,7 @@ type FinalModuleBuildTargetsInfo struct {
BlueprintDir string BlueprintDir string
} }
var FinalModuleBuildTargetsProvider = blueprint.NewProvider[FinalModuleBuildTargetsInfo]() var InstallFilesProvider = blueprint.NewProvider[InstallFilesInfo]()
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) { func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
ctx := &moduleContext{ ctx := &moduleContext{
@@ -1793,10 +1809,10 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
m.licenseMetadataFile = PathForModuleOut(ctx, "meta_lic") m.licenseMetadataFile = PathForModuleOut(ctx, "meta_lic")
dependencyInstallFiles, dependencyPackagingSpecs := m.computeInstallDeps(ctx) dependencyInstallFiles, dependencyPackagingSpecs := m.computeInstallDeps(ctx)
// set the TransitiveInstallFiles to only the transitive dependencies to be used as the dependencies // set m.installFilesDepSet to only the transitive dependencies to be used as the dependencies
// of installed files of this module. It will be replaced by a depset including the installed // of installed files of this module. It will be replaced by a depset including the installed
// files of this module at the end for use by modules that depend on this one. // files of this module at the end for use by modules that depend on this one.
ctx.TransitiveInstallFiles = NewDepSet[InstallPath](TOPOLOGICAL, nil, dependencyInstallFiles) m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, nil, dependencyInstallFiles)
// Temporarily continue to call blueprintCtx.GetMissingDependencies() to maintain the previous behavior of never // Temporarily continue to call blueprintCtx.GetMissingDependencies() to maintain the previous behavior of never
// reporting missing dependency errors in Blueprint when AllowMissingDependencies == true. // reporting missing dependency errors in Blueprint when AllowMissingDependencies == true.
@@ -1840,8 +1856,6 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
checkDistProperties(ctx, fmt.Sprintf("dists[%d]", i), &m.distProperties.Dists[i]) checkDistProperties(ctx, fmt.Sprintf("dists[%d]", i), &m.distProperties.Dists[i])
} }
var installFiles InstallFilesInfo
if m.Enabled(ctx) { if m.Enabled(ctx) {
// ensure all direct android.Module deps are enabled // ensure all direct android.Module deps are enabled
ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) { ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) {
@@ -1963,12 +1977,14 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
return return
} }
installFiles.InstallFiles = ctx.installFiles SetProvider(ctx, InstallFilesProvider, InstallFilesInfo{
installFiles.CheckbuildFiles = ctx.checkbuildFiles InstallFiles: ctx.installFiles,
installFiles.PackagingSpecs = ctx.packagingSpecs CheckbuildFiles: ctx.checkbuildFiles,
installFiles.KatiInstalls = ctx.katiInstalls PackagingSpecs: ctx.packagingSpecs,
installFiles.KatiSymlinks = ctx.katiSymlinks KatiInstalls: ctx.katiInstalls,
installFiles.TestData = ctx.testData KatiSymlinks: ctx.katiSymlinks,
TestData: ctx.testData,
})
} 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
@@ -1984,11 +2000,9 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
} }
} }
ctx.TransitiveInstallFiles = NewDepSet[InstallPath](TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles) m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles)
installFiles.TransitiveInstallFiles = ctx.TransitiveInstallFiles m.packagingSpecsDepSet = NewDepSet[PackagingSpec](TOPOLOGICAL, ctx.packagingSpecs, dependencyPackagingSpecs)
installFiles.TransitivePackagingSpecs = NewDepSet[PackagingSpec](TOPOLOGICAL, ctx.packagingSpecs, dependencyPackagingSpecs)
SetProvider(ctx, InstallFilesProvider, installFiles)
buildLicenseMetadata(ctx, m.licenseMetadataFile) buildLicenseMetadata(ctx, m.licenseMetadataFile)
if m.moduleInfoJSON != nil { if m.moduleInfoJSON != nil {

View File

@@ -107,65 +107,65 @@ type ModuleContext interface {
// InstallExecutable creates a rule to copy srcPath to name in the installPath directory, // InstallExecutable creates a rule to copy srcPath to name in the installPath directory,
// with the given additional dependencies. The file is marked executable after copying. // with the given additional dependencies. The file is marked executable after copying.
// //
// The installed file can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec // The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module // installed file will be returned by PackagingSpecs() on this module or by
// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through // TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// dependency tags for which IsInstallDepNeeded returns true. // for which IsInstallDepNeeded returns true.
InstallExecutable(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath InstallExecutable(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
// InstallFile creates a rule to copy srcPath to name in the installPath directory, // InstallFile creates a rule to copy srcPath to name in the installPath directory,
// with the given additional dependencies. // with the given additional dependencies.
// //
// The installed file can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec // The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module // installed file will be returned by PackagingSpecs() on this module or by
// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through // TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// dependency tags for which IsInstallDepNeeded returns true. // for which IsInstallDepNeeded returns true.
InstallFile(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath InstallFile(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
// InstallFileWithExtraFilesZip creates a rule to copy srcPath to name in the installPath // InstallFileWithExtraFilesZip creates a rule to copy srcPath to name in the installPath
// directory, and also unzip a zip file containing extra files to install into the same // directory, and also unzip a zip file containing extra files to install into the same
// directory. // directory.
// //
// The installed file can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec // The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module // installed file will be returned by PackagingSpecs() on this module or by
// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through // TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// dependency tags for which IsInstallDepNeeded returns true. // for which IsInstallDepNeeded returns true.
InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path, extraZip Path, deps ...InstallPath) InstallPath InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path, extraZip Path, deps ...InstallPath) InstallPath
// InstallSymlink creates a rule to create a symlink from src srcPath to name in the installPath // InstallSymlink creates a rule to create a symlink from src srcPath to name in the installPath
// directory. // directory.
// //
// The installed symlink can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec // The installed symlink will be returned by FilesToInstall(), and the PackagingSpec for the
// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module // installed file will be returned by PackagingSpecs() on this module or by
// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through // TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// dependency tags for which IsInstallDepNeeded returns true. // for which IsInstallDepNeeded returns true.
InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath
// InstallAbsoluteSymlink creates a rule to create an absolute symlink from src srcPath to name // InstallAbsoluteSymlink creates a rule to create an absolute symlink from src srcPath to name
// in the installPath directory. // in the installPath directory.
// //
// The installed symlink can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec // The installed symlink will be returned by FilesToInstall(), and the PackagingSpec for the
// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module // installed file will be returned by PackagingSpecs() on this module or by
// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through // TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// dependency tags for which IsInstallDepNeeded returns true. // for which IsInstallDepNeeded returns true.
InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath
// InstallTestData creates rules to install test data (e.g. data files used during a test) into // InstallTestData creates rules to install test data (e.g. data files used during a test) into
// the installPath directory. // the installPath directory.
// //
// The installed files can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec // The installed files will be returned by FilesToInstall(), and the PackagingSpec for the
// for the installed files can be accessed by InstallFilesInfo.PackagingSpecs on this module // installed files will be returned by PackagingSpecs() on this module or by
// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through // TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// dependency tags for which IsInstallDepNeeded returns true. // for which IsInstallDepNeeded returns true.
InstallTestData(installPath InstallPath, data []DataPath) InstallPaths InstallTestData(installPath InstallPath, data []DataPath) InstallPaths
// PackageFile creates a PackagingSpec as if InstallFile was called, but without creating // PackageFile creates a PackagingSpec as if InstallFile was called, but without creating
// the rule to copy the file. This is useful to define how a module would be packaged // the rule to copy the file. This is useful to define how a module would be packaged
// without installing it into the global installation directories. // without installing it into the global installation directories.
// //
// The created PackagingSpec can be accessed by InstallFilesInfo.PackagingSpecs on this module // The created PackagingSpec for the will be returned by PackagingSpecs() on this module or by
// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through // TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// dependency tags for which IsInstallDepNeeded returns true. // for which IsInstallDepNeeded returns true.
PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec
CheckbuildFile(srcPath Path) CheckbuildFile(srcPath Path)
@@ -218,10 +218,6 @@ type ModuleContext interface {
GetOutputFiles() OutputFilesInfo GetOutputFiles() OutputFilesInfo
// SetLicenseInstallMap stores the set of dependency module:location mappings for files in an
// apex container for use when generation the license metadata file.
SetLicenseInstallMap(installMap []string)
// ComplianceMetadataInfo returns a ComplianceMetadataInfo instance for different module types to dump metadata, // ComplianceMetadataInfo returns a ComplianceMetadataInfo instance for different module types to dump metadata,
// which usually happens in GenerateAndroidBuildActions() of a module type. // which usually happens in GenerateAndroidBuildActions() of a module type.
// See android.ModuleBase.complianceMetadataInfo // See android.ModuleBase.complianceMetadataInfo
@@ -240,12 +236,6 @@ type moduleContext struct {
// the OutputFilesProvider in GenerateBuildActions // the OutputFilesProvider in GenerateBuildActions
outputFiles OutputFilesInfo outputFiles OutputFilesInfo
TransitiveInstallFiles *DepSet[InstallPath]
// set of dependency module:location mappings used to populate the license metadata for
// apex containers.
licenseInstallMap []string
katiInstalls katiInstalls katiInstalls katiInstalls
katiSymlinks katiInstalls katiSymlinks katiInstalls
@@ -531,7 +521,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
} }
if m.requiresFullInstall() { if m.requiresFullInstall() {
deps = append(deps, InstallPaths(m.TransitiveInstallFiles.ToList())...) deps = append(deps, InstallPaths(m.module.base().installFilesDepSet.ToList())...)
deps = append(deps, m.module.base().installedInitRcPaths...) deps = append(deps, m.module.base().installedInitRcPaths...)
deps = append(deps, m.module.base().installedVintfFragmentsPaths...) deps = append(deps, m.module.base().installedVintfFragmentsPaths...)
@@ -748,10 +738,6 @@ func (m *moduleContext) GetOutputFiles() OutputFilesInfo {
return m.outputFiles return m.outputFiles
} }
func (m *moduleContext) SetLicenseInstallMap(installMap []string) {
m.licenseInstallMap = append(m.licenseInstallMap, installMap...)
}
func (m *moduleContext) ComplianceMetadataInfo() *ComplianceMetadataInfo { func (m *moduleContext) ComplianceMetadataInfo() *ComplianceMetadataInfo {
if complianceMetadataInfo := m.module.base().complianceMetadataInfo; complianceMetadataInfo != nil { if complianceMetadataInfo := m.module.base().complianceMetadataInfo; complianceMetadataInfo != nil {
return complianceMetadataInfo return complianceMetadataInfo

View File

@@ -346,8 +346,7 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter
if pi, ok := ctx.OtherModuleDependencyTag(child).(PackagingItem); !ok || !pi.IsPackagingItem() { if pi, ok := ctx.OtherModuleDependencyTag(child).(PackagingItem); !ok || !pi.IsPackagingItem() {
return return
} }
for _, ps := range OtherModuleProviderOrDefault( for _, ps := range child.TransitivePackagingSpecs() {
ctx, child, InstallFilesProvider).TransitivePackagingSpecs.ToList() {
if !filterArch(ps) { if !filterArch(ps) {
continue continue
} }

View File

@@ -595,7 +595,7 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
if len(installMapSet) > 0 { if len(installMapSet) > 0 {
var installs []string var installs []string
installs = append(installs, android.SortedKeys(installMapSet)...) installs = append(installs, android.SortedKeys(installMapSet)...)
ctx.SetLicenseInstallMap(installs) a.SetLicenseInstallMap(installs)
} }
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -320,8 +320,7 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
ctx.ModuleErrorf("host tool %q missing output file", tool) ctx.ModuleErrorf("host tool %q missing output file", tool)
return return
} }
if specs := android.OtherModuleProviderOrDefault( if specs := t.TransitivePackagingSpecs(); specs != nil {
ctx, t, android.InstallFilesProvider).TransitivePackagingSpecs.ToList(); specs != nil {
// If the HostToolProvider has PackgingSpecs, which are definitions of the // If the HostToolProvider has PackgingSpecs, which are definitions of the
// required relative locations of the tool and its dependencies, use those // required relative locations of the tool and its dependencies, use those
// instead. They will be copied to those relative locations in the sbox // instead. They will be copied to those relative locations in the sbox