Merge "Add environment variable UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA" into main am: a0ccab683b am: 4e0e9d3108

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

Change-Id: I58583de88c9363c44b31d6c92c08aa05ef7557b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jihoon Kang
2024-02-13 14:38:26 +00:00
committed by Automerger Merge Worker
4 changed files with 108 additions and 18 deletions

View File

@@ -152,9 +152,10 @@ func ManifestFixer(ctx android.ModuleContext, manifest android.Path,
if params.SdkContext != nil {
targetSdkVersion := targetSdkVersionForManifestFixer(ctx, params)
if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
deps = append(deps, ApiFingerprintPath(ctx))
if useApiFingerprint, fingerprintTargetSdkVersion, fingerprintDeps :=
UseApiFingerprint(ctx); useApiFingerprint && ctx.ModuleName() != "framework-res" {
targetSdkVersion = fingerprintTargetSdkVersion
deps = append(deps, fingerprintDeps)
}
args = append(args, "--targetSdkVersion ", targetSdkVersion)
@@ -169,9 +170,10 @@ func ManifestFixer(ctx android.ModuleContext, manifest android.Path,
ctx.ModuleErrorf("invalid ReplaceMaxSdkVersionPlaceholder: %s", err)
}
if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
deps = append(deps, ApiFingerprintPath(ctx))
if useApiFingerprint, fingerprintMinSdkVersion, fingerprintDeps :=
UseApiFingerprint(ctx); useApiFingerprint && ctx.ModuleName() != "framework-res" {
minSdkVersion = fingerprintMinSdkVersion
deps = append(deps, fingerprintDeps)
}
if err != nil {

View File

@@ -33,13 +33,26 @@ var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
func UseApiFingerprint(ctx android.BaseModuleContext) bool {
if ctx.Config().UnbundledBuild() &&
!ctx.Config().AlwaysUsePrebuiltSdks() &&
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
return true
func UseApiFingerprint(ctx android.BaseModuleContext) (useApiFingerprint bool, fingerprintSdkVersion string, fingerprintDeps android.OutputPath) {
if ctx.Config().UnbundledBuild() && !ctx.Config().AlwaysUsePrebuiltSdks() {
apiFingerprintTrue := ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT")
dessertShaIsSet := ctx.Config().Getenv("UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA") != ""
// Error when both UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT and UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA are set
if apiFingerprintTrue && dessertShaIsSet {
ctx.ModuleErrorf("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true cannot be set alongside with UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA")
}
useApiFingerprint = apiFingerprintTrue || dessertShaIsSet
if apiFingerprintTrue {
fingerprintSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
fingerprintDeps = ApiFingerprintPath(ctx)
}
if dessertShaIsSet {
fingerprintSdkVersion = ctx.Config().Getenv("UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA")
}
}
return false
return useApiFingerprint, fingerprintSdkVersion, fingerprintDeps
}
func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpec) javaVersion {