Add TransitivePackagingSpecs
Add TransitivePackagingSpecs to return the PackagingSpecs for a module and any of its transitive dependencies that have dependency tags for which IsInstallDepNeeded returns true. Bug: 124313442 Test: m checkbuild Change-Id: I1d6750db830d1601d696349674f0b7071372ca11
This commit is contained in:
@@ -441,6 +441,10 @@ type Module interface {
|
|||||||
|
|
||||||
FilesToInstall() InstallPaths
|
FilesToInstall() InstallPaths
|
||||||
PackagingSpecs() []PackagingSpec
|
PackagingSpecs() []PackagingSpec
|
||||||
|
|
||||||
|
// TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive
|
||||||
|
// dependencies with dependency tags for which IsInstallDepNeeded() returns true.
|
||||||
|
TransitivePackagingSpecs() []PackagingSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
// Qualified id for a module
|
// Qualified id for a module
|
||||||
@@ -1008,6 +1012,7 @@ type ModuleBase struct {
|
|||||||
installFilesDepSet *installPathsDepSet
|
installFilesDepSet *installPathsDepSet
|
||||||
checkbuildFiles Paths
|
checkbuildFiles Paths
|
||||||
packagingSpecs []PackagingSpec
|
packagingSpecs []PackagingSpec
|
||||||
|
packagingSpecsDepSet *packagingSpecsDepSet
|
||||||
noticeFiles Paths
|
noticeFiles Paths
|
||||||
phonies map[string]Paths
|
phonies map[string]Paths
|
||||||
|
|
||||||
@@ -1339,15 +1344,17 @@ func (m *ModuleBase) ExportedToMake() bool {
|
|||||||
|
|
||||||
// computeInstallDeps finds the installed paths of all dependencies that have a dependency
|
// computeInstallDeps finds the installed paths of all dependencies that have a dependency
|
||||||
// tag that is annotated as needing installation via the IsInstallDepNeeded method.
|
// tag that is annotated as needing installation via the IsInstallDepNeeded method.
|
||||||
func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) []*installPathsDepSet {
|
func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]*installPathsDepSet, []*packagingSpecsDepSet) {
|
||||||
var installDeps []*installPathsDepSet
|
var installDeps []*installPathsDepSet
|
||||||
|
var packagingSpecs []*packagingSpecsDepSet
|
||||||
ctx.VisitDirectDeps(func(dep Module) {
|
ctx.VisitDirectDeps(func(dep Module) {
|
||||||
if IsInstallDepNeeded(ctx.OtherModuleDependencyTag(dep)) {
|
if IsInstallDepNeeded(ctx.OtherModuleDependencyTag(dep)) {
|
||||||
installDeps = append(installDeps, dep.base().installFilesDepSet)
|
installDeps = append(installDeps, dep.base().installFilesDepSet)
|
||||||
|
packagingSpecs = append(packagingSpecs, dep.base().packagingSpecsDepSet)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return installDeps
|
return installDeps, packagingSpecs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) FilesToInstall() InstallPaths {
|
func (m *ModuleBase) FilesToInstall() InstallPaths {
|
||||||
@@ -1358,6 +1365,10 @@ func (m *ModuleBase) PackagingSpecs() []PackagingSpec {
|
|||||||
return m.packagingSpecs
|
return m.packagingSpecs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
@@ -1587,7 +1598,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||||||
variables: make(map[string]string),
|
variables: make(map[string]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyInstallFiles := m.computeInstallDeps(ctx)
|
dependencyInstallFiles, dependencyPackagingSpecs := m.computeInstallDeps(ctx)
|
||||||
// set m.installFilesDepSet 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.
|
||||||
@@ -1702,6 +1713,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.installFilesDepSet = newInstallPathsDepSet(m.installFiles, dependencyInstallFiles)
|
m.installFilesDepSet = newInstallPathsDepSet(m.installFiles, dependencyInstallFiles)
|
||||||
|
m.packagingSpecsDepSet = newPackagingSpecsDepSet(m.packagingSpecs, dependencyPackagingSpecs)
|
||||||
|
|
||||||
m.buildParams = ctx.buildParams
|
m.buildParams = ctx.buildParams
|
||||||
m.ruleParams = ctx.ruleParams
|
m.ruleParams = ctx.ruleParams
|
||||||
|
@@ -203,3 +203,23 @@ func (p *PackagingBase) CopyDepsToZip(ctx ModuleContext, zipOut OutputPath) (ent
|
|||||||
builder.Build("zip_deps", fmt.Sprintf("Zipping deps for %s", ctx.ModuleName()))
|
builder.Build("zip_deps", fmt.Sprintf("Zipping deps for %s", ctx.ModuleName()))
|
||||||
return entries
|
return entries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// packagingSpecsDepSet is a thin type-safe wrapper around the generic depSet. It always uses
|
||||||
|
// topological order.
|
||||||
|
type packagingSpecsDepSet struct {
|
||||||
|
depSet
|
||||||
|
}
|
||||||
|
|
||||||
|
// newPackagingSpecsDepSet returns an immutable packagingSpecsDepSet with the given direct and
|
||||||
|
// transitive contents.
|
||||||
|
func newPackagingSpecsDepSet(direct []PackagingSpec, transitive []*packagingSpecsDepSet) *packagingSpecsDepSet {
|
||||||
|
return &packagingSpecsDepSet{*newDepSet(TOPOLOGICAL, direct, transitive)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToList returns the packagingSpecsDepSet flattened to a list in topological order.
|
||||||
|
func (d *packagingSpecsDepSet) ToList() []PackagingSpec {
|
||||||
|
if d == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return d.depSet.ToList().([]PackagingSpec)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user