Merge remote-tracking branch 'aosp/upstream' into master am: 1a01946bf1

am: 076915c7da

Change-Id: I71b8d955ef0206ac0768fff12161e55729abbc98
This commit is contained in:
Colin Cross 2019-08-09 20:38:48 -07:00 committed by android-build-merger
commit cd44450457
2 changed files with 30 additions and 12 deletions

View file

@ -1153,7 +1153,7 @@ func (c *Context) cloneLogicModule(origModule *moduleInfo) (Module, []interface{
}
func (c *Context) createVariations(origModule *moduleInfo, mutatorName string,
variationNames []string) ([]*moduleInfo, []error) {
defaultVariationName *string, variationNames []string) ([]*moduleInfo, []error) {
if len(variationNames) == 0 {
panic(fmt.Errorf("mutator %q passed zero-length variation list for module %q",
@ -1198,7 +1198,7 @@ func (c *Context) createVariations(origModule *moduleInfo, mutatorName string,
newModules = append(newModules, newModule)
newErrs := c.convertDepsToVariation(newModule, mutatorName, variationName)
newErrs := c.convertDepsToVariation(newModule, mutatorName, variationName, defaultVariationName)
if len(newErrs) > 0 {
errs = append(errs, newErrs...)
}
@ -1215,7 +1215,7 @@ func (c *Context) createVariations(origModule *moduleInfo, mutatorName string,
}
func (c *Context) convertDepsToVariation(module *moduleInfo,
mutatorName, variationName string) (errs []error) {
mutatorName, variationName string, defaultVariationName *string) (errs []error) {
for i, dep := range module.directDeps {
if dep.module.logicModule == nil {
@ -1226,6 +1226,15 @@ func (c *Context) convertDepsToVariation(module *moduleInfo,
break
}
}
if newDep == nil && defaultVariationName != nil {
// give it a second chance; match with defaultVariationName
for _, m := range dep.module.splitModules {
if m.variant[mutatorName] == *defaultVariationName {
newDep = m
break
}
}
}
if newDep == nil {
errs = append(errs, &BlueprintError{
Err: fmt.Errorf("failed to find variation %q for module %q needed by %q",

View file

@ -661,12 +661,13 @@ func (m *moduleContext) GetMissingDependencies() []string {
type mutatorContext struct {
baseModuleContext
name string
reverseDeps []reverseDep
rename []rename
replace []replace
newVariations []*moduleInfo // new variants of existing modules
newModules []*moduleInfo // brand new modules
name string
reverseDeps []reverseDep
rename []rename
replace []replace
newVariations []*moduleInfo // new variants of existing modules
newModules []*moduleInfo // brand new modules
defaultVariation *string
}
type BaseMutatorContext interface {
@ -752,9 +753,13 @@ type BottomUpMutatorContext interface {
CreateLocalVariations(...string) []Module
// SetDependencyVariation sets all dangling dependencies on the current module to point to the variation
// with given name.
// with given name. This function ignores the default variation set by SetDefaultDependencyVariation.
SetDependencyVariation(string)
// SetDefaultDependencyVariation sets the default variation when a dangling reference is detected
// during the subsequent calls on Create*Variations* functions. To reset, set it to nil.
SetDefaultDependencyVariation(*string)
// AddVariationDependencies adds deps as dependencies of the current module, but uses the variations
// argument to select which variant of the dependency to use. A variant of the dependency must
// exist that matches the all of the non-local variations of the current module, plus the variations
@ -825,7 +830,7 @@ func (mctx *mutatorContext) CreateLocalVariations(variationNames ...string) []Mo
func (mctx *mutatorContext) createVariations(variationNames []string, local bool) []Module {
ret := []Module{}
modules, errs := mctx.context.createVariations(mctx.module, mctx.name, variationNames)
modules, errs := mctx.context.createVariations(mctx.module, mctx.name, mctx.defaultVariation, variationNames)
if len(errs) > 0 {
mctx.errs = append(mctx.errs, errs...)
}
@ -850,7 +855,11 @@ func (mctx *mutatorContext) createVariations(variationNames []string, local bool
}
func (mctx *mutatorContext) SetDependencyVariation(variationName string) {
mctx.context.convertDepsToVariation(mctx.module, mctx.name, variationName)
mctx.context.convertDepsToVariation(mctx.module, mctx.name, variationName, nil)
}
func (mctx *mutatorContext) SetDefaultDependencyVariation(variationName *string) {
mctx.defaultVariation = variationName
}
func (mctx *mutatorContext) Module() Module {