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
|
||||
|
|
21
context.go
21
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
|
||||
|
@ -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})
|
||||
|
|
Loading…
Reference in a new issue