aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2018-06-21 13:03:07 -0700
committerColin Cross <ccross@android.com>2018-06-22 12:44:35 -0700
commit6b75360cbcc4c3e26507092cc910bf001465bef1 (patch)
treec6510572cc8ba33338b9f85f1f9e663ae1c6859c /python
parent5c733856bd8e16bbd739abc388fa8ac43f073c92 (diff)
downloadbuild_soong-6b75360cbcc4c3e26507092cc910bf001465bef1.tar.gz
build_soong-6b75360cbcc4c3e26507092cc910bf001465bef1.tar.bz2
build_soong-6b75360cbcc4c3e26507092cc910bf001465bef1.zip
Use WalkDeps instead of VisitDepsDepthFirst
VisitDepsDepthFirst is almost never correct, as it can't query dependency tags of multiple dependencies between the same two modules. Replace VisitDepsDepthFirst with WalkDeps in sanitize.go and python.go. Also verify the dependency tag before continuing to recurse to ensure that they don't recurse through genrules and into unrelated modules. Test: m checkbuild Change-Id: I2f7560126f56b51a40ec39dfbdcc18b5891489f7
Diffstat (limited to 'python')
-rw-r--r--python/python.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/python/python.go b/python/python.go
index 4b9111f3..feb17da0 100644
--- a/python/python.go
+++ b/python/python.go
@@ -574,32 +574,39 @@ func (p *Module) walkTransitiveDeps(ctx android.ModuleContext) {
destToPyData[path.dest] = path.src.String()
}
+ seen := make(map[android.Module]bool)
+
// visit all its dependencies in depth first.
- ctx.VisitDepsDepthFirst(func(module android.Module) {
- if ctx.OtherModuleDependencyTag(module) != pythonLibTag {
- return
+ ctx.WalkDeps(func(child, parent android.Module) bool {
+ if ctx.OtherModuleDependencyTag(child) != pythonLibTag {
+ return false
}
+ if seen[child] {
+ return false
+ }
+ seen[child] = true
// Python modules only can depend on Python libraries.
- if !isPythonLibModule(module) {
+ if !isPythonLibModule(child) {
panic(fmt.Errorf(
"the dependency %q of module %q is not Python library!",
- ctx.ModuleName(), ctx.OtherModuleName(module)))
+ ctx.ModuleName(), ctx.OtherModuleName(child)))
}
- if dep, ok := module.(PythonDependency); ok {
+ if dep, ok := child.(PythonDependency); ok {
srcs := dep.GetSrcsPathMappings()
for _, path := range srcs {
if !fillInMap(ctx, destToPySrcs,
- path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(module)) {
+ path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(child)) {
continue
}
}
data := dep.GetDataPathMappings()
for _, path := range data {
fillInMap(ctx, destToPyData,
- path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(module))
+ path.dest, path.src.String(), ctx.ModuleName(), ctx.OtherModuleName(child))
}
p.depsSrcsZips = append(p.depsSrcsZips, dep.GetSrcsZip())
}
+ return true
})
}