Merge remote-tracking branch 'aosp/upstream' am: f41959b79a
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/1512683 Change-Id: Ie8e7065b40c366b52100e346571547b2047f7181
This commit is contained in:
commit
14e63c229f
4 changed files with 26 additions and 16 deletions
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
|
@ -17,13 +17,13 @@ jobs:
|
|||
steps:
|
||||
|
||||
- name: Set up Go ${{ matrix.go }}
|
||||
uses: actions/setup-go@v2.0.3
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
id: go
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2.2.0
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install ninja
|
||||
run: |
|
||||
|
@ -31,7 +31,7 @@ jobs:
|
|||
wget https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip
|
||||
unzip ninja-linux.zip
|
||||
rm ninja-linux.zip
|
||||
echo "::add-path::${GITHUB_WORKSPACE}/ninja-bin"
|
||||
echo "${GITHUB_WORKSPACE}/ninja-bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Run gofmt
|
||||
run: ./.gofmt.sh
|
||||
|
|
25
context.go
25
context.go
|
@ -110,6 +110,8 @@ type Context struct {
|
|||
|
||||
// set lazily by sortedModuleGroups
|
||||
cachedSortedModuleGroups []*moduleGroup
|
||||
// cache deps modified to determine whether cachedSortedModuleGroups needs to be recalculated
|
||||
cachedDepsModified bool
|
||||
|
||||
globs map[string]GlobPath
|
||||
globLock sync.Mutex
|
||||
|
@ -1420,7 +1422,7 @@ func (c *Context) prettyPrintVariant(variations variationMap) string {
|
|||
}
|
||||
}
|
||||
|
||||
return strings.Join(names, ", ")
|
||||
return strings.Join(names, ",")
|
||||
}
|
||||
|
||||
func (c *Context) prettyPrintGroupVariants(group *moduleGroup) string {
|
||||
|
@ -1430,7 +1432,7 @@ func (c *Context) prettyPrintGroupVariants(group *moduleGroup) string {
|
|||
variants = append(variants, c.prettyPrintVariant(mod.variant.variations))
|
||||
} else if alias := moduleOrAlias.alias(); alias != nil {
|
||||
variants = append(variants, c.prettyPrintVariant(alias.variant.variations)+
|
||||
"(alias to "+c.prettyPrintVariant(alias.target.variant.variations)+")")
|
||||
" (alias to "+c.prettyPrintVariant(alias.target.variant.variations)+")")
|
||||
}
|
||||
}
|
||||
return strings.Join(variants, "\n ")
|
||||
|
@ -1632,7 +1634,7 @@ func (c *Context) addDependency(module *moduleInfo, tag DependencyTag, depName s
|
|||
|
||||
possibleDeps := c.moduleGroupFromName(depName, module.namespace())
|
||||
if possibleDeps == nil {
|
||||
return nil, c.discoveredMissingDependencies(module, depName)
|
||||
return nil, c.discoveredMissingDependencies(module, depName, nil)
|
||||
}
|
||||
|
||||
if m := findExactVariantOrSingle(module, possibleDeps, false); m != nil {
|
||||
|
@ -1643,7 +1645,7 @@ func (c *Context) addDependency(module *moduleInfo, tag DependencyTag, depName s
|
|||
|
||||
if c.allowMissingDependencies {
|
||||
// Allow missing variants.
|
||||
return nil, c.discoveredMissingDependencies(module, depName+c.prettyPrintVariant(module.variant.dependencyVariations))
|
||||
return nil, c.discoveredMissingDependencies(module, depName, module.variant.dependencyVariations)
|
||||
}
|
||||
|
||||
return nil, []error{&BlueprintError{
|
||||
|
@ -1678,7 +1680,7 @@ func (c *Context) findReverseDependency(module *moduleInfo, destName string) (*m
|
|||
|
||||
if c.allowMissingDependencies {
|
||||
// Allow missing variants.
|
||||
return module, c.discoveredMissingDependencies(module, destName+c.prettyPrintVariant(module.variant.dependencyVariations))
|
||||
return module, c.discoveredMissingDependencies(module, destName, module.variant.dependencyVariations)
|
||||
}
|
||||
|
||||
return nil, []error{&BlueprintError{
|
||||
|
@ -1739,7 +1741,7 @@ func (c *Context) addVariationDependency(module *moduleInfo, variations []Variat
|
|||
|
||||
possibleDeps := c.moduleGroupFromName(depName, module.namespace())
|
||||
if possibleDeps == nil {
|
||||
return nil, c.discoveredMissingDependencies(module, depName)
|
||||
return nil, c.discoveredMissingDependencies(module, depName, nil)
|
||||
}
|
||||
|
||||
foundDep, newVariant := findVariant(module, possibleDeps, variations, far, false)
|
||||
|
@ -1747,7 +1749,7 @@ func (c *Context) addVariationDependency(module *moduleInfo, variations []Variat
|
|||
if foundDep == nil {
|
||||
if c.allowMissingDependencies {
|
||||
// Allow missing variants.
|
||||
return nil, c.discoveredMissingDependencies(module, depName+c.prettyPrintVariant(newVariant))
|
||||
return nil, c.discoveredMissingDependencies(module, depName, newVariant)
|
||||
}
|
||||
return nil, []error{&BlueprintError{
|
||||
Err: fmt.Errorf("dependency %q of %q missing variant:\n %s\navailable variants:\n %s",
|
||||
|
@ -2165,6 +2167,7 @@ func cycleError(cycle []*moduleInfo) (errs []error) {
|
|||
// it encounters dependency cycles. This should called after resolveDependencies,
|
||||
// as well as after any mutator pass has called addDependency
|
||||
func (c *Context) updateDependencies() (errs []error) {
|
||||
c.cachedDepsModified = true
|
||||
visited := make(map[*moduleInfo]bool) // modules that were already checked
|
||||
checking := make(map[*moduleInfo]bool) // modules actively being checked
|
||||
|
||||
|
@ -2986,7 +2989,10 @@ func (c *Context) handleReplacements(replacements []replace) []error {
|
|||
return errs
|
||||
}
|
||||
|
||||
func (c *Context) discoveredMissingDependencies(module *moduleInfo, depName string) (errs []error) {
|
||||
func (c *Context) discoveredMissingDependencies(module *moduleInfo, depName string, depVariations variationMap) (errs []error) {
|
||||
if depVariations != nil {
|
||||
depName = depName + "{" + c.prettyPrintVariant(depVariations) + "}"
|
||||
}
|
||||
if c.allowMissingDependencies {
|
||||
module.missingDeps = append(module.missingDeps, depName)
|
||||
return nil
|
||||
|
@ -3012,7 +3018,7 @@ func (c *Context) moduleGroupFromName(name string, namespace Namespace) *moduleG
|
|||
}
|
||||
|
||||
func (c *Context) sortedModuleGroups() []*moduleGroup {
|
||||
if c.cachedSortedModuleGroups == nil {
|
||||
if c.cachedSortedModuleGroups == nil || c.cachedDepsModified {
|
||||
unwrap := func(wrappers []ModuleGroup) []*moduleGroup {
|
||||
result := make([]*moduleGroup, 0, len(wrappers))
|
||||
for _, group := range wrappers {
|
||||
|
@ -3022,6 +3028,7 @@ func (c *Context) sortedModuleGroups() []*moduleGroup {
|
|||
}
|
||||
|
||||
c.cachedSortedModuleGroups = unwrap(c.nameInterface.AllModules())
|
||||
c.cachedDepsModified = false
|
||||
}
|
||||
|
||||
return c.cachedSortedModuleGroups
|
||||
|
|
|
@ -1166,8 +1166,11 @@ func (mctx *mutatorContext) ReplaceDependenciesIf(name string, predicate Replace
|
|||
target := mctx.context.moduleMatchingVariant(mctx.module, name)
|
||||
|
||||
if target == nil {
|
||||
panic(fmt.Errorf("ReplaceDependencies could not find identical variant %q for module %q",
|
||||
mctx.module.variant.name, name))
|
||||
panic(fmt.Errorf("ReplaceDependencies could not find identical variant {%s} for module %s\n"+
|
||||
"available variants:\n %s",
|
||||
mctx.context.prettyPrintVariant(mctx.module.variant.variations),
|
||||
name,
|
||||
mctx.context.prettyPrintGroupVariants(mctx.context.moduleGroupFromName(name, mctx.module.namespace()))))
|
||||
}
|
||||
|
||||
mctx.replace = append(mctx.replace, replace{target, mctx.module, predicate})
|
||||
|
|
|
@ -191,7 +191,7 @@ func TestAliasVariation(t *testing.T) {
|
|||
|
||||
runWithFailures(ctx, `dependency "bar" of "foo" missing variant:`+"\n \n"+
|
||||
"available variants:"+
|
||||
"\n 1:a, 2:a\n 1:a, 2:b\n 1:b, 2:a\n 1:b, 2:b")
|
||||
"\n 1:a,2:a\n 1:a,2:b\n 1:b,2:a\n 1:b,2:b")
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ func TestCreateAliasVariations(t *testing.T) {
|
|||
|
||||
runWithFailures(ctx, `dependency "bar" of "foo" missing variant:`+"\n 1:d\n"+
|
||||
"available variants:"+
|
||||
"\n 1:a, 2:a\n 1:a, 2:b\n 1:b, 2:a\n 1:b, 2:b")
|
||||
"\n 1:a,2:a\n 1:a,2:b\n 1:b,2:a\n 1:b,2:b")
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue