Merge pull request #263 from jiyongp/reverse_dep

Don't ignore local variations when creating reverse dep
This commit is contained in:
colincross 2019-09-22 17:11:21 -07:00 committed by GitHub
commit 884e7374fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1410,12 +1410,21 @@ func blueprintDepsMutator(ctx BottomUpMutatorContext) {
// findMatchingVariant searches the moduleGroup for a module with the same variant as module,
// and returns the matching module, or nil if one is not found.
func (c *Context) findMatchingVariant(module *moduleInfo, possible []*moduleInfo) *moduleInfo {
func (c *Context) findMatchingVariant(module *moduleInfo, possible []*moduleInfo, reverse bool) *moduleInfo {
if len(possible) == 1 {
return possible[0]
} else {
var variantToMatch variationMap
if !reverse {
// For forward dependency, ignore local variants by matching against
// dependencyVariant which doesn't have the local variants
variantToMatch = module.dependencyVariant
} else {
// For reverse dependency, use all the variants
variantToMatch = module.variant
}
for _, m := range possible {
if m.variant.equal(module.dependencyVariant) {
if m.variant.equal(variantToMatch) {
return m
}
}
@ -1441,7 +1450,7 @@ func (c *Context) addDependency(module *moduleInfo, tag DependencyTag, depName s
return c.discoveredMissingDependencies(module, depName)
}
if m := c.findMatchingVariant(module, possibleDeps); m != nil {
if m := c.findMatchingVariant(module, possibleDeps, false); m != nil {
module.newDirectDeps = append(module.newDirectDeps, depInfo{m, tag})
atomic.AddUint32(&c.depsModified, 1)
return nil
@ -1479,7 +1488,7 @@ func (c *Context) findReverseDependency(module *moduleInfo, destName string) (*m
}}
}
if m := c.findMatchingVariant(module, possibleDeps); m != nil {
if m := c.findMatchingVariant(module, possibleDeps, true); m != nil {
return m, nil
}