Do not install transitive packaging specs of overriden modules
e.g. if a cc_binary is overriden, its shared_libs should not be
installed.
To do, a new `depNames` array is introduced to track the top-level
module which requested the packaging spec. If the top-level module has
been overridden, the packaging spec will not be installed.
Test: go test ./filesystem
Test: vendor partition diffs for aosp cf https://diff.googleplex.com/#key=276Je74QO1VE
Change-Id: I1c8df831c696990bb0982e4537129b8e85abeda6
diff --git a/android/packaging.go b/android/packaging.go
index b505964..fe76bfc 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -395,6 +395,11 @@
func (p *PackagingBase) GatherPackagingSpecsWithFilter(ctx ModuleContext, filter func(PackagingSpec) bool) map[string]PackagingSpec {
// all packaging specs gathered from the dep.
var all []PackagingSpec
+ // Name of the dependency which requested the packaging spec.
+ // If this dep is overridden, the packaging spec will not be installed via this dependency chain.
+ // (the packaging spec might still be installed if there are some other deps which depend on it).
+ var depNames []string
+
// list of module names overridden
var overridden []string
@@ -429,6 +434,7 @@
}
}
all = append(all, ps)
+ depNames = append(depNames, child.Name())
if ps.overrides != nil {
overridden = append(overridden, *ps.overrides...)
}
@@ -437,10 +443,14 @@
// all minus packaging specs that are overridden
var filtered []PackagingSpec
- for _, ps := range all {
+ for index, ps := range all {
if ps.owner != "" && InList(ps.owner, overridden) {
continue
}
+ // The dependency which requested this packaging spec has been overridden.
+ if InList(depNames[index], overridden) {
+ continue
+ }
filtered = append(filtered, ps)
}