Revert "Allow codename.fingerprint format for minSdkVersion"

This reverts commit 014a85712d.

Reason for revert: Caused vendor/google/build/build_mainline_modules.sh to fail with `Error: minSdkVersion (10000) is greater than maxSdkVersion (30)`.

Bug: 130541924
Change-Id: Ifa233bf40a674481d21b61ee816c5fdde8201080
This commit is contained in:
Pete Gillin 2020-01-21 13:41:17 +00:00
parent 014a85712d
commit 230e241f58
3 changed files with 17 additions and 33 deletions

View File

@ -376,17 +376,15 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
}
targetSdkVersion := ctx.Config().DefaultAppTargetSdk()
minSdkVersion := ctx.Config().DefaultAppTargetSdk()
if java.UseApiFingerprint(ctx, targetSdkVersion) {
targetSdkVersion += fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
}
if java.UseApiFingerprint(ctx, minSdkVersion) {
minSdkVersion += fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
if targetSdkVersion == ctx.Config().PlatformSdkCodename() &&
ctx.Config().UnbundledBuild() &&
!ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
apiFingerprint := java.ApiFingerprintPath(ctx)
targetSdkVersion += fmt.Sprintf(".$$(cat %s)", apiFingerprint.String())
implicitInputs = append(implicitInputs, apiFingerprint)
}
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion)
noticeFile := a.buildNoticeFile(ctx, a.Name()+suffix)
if noticeFile.Valid() {

View File

@ -93,11 +93,13 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
var deps android.Paths
targetSdkVersion := sdkVersionOrDefault(ctx, sdkContext.targetSdkVersion())
minSdkVersion := sdkVersionOrDefault(ctx, sdkContext.minSdkVersion())
if (UseApiFingerprint(ctx, sdkContext.targetSdkVersion()) ||
UseApiFingerprint(ctx, sdkContext.minSdkVersion())) {
apiFingerprint := ApiFingerprintPath(ctx)
deps = append(deps, apiFingerprint)
if targetSdkVersion == ctx.Config().PlatformSdkCodename() &&
ctx.Config().UnbundledBuild() &&
!ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
apiFingerprint := ApiFingerprintPath(ctx)
targetSdkVersion += fmt.Sprintf(".$$(cat %s)", apiFingerprint.String())
deps = append(deps, apiFingerprint)
}
fixedManifest := android.PathForModuleOut(ctx, "manifest_fixer", "AndroidManifest.xml")
@ -108,7 +110,7 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
Implicits: deps,
Output: fixedManifest,
Args: map[string]string{
"minSdkVersion": minSdkVersion,
"minSdkVersion": sdkVersionOrDefault(ctx, sdkContext.minSdkVersion()),
"targetSdkVersion": targetSdkVersion,
"args": strings.Join(args, " "),
},

View File

@ -47,29 +47,13 @@ type sdkContext interface {
targetSdkVersion() string
}
func UseApiFingerprint(ctx android.BaseModuleContext, v string) bool {
if v == ctx.Config().PlatformSdkCodename() &&
ctx.Config().UnbundledBuild() &&
!ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
return true
}
return false
}
func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string {
var sdkVersion string
switch v {
case "", "none", "current", "test_current", "system_current", "core_current", "core_platform":
sdkVersion = ctx.Config().DefaultAppTargetSdk()
return ctx.Config().DefaultAppTargetSdk()
default:
sdkVersion = v
return v
}
if UseApiFingerprint(ctx, sdkVersion) {
apiFingerprint := ApiFingerprintPath(ctx)
sdkVersion += fmt.Sprintf(".$$(cat %s)", apiFingerprint.String())
}
return sdkVersion
}
// Returns a sdk version as a number. For modules targeting an unreleased SDK (meaning it does not yet have a number)