Check compatibility between STLs correctly

During link-type check, if a module with sdk_version "current" refers
another, compatibility check between STLs has not been performed.

Bug: 77834464
Test: m -j succeeded
Change-Id: Id82a39372670daca779d4fb4af2deb202170a2fd
This commit is contained in:
Inseob Kim 2018-04-11 09:48:45 +09:00 committed by Colin Cross
parent ed1268268d
commit 01a2872c05

View file

@ -1082,31 +1082,32 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to *Module, tag depe
// API level, as it is only valid to link against older or equivalent
// APIs.
if String(from.Properties.Sdk_version) == "current" {
// Current can link against anything.
return
} else if String(to.Properties.Sdk_version) == "current" {
// Current can't be linked against by anything else.
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to), "current")
}
// Current can link against anything.
if String(from.Properties.Sdk_version) != "current" {
// Otherwise we need to check.
if String(to.Properties.Sdk_version) == "current" {
// Current can't be linked against by anything else.
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to), "current")
} else {
fromApi, err := strconv.Atoi(String(from.Properties.Sdk_version))
if err != nil {
ctx.PropertyErrorf("sdk_version",
"Invalid sdk_version value (must be int): %q",
String(from.Properties.Sdk_version))
}
toApi, err := strconv.Atoi(String(to.Properties.Sdk_version))
if err != nil {
ctx.PropertyErrorf("sdk_version",
"Invalid sdk_version value (must be int): %q",
String(to.Properties.Sdk_version))
}
fromApi, err := strconv.Atoi(String(from.Properties.Sdk_version))
if err != nil {
ctx.PropertyErrorf("sdk_version",
"Invalid sdk_version value (must be int): %q",
String(from.Properties.Sdk_version))
}
toApi, err := strconv.Atoi(String(to.Properties.Sdk_version))
if err != nil {
ctx.PropertyErrorf("sdk_version",
"Invalid sdk_version value (must be int): %q",
String(to.Properties.Sdk_version))
}
if toApi > fromApi {
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to), String(to.Properties.Sdk_version))
if toApi > fromApi {
ctx.ModuleErrorf("links %q built against newer API version %q",
ctx.OtherModuleName(to), String(to.Properties.Sdk_version))
}
}
}
// Also check that the two STL choices are compatible.