Merge "Add ModuleWithMinSdkVersionCheck type." am: a4fc08d204
am: 25f5783263
am: fe55ffd190
am: 44d0ef55da
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1907860 Change-Id: I147da371d445f09ca2f131df1be91545eba37772
This commit is contained in:
@@ -908,16 +908,17 @@ var minSdkVersionAllowlist = func(apiMap map[string]int) map[string]ApiLevel {
|
|||||||
//
|
//
|
||||||
// Return true if the `to` module should be visited, false otherwise.
|
// Return true if the `to` module should be visited, false otherwise.
|
||||||
type PayloadDepsCallback func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool
|
type PayloadDepsCallback func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool
|
||||||
|
type WalkPayloadDepsFunc func(ctx ModuleContext, do PayloadDepsCallback)
|
||||||
|
|
||||||
// UpdatableModule represents updatable APEX/APK
|
// ModuleWithMinSdkVersionCheck represents a module that implements min_sdk_version checks
|
||||||
type UpdatableModule interface {
|
type ModuleWithMinSdkVersionCheck interface {
|
||||||
Module
|
Module
|
||||||
WalkPayloadDeps(ctx ModuleContext, do PayloadDepsCallback)
|
CheckMinSdkVersion(ctx ModuleContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckMinSdkVersion checks if every dependency of an updatable module sets min_sdk_version
|
// CheckMinSdkVersion checks if every dependency of an updatable module sets min_sdk_version
|
||||||
// accordingly
|
// accordingly
|
||||||
func CheckMinSdkVersion(m UpdatableModule, ctx ModuleContext, minSdkVersion ApiLevel) {
|
func CheckMinSdkVersion(ctx ModuleContext, minSdkVersion ApiLevel, walk WalkPayloadDepsFunc) {
|
||||||
// do not enforce min_sdk_version for host
|
// do not enforce min_sdk_version for host
|
||||||
if ctx.Host() {
|
if ctx.Host() {
|
||||||
return
|
return
|
||||||
@@ -933,7 +934,7 @@ func CheckMinSdkVersion(m UpdatableModule, ctx ModuleContext, minSdkVersion ApiL
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.WalkPayloadDeps(ctx, func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool {
|
walk(ctx, func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool {
|
||||||
if externalDep {
|
if externalDep {
|
||||||
// external deps are outside the payload boundary, which is "stable"
|
// external deps are outside the payload boundary, which is "stable"
|
||||||
// interface. We don't have to check min_sdk_version for external
|
// interface. We don't have to check min_sdk_version for external
|
||||||
|
@@ -1681,7 +1681,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
// 1) do some validity checks such as apex_available, min_sdk_version, etc.
|
// 1) do some validity checks such as apex_available, min_sdk_version, etc.
|
||||||
a.checkApexAvailability(ctx)
|
a.checkApexAvailability(ctx)
|
||||||
a.checkUpdatable(ctx)
|
a.checkUpdatable(ctx)
|
||||||
a.checkMinSdkVersion(ctx)
|
a.CheckMinSdkVersion(ctx)
|
||||||
a.checkStaticLinkingToStubLibraries(ctx)
|
a.checkStaticLinkingToStubLibraries(ctx)
|
||||||
a.checkStaticExecutables(ctx)
|
a.checkStaticExecutables(ctx)
|
||||||
if len(a.properties.Tests) > 0 && !a.testApex {
|
if len(a.properties.Tests) > 0 && !a.testApex {
|
||||||
@@ -2314,13 +2314,13 @@ func overrideApexFactory() android.Module {
|
|||||||
|
|
||||||
// Entures that min_sdk_version of the included modules are equal or less than the min_sdk_version
|
// Entures that min_sdk_version of the included modules are equal or less than the min_sdk_version
|
||||||
// of this apexBundle.
|
// of this apexBundle.
|
||||||
func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) {
|
func (a *apexBundle) CheckMinSdkVersion(ctx android.ModuleContext) {
|
||||||
if a.testApex || a.vndkApex {
|
if a.testApex || a.vndkApex {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// apexBundle::minSdkVersion reports its own errors.
|
// apexBundle::minSdkVersion reports its own errors.
|
||||||
minSdkVersion := a.minSdkVersion(ctx)
|
minSdkVersion := a.minSdkVersion(ctx)
|
||||||
android.CheckMinSdkVersion(a, ctx, minSdkVersion)
|
android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel {
|
func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel {
|
||||||
|
@@ -294,7 +294,7 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
if minSdkVersion, err := a.MinSdkVersion(ctx).EffectiveVersion(ctx); err == nil {
|
if minSdkVersion, err := a.MinSdkVersion(ctx).EffectiveVersion(ctx); err == nil {
|
||||||
a.checkJniLibsSdkVersion(ctx, minSdkVersion)
|
a.checkJniLibsSdkVersion(ctx, minSdkVersion)
|
||||||
android.CheckMinSdkVersion(a, ctx, minSdkVersion)
|
android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps)
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
|
ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user