Merge "Revert "Set targetsdkversion to future level if TARGET_BUILD_APPS is not empty"" am: 9df0fa5e63

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1914027

Change-Id: Ia35a8a3e1094d2d7c3355e66395dfa7b6880ead7
This commit is contained in:
Allen Hair 2021-12-08 18:12:54 +00:00 committed by Automerger Merge Worker
commit 952ebe85f0

View file

@ -16,7 +16,6 @@ package java
import (
"fmt"
"strconv"
"strings"
"github.com/google/blueprint"
@ -43,20 +42,6 @@ var manifestMergerRule = pctx.AndroidStaticRule("manifestMerger",
},
"args", "libs")
// targetSdkVersion for manifest_fixer
// When TARGET_BUILD_APPS is not empty, this method returns the unreleased(future) API level
// This enables release builds (that run with TARGET_BUILD_APPS=[val...]) to target APIs that have not yet been finalized as part of an SDK
func targetSdkVersionForManifestFixer(ctx android.ModuleContext, sdkContext android.SdkContext) string {
if ctx.Config().UnbundledBuildApps() {
return strconv.Itoa(android.FutureApiLevel.FinalOrFutureInt())
}
targetSdkVersion, err := sdkContext.TargetSdkVersion(ctx).EffectiveVersionString(ctx)
if err != nil {
ctx.ModuleErrorf("invalid targetSdkVersion: %s", err)
}
return targetSdkVersion
}
// Uses manifest_fixer.py to inject minSdkVersion, etc. into an AndroidManifest.xml
func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext android.SdkContext,
classLoaderContexts dexpreopt.ClassLoaderContextMap, isLibrary, useEmbeddedNativeLibs, usesNonSdkApis,
@ -104,7 +89,10 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
args = append(args, "--logging-parent", loggingParent)
}
var deps android.Paths
targetSdkVersion := targetSdkVersionForManifestFixer(ctx, sdkContext)
targetSdkVersion, err := sdkContext.TargetSdkVersion(ctx).EffectiveVersionString(ctx)
if err != nil {
ctx.ModuleErrorf("invalid targetSdkVersion: %s", err)
}
if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
deps = append(deps, ApiFingerprintPath(ctx))