Merge "Ensure APEX's Java deps use stable SDKs."

This commit is contained in:
satayev
2020-05-04 16:03:44 +00:00
committed by Gerrit Code Review
4 changed files with 150 additions and 2 deletions

View File

@@ -1885,6 +1885,8 @@ func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
if String(a.properties.Min_sdk_version) == "" {
ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
}
a.checkJavaStableSdkVersion(ctx)
}
}
@@ -1954,7 +1956,6 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.checkApexAvailability(ctx)
a.checkUpdatable(ctx)
a.collectDepsInfo(ctx)
handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
@@ -2274,6 +2275,23 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.buildApexDependencyInfo(ctx)
}
// Enforce that Java deps of the apex are using stable SDKs to compile
func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) {
// Visit direct deps only. As long as we guarantee top-level deps are using
// stable SDKs, java's checkLinkType guarantees correct usage for transitive deps
ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
tag := ctx.OtherModuleDependencyTag(module)
switch tag {
case javaLibTag, androidAppTag:
if m, ok := module.(interface{ CheckStableSdkVersion() error }); ok {
if err := m.CheckStableSdkVersion(); err != nil {
ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err)
}
}
}
})
}
func whitelistedApexAvailable(apex, moduleName string) bool {
key := apex
moduleName = normalizeModuleName(moduleName)