Merge "Further simplify the link type check routine"
This commit is contained in:
36
java/java.go
36
java/java.go
@@ -1014,6 +1014,7 @@ type linkType int
|
|||||||
const (
|
const (
|
||||||
// TODO(jiyong) rename these for better readability. Make the allowed
|
// TODO(jiyong) rename these for better readability. Make the allowed
|
||||||
// and disallowed link types explicit
|
// and disallowed link types explicit
|
||||||
|
// order is important here. See rank()
|
||||||
javaCore linkType = iota
|
javaCore linkType = iota
|
||||||
javaSdk
|
javaSdk
|
||||||
javaSystem
|
javaSystem
|
||||||
@@ -1041,6 +1042,12 @@ func (lt linkType) String() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rank determins the total order among linkTypes. A link type of rank A can link to another link
|
||||||
|
// type of rank B only when B <= A
|
||||||
|
func (lt linkType) rank() int {
|
||||||
|
return int(lt)
|
||||||
|
}
|
||||||
|
|
||||||
type linkTypeContext interface {
|
type linkTypeContext interface {
|
||||||
android.Module
|
android.Module
|
||||||
getLinkType(name string) (ret linkType, stubs bool)
|
getLinkType(name string) (ret linkType, stubs bool)
|
||||||
@@ -1101,34 +1108,7 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to linkTypeContext,
|
|||||||
}
|
}
|
||||||
otherLinkType, _ := to.getLinkType(ctx.OtherModuleName(to))
|
otherLinkType, _ := to.getLinkType(ctx.OtherModuleName(to))
|
||||||
|
|
||||||
violation := false
|
if myLinkType.rank() < otherLinkType.rank() {
|
||||||
switch myLinkType {
|
|
||||||
case javaCore:
|
|
||||||
if otherLinkType != javaCore {
|
|
||||||
violation = true
|
|
||||||
}
|
|
||||||
case javaSdk:
|
|
||||||
if otherLinkType != javaCore && otherLinkType != javaSdk {
|
|
||||||
violation = true
|
|
||||||
}
|
|
||||||
case javaSystem:
|
|
||||||
if otherLinkType == javaPlatform || otherLinkType == javaModule || otherLinkType == javaSystemServer {
|
|
||||||
violation = true
|
|
||||||
}
|
|
||||||
case javaModule:
|
|
||||||
if otherLinkType == javaPlatform || otherLinkType == javaSystemServer {
|
|
||||||
violation = true
|
|
||||||
}
|
|
||||||
case javaSystemServer:
|
|
||||||
if otherLinkType == javaPlatform {
|
|
||||||
violation = true
|
|
||||||
}
|
|
||||||
case javaPlatform:
|
|
||||||
// no restriction on link-type
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if violation {
|
|
||||||
ctx.ModuleErrorf("compiles against %v, but dependency %q is compiling against %v. "+
|
ctx.ModuleErrorf("compiles against %v, but dependency %q is compiling against %v. "+
|
||||||
"In order to fix this, consider adjusting sdk_version: OR platform_apis: "+
|
"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 "+
|
"property of the source or target module so that target module is built "+
|
||||||
|
Reference in New Issue
Block a user