Linktype check error message becomes more correct
The type linkType has String() method and the error message is created using it. Bug: 180477804 Test: m nothing Change-Id: I74fe9c93b74904177dbe9d29cd3aa3304b67ba4f
This commit is contained in:
51
java/java.go
51
java/java.go
@@ -1022,6 +1022,25 @@ const (
|
||||
javaPlatform
|
||||
)
|
||||
|
||||
func (lt linkType) String() string {
|
||||
switch lt {
|
||||
case javaCore:
|
||||
return "core Java API"
|
||||
case javaSdk:
|
||||
return "Android API"
|
||||
case javaSystem:
|
||||
return "system API"
|
||||
case javaModule:
|
||||
return "module API"
|
||||
case javaSystemServer:
|
||||
return "system server API"
|
||||
case javaPlatform:
|
||||
return "private API"
|
||||
default:
|
||||
panic(fmt.Errorf("unrecognized linktype: %v", lt))
|
||||
}
|
||||
}
|
||||
|
||||
type linkTypeContext interface {
|
||||
android.Module
|
||||
getLinkType(name string) (ret linkType, stubs bool)
|
||||
@@ -1081,45 +1100,41 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to linkTypeContext,
|
||||
return
|
||||
}
|
||||
otherLinkType, _ := to.getLinkType(ctx.OtherModuleName(to))
|
||||
commonMessage := " In order to fix this, consider adjusting sdk_version: OR platform_apis: " +
|
||||
"property of the source or target module so that target module is built with the same " +
|
||||
"or smaller API set when compared to the source."
|
||||
|
||||
violation := false
|
||||
switch myLinkType {
|
||||
case javaCore:
|
||||
if otherLinkType != javaCore {
|
||||
ctx.ModuleErrorf("compiles against core Java API, but dependency %q is compiling against non-core Java APIs."+commonMessage,
|
||||
ctx.OtherModuleName(to))
|
||||
violation = true
|
||||
}
|
||||
break
|
||||
case javaSdk:
|
||||
if otherLinkType != javaCore && otherLinkType != javaSdk {
|
||||
ctx.ModuleErrorf("compiles against Android API, but dependency %q is compiling against non-public Android API."+commonMessage,
|
||||
ctx.OtherModuleName(to))
|
||||
violation = true
|
||||
}
|
||||
break
|
||||
case javaSystem:
|
||||
if otherLinkType == javaPlatform || otherLinkType == javaModule || otherLinkType == javaSystemServer {
|
||||
ctx.ModuleErrorf("compiles against system API, but dependency %q is compiling against private API."+commonMessage,
|
||||
ctx.OtherModuleName(to))
|
||||
violation = true
|
||||
}
|
||||
break
|
||||
case javaModule:
|
||||
if otherLinkType == javaPlatform || otherLinkType == javaSystemServer {
|
||||
ctx.ModuleErrorf("compiles against module API, but dependency %q is compiling against private API."+commonMessage,
|
||||
ctx.OtherModuleName(to))
|
||||
violation = true
|
||||
}
|
||||
break
|
||||
case javaSystemServer:
|
||||
if otherLinkType == javaPlatform {
|
||||
ctx.ModuleErrorf("compiles against system server API, but dependency %q is compiling against private API."+commonMessage,
|
||||
ctx.OtherModuleName(to))
|
||||
violation = true
|
||||
}
|
||||
break
|
||||
case javaPlatform:
|
||||
// no restriction on link-type
|
||||
break
|
||||
}
|
||||
|
||||
if violation {
|
||||
ctx.ModuleErrorf("compiles against %v, but dependency %q is compiling against %v. "+
|
||||
"In order to fix this, consider adjusting sdk_version: OR platform_apis: "+
|
||||
"property of the source or target module so that target module is built "+
|
||||
"with the same or smaller API set when compared to the source.",
|
||||
myLinkType, ctx.OtherModuleName(to), otherLinkType)
|
||||
}
|
||||
}
|
||||
|
||||
func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||
|
Reference in New Issue
Block a user