diff options
| author | 2022-12-02 17:00:22 +0000 | |
|---|---|---|
| committer | 2022-12-06 07:15:44 +0000 | |
| commit | 16ebdfdf0fac0c38d595069f2e38d45e749e9112 (patch) | |
| tree | 4d11d89354c1b59cad1602367fbe203a3482f6d6 | |
| parent | 3f32b38cfb6ce44dc26e3d9bac9c219c49aa95b5 (diff) | |
Add option to override defaultManifestVersion
Add an option to override defaultManifestVersion using environment
variable. The environment variable will be used to override the apex
version locally when developing a desert release feature in
mainline-prod branch. Overriding the apex version in mainline-prod
branch allows us to install apex built in mainline-prod branch to device
running code from git_master which has a higher apex version than
mainline-prod branch.
Bug: b/233608815
Bug: b/196860838
Test: presubmit
Test: go test -v ./build/soong/apex/
Change-Id: I8ac2aae2b6b29da7f09db6edb893e0a0f0691e51
| -rw-r--r-- | apex/apex_test.go | 35 | ||||
| -rw-r--r-- | apex/builder.go | 6 |
2 files changed, 40 insertions, 1 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go index 883c3c847..876a052b2 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -4130,6 +4130,41 @@ func TestApexName(t *testing.T) { ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n") } +func TestOverrideApexManifestDefaultVersion(t *testing.T) { + ctx := testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + apex_name: "com.android.myapex", + native_shared_libs: ["mylib"], + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + cc_library { + name: "mylib", + srcs: ["mylib.cpp"], + system_shared_libs: [], + stl: "none", + apex_available: [ + "//apex_available:platform", + "myapex", + ], + } + `, android.FixtureMergeEnv(map[string]string{ + "OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION": "1234", + })) + + module := ctx.ModuleForTests("myapex", "android_common_com.android.myapex_image") + apexManifestRule := module.Rule("apexManifestRule") + ensureContains(t, apexManifestRule.Args["default_version"], "1234") +} + func TestCompileMultilibProp(t *testing.T) { testCases := []struct { compileMultiLibProp string diff --git a/apex/builder.go b/apex/builder.go index 9e368b604..4be34d22b 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -236,6 +236,10 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, } manifestJsonFullOut := android.PathForModuleOut(ctx, "apex_manifest_full.json") + defaultVersion := android.DefaultUpdatableModuleVersion + if override := ctx.Config().Getenv("OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION"); override != "" { + defaultVersion = override + } ctx.Build(pctx, android.BuildParams{ Rule: apexManifestRule, Input: src, @@ -243,7 +247,7 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, Args: map[string]string{ "provideNativeLibs": strings.Join(provideNativeLibs, " "), "requireNativeLibs": strings.Join(requireNativeLibs, " "), - "default_version": android.DefaultUpdatableModuleVersion, + "default_version": defaultVersion, "opt": strings.Join(optCommands, " "), }, }) |