Merge remote-tracking branch 'aosp/upstream' into master
am: d8000d21a9
Change-Id: I910f58b12fb5e8b3b08dcc207541c9ab10233bdb
This commit is contained in:
commit
8954814fb5
3 changed files with 40 additions and 18 deletions
|
@ -3,6 +3,8 @@ language: go
|
|||
go:
|
||||
- 1.9
|
||||
- "1.10"
|
||||
- "1.11"
|
||||
- "1.12"
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
|
|
@ -123,6 +123,7 @@ type DynamicDependerModule interface {
|
|||
type BaseModuleContext interface {
|
||||
ModuleName() string
|
||||
ModuleDir() string
|
||||
ModuleType() string
|
||||
Config() interface{}
|
||||
|
||||
ContainsProperty(name string) bool
|
||||
|
@ -154,6 +155,9 @@ type ModuleContext interface {
|
|||
BaseModuleContext
|
||||
|
||||
OtherModuleName(m Module) string
|
||||
OtherModuleDir(m Module) string
|
||||
OtherModuleSubDir(m Module) string
|
||||
OtherModuleType(m Module) string
|
||||
OtherModuleErrorf(m Module, fmt string, args ...interface{})
|
||||
OtherModuleDependencyTag(m Module) DependencyTag
|
||||
|
||||
|
@ -199,6 +203,10 @@ func (d *baseModuleContext) ModuleName() string {
|
|||
return d.module.Name()
|
||||
}
|
||||
|
||||
func (d *baseModuleContext) ModuleType() string {
|
||||
return d.module.typeName
|
||||
}
|
||||
|
||||
func (d *baseModuleContext) ContainsProperty(name string) bool {
|
||||
_, ok := d.module.propertyPos[name]
|
||||
return ok
|
||||
|
@ -291,6 +299,21 @@ func (m *baseModuleContext) OtherModuleName(logicModule Module) string {
|
|||
return module.Name()
|
||||
}
|
||||
|
||||
func (m *baseModuleContext) OtherModuleDir(logicModule Module) string {
|
||||
module := m.context.moduleInfo[logicModule]
|
||||
return filepath.Dir(module.relBlueprintsFile)
|
||||
}
|
||||
|
||||
func (m *baseModuleContext) OtherModuleSubDir(logicModule Module) string {
|
||||
module := m.context.moduleInfo[logicModule]
|
||||
return module.variantName
|
||||
}
|
||||
|
||||
func (m *baseModuleContext) OtherModuleType(logicModule Module) string {
|
||||
module := m.context.moduleInfo[logicModule]
|
||||
return module.typeName
|
||||
}
|
||||
|
||||
func (m *baseModuleContext) OtherModuleErrorf(logicModule Module, format string,
|
||||
args ...interface{}) {
|
||||
|
||||
|
@ -559,6 +582,9 @@ type TopDownMutatorContext interface {
|
|||
baseMutatorContext
|
||||
|
||||
OtherModuleName(m Module) string
|
||||
OtherModuleDir(m Module) string
|
||||
OtherModuleSubDir(m Module) string
|
||||
OtherModuleType(m Module) string
|
||||
OtherModuleErrorf(m Module, fmt string, args ...interface{})
|
||||
OtherModuleDependencyTag(m Module) DependencyTag
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -137,12 +138,17 @@ func checkCalledFromInit() {
|
|||
panic("not called from an init func")
|
||||
}
|
||||
|
||||
if funcName == "init" || strings.HasPrefix(funcName, "init·") {
|
||||
if funcName == "init" || strings.HasPrefix(funcName, "init·") ||
|
||||
funcName == "init.ializers" || strings.HasPrefix(funcName, "init.") {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A regex to find a package path within a function name. It finds the shortest string that is
|
||||
// followed by '.' and doesn't have any '/'s left.
|
||||
var pkgPathRe = regexp.MustCompile(`^(.*?)\.([^/]+)$`)
|
||||
|
||||
// callerName returns the package path and function name of the calling
|
||||
// function. The skip argument has the same meaning as the skip argument of
|
||||
// runtime.Callers.
|
||||
|
@ -153,25 +159,13 @@ func callerName(skip int) (pkgPath, funcName string, ok bool) {
|
|||
return "", "", false
|
||||
}
|
||||
|
||||
f := runtime.FuncForPC(pc[0])
|
||||
fullName := f.Name()
|
||||
|
||||
lastDotIndex := strings.LastIndex(fullName, ".")
|
||||
if lastDotIndex == -1 {
|
||||
panic("unable to distinguish function name from package")
|
||||
f := runtime.FuncForPC(pc[0]).Name()
|
||||
s := pkgPathRe.FindStringSubmatch(f)
|
||||
if len(s) < 3 {
|
||||
panic(fmt.Errorf("failed to extract package path and function name from %q", f))
|
||||
}
|
||||
|
||||
if fullName[lastDotIndex-1] == ')' {
|
||||
// The caller is a method on some type, so it's name looks like
|
||||
// "pkg/path.(type).method". We need to go back one dot farther to get
|
||||
// to the package name.
|
||||
lastDotIndex = strings.LastIndex(fullName[:lastDotIndex], ".")
|
||||
}
|
||||
|
||||
pkgPath = fullName[:lastDotIndex]
|
||||
funcName = fullName[lastDotIndex+1:]
|
||||
ok = true
|
||||
return
|
||||
return s[1], s[2], true
|
||||
}
|
||||
|
||||
// pkgPathToName makes a Ninja-friendly name out of a Go package name by
|
||||
|
|
Loading…
Reference in a new issue