Always use "${codename}.${sha}" if UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true

Test: m checkbuild
Test: DIST_DIR=/tmp/r-on-q/prod/ TARGET_BUILD_VARIANT=userdebug \
  vendor/google/build/build_mainline_modules_prod.sh -j120
Test: DIST_DIR=/tmp/r-on-q/rsha/ TARGET_BUILD_VARIANT=userdebug \
  vendor/google/build/build_mainline_modules.sh -j120
Test: checked target sdk version is correct for both builds
Bug: 149733822
Change-Id: I3e1beeb721f7e87bc6adda61861fa962ec892360
This commit is contained in:
Nikita Ioffe 2020-03-02 16:58:11 +00:00
parent af8998cba6
commit 934c4f2acc
3 changed files with 13 additions and 17 deletions

View File

@ -442,21 +442,18 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
targetSdkVersion := ctx.Config().DefaultAppTargetSdk()
minSdkVersion := ctx.Config().DefaultAppTargetSdk()
// TODO: this should be based on min_sdk_version property of an APEX.
if proptools.Bool(a.properties.Legacy_android10_support) {
if !java.UseApiFingerprint(ctx, targetSdkVersion) {
targetSdkVersion = "29"
}
if !java.UseApiFingerprint(ctx, minSdkVersion) {
minSdkVersion = "29"
}
targetSdkVersion = "29"
minSdkVersion = "29"
}
if java.UseApiFingerprint(ctx, targetSdkVersion) {
targetSdkVersion += fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
if java.UseApiFingerprint(ctx) {
targetSdkVersion = ctx.Config().PlatformSdkCodename() + 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())
if java.UseApiFingerprint(ctx) {
minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
}
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)

View File

@ -99,8 +99,8 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
if err != nil {
ctx.ModuleErrorf("invalid targetSdkVersion: %s", err)
}
if UseApiFingerprint(ctx, targetSdkVersion) {
targetSdkVersion += fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
if UseApiFingerprint(ctx) {
targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
deps = append(deps, ApiFingerprintPath(ctx))
}
@ -108,8 +108,8 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
if err != nil {
ctx.ModuleErrorf("invalid minSdkVersion: %s", err)
}
if UseApiFingerprint(ctx, minSdkVersion) {
minSdkVersion += fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
if UseApiFingerprint(ctx) {
minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
deps = append(deps, ApiFingerprintPath(ctx))
}

View File

@ -50,9 +50,8 @@ type sdkContext interface {
targetSdkVersion() sdkSpec
}
func UseApiFingerprint(ctx android.BaseModuleContext, v string) bool {
if v == ctx.Config().PlatformSdkCodename() &&
ctx.Config().UnbundledBuild() &&
func UseApiFingerprint(ctx android.BaseModuleContext) bool {
if ctx.Config().UnbundledBuild() &&
!ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
return true