Merge "Add environment variable UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA" into main
This commit is contained in:
@@ -790,6 +790,79 @@ func TestApexManifestMinSdkVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApexWithDessertSha(t *testing.T) {
|
||||||
|
ctx := testApex(t, `
|
||||||
|
apex_defaults {
|
||||||
|
name: "my_defaults",
|
||||||
|
key: "myapex.key",
|
||||||
|
product_specific: true,
|
||||||
|
file_contexts: ":my-file-contexts",
|
||||||
|
updatable: false,
|
||||||
|
}
|
||||||
|
apex {
|
||||||
|
name: "myapex_30",
|
||||||
|
min_sdk_version: "30",
|
||||||
|
defaults: ["my_defaults"],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex {
|
||||||
|
name: "myapex_current",
|
||||||
|
min_sdk_version: "current",
|
||||||
|
defaults: ["my_defaults"],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex {
|
||||||
|
name: "myapex_none",
|
||||||
|
defaults: ["my_defaults"],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
filegroup {
|
||||||
|
name: "my-file-contexts",
|
||||||
|
srcs: ["product_specific_file_contexts"],
|
||||||
|
}
|
||||||
|
`, withFiles(map[string][]byte{
|
||||||
|
"product_specific_file_contexts": nil,
|
||||||
|
}), android.FixtureModifyProductVariables(
|
||||||
|
func(variables android.FixtureProductVariables) {
|
||||||
|
variables.Unbundled_build = proptools.BoolPtr(true)
|
||||||
|
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(false)
|
||||||
|
}), android.FixtureMergeEnv(map[string]string{
|
||||||
|
"UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA": "UpsideDownCake.abcdefghijklmnopqrstuvwxyz123456",
|
||||||
|
}))
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
module string
|
||||||
|
minSdkVersion string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
module: "myapex_30",
|
||||||
|
minSdkVersion: "30",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
module: "myapex_current",
|
||||||
|
minSdkVersion: "UpsideDownCake.abcdefghijklmnopqrstuvwxyz123456",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
module: "myapex_none",
|
||||||
|
minSdkVersion: "UpsideDownCake.abcdefghijklmnopqrstuvwxyz123456",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
module := ctx.ModuleForTests(tc.module, "android_common_"+tc.module)
|
||||||
|
args := module.Rule("apexRule").Args
|
||||||
|
optFlags := args["opt_flags"]
|
||||||
|
if !strings.Contains(optFlags, "--min_sdk_version "+tc.minSdkVersion) {
|
||||||
|
t.Errorf("%s: Expected min_sdk_version=%s, got: %s", tc.module, tc.minSdkVersion, optFlags)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestFileContexts(t *testing.T) {
|
func TestFileContexts(t *testing.T) {
|
||||||
for _, vendor := range []bool{true, false} {
|
for _, vendor := range []bool{true, false} {
|
||||||
prop := ""
|
prop := ""
|
||||||
|
@@ -695,18 +695,20 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
|
|||||||
if moduleMinSdkVersion.IsCurrent() || moduleMinSdkVersion.IsNone() {
|
if moduleMinSdkVersion.IsCurrent() || moduleMinSdkVersion.IsNone() {
|
||||||
minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
|
minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
|
||||||
|
|
||||||
if java.UseApiFingerprint(ctx) {
|
if useApiFingerprint, fingerprintMinSdkVersion, fingerprintDeps :=
|
||||||
minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
|
java.UseApiFingerprint(ctx); useApiFingerprint {
|
||||||
implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
|
minSdkVersion = fingerprintMinSdkVersion
|
||||||
|
implicitInputs = append(implicitInputs, fingerprintDeps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// apex module doesn't have a concept of target_sdk_version, hence for the time
|
// apex module doesn't have a concept of target_sdk_version, hence for the time
|
||||||
// being targetSdkVersion == default targetSdkVersion of the branch.
|
// being targetSdkVersion == default targetSdkVersion of the branch.
|
||||||
targetSdkVersion := strconv.Itoa(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt())
|
targetSdkVersion := strconv.Itoa(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt())
|
||||||
|
|
||||||
if java.UseApiFingerprint(ctx) {
|
if useApiFingerprint, fingerprintTargetSdkVersion, fingerprintDeps :=
|
||||||
targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
|
java.UseApiFingerprint(ctx); useApiFingerprint {
|
||||||
implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
|
targetSdkVersion = fingerprintTargetSdkVersion
|
||||||
|
implicitInputs = append(implicitInputs, fingerprintDeps)
|
||||||
}
|
}
|
||||||
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
|
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
|
||||||
optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion)
|
optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion)
|
||||||
|
@@ -152,9 +152,10 @@ func ManifestFixer(ctx android.ModuleContext, manifest android.Path,
|
|||||||
if params.SdkContext != nil {
|
if params.SdkContext != nil {
|
||||||
targetSdkVersion := targetSdkVersionForManifestFixer(ctx, params)
|
targetSdkVersion := targetSdkVersionForManifestFixer(ctx, params)
|
||||||
|
|
||||||
if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
|
if useApiFingerprint, fingerprintTargetSdkVersion, fingerprintDeps :=
|
||||||
targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
|
UseApiFingerprint(ctx); useApiFingerprint && ctx.ModuleName() != "framework-res" {
|
||||||
deps = append(deps, ApiFingerprintPath(ctx))
|
targetSdkVersion = fingerprintTargetSdkVersion
|
||||||
|
deps = append(deps, fingerprintDeps)
|
||||||
}
|
}
|
||||||
|
|
||||||
args = append(args, "--targetSdkVersion ", targetSdkVersion)
|
args = append(args, "--targetSdkVersion ", targetSdkVersion)
|
||||||
@@ -169,9 +170,10 @@ func ManifestFixer(ctx android.ModuleContext, manifest android.Path,
|
|||||||
ctx.ModuleErrorf("invalid ReplaceMaxSdkVersionPlaceholder: %s", err)
|
ctx.ModuleErrorf("invalid ReplaceMaxSdkVersionPlaceholder: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
|
if useApiFingerprint, fingerprintMinSdkVersion, fingerprintDeps :=
|
||||||
minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
|
UseApiFingerprint(ctx); useApiFingerprint && ctx.ModuleName() != "framework-res" {
|
||||||
deps = append(deps, ApiFingerprintPath(ctx))
|
minSdkVersion = fingerprintMinSdkVersion
|
||||||
|
deps = append(deps, fingerprintDeps)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
25
java/sdk.go
25
java/sdk.go
@@ -33,13 +33,26 @@ var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
|
|||||||
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
|
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
|
||||||
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
|
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
|
||||||
|
|
||||||
func UseApiFingerprint(ctx android.BaseModuleContext) bool {
|
func UseApiFingerprint(ctx android.BaseModuleContext) (useApiFingerprint bool, fingerprintSdkVersion string, fingerprintDeps android.OutputPath) {
|
||||||
if ctx.Config().UnbundledBuild() &&
|
if ctx.Config().UnbundledBuild() && !ctx.Config().AlwaysUsePrebuiltSdks() {
|
||||||
!ctx.Config().AlwaysUsePrebuiltSdks() &&
|
apiFingerprintTrue := ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT")
|
||||||
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
|
dessertShaIsSet := ctx.Config().Getenv("UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA") != ""
|
||||||
return true
|
|
||||||
|
// 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 {
|
func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpec) javaVersion {
|
||||||
|
Reference in New Issue
Block a user