Merge "Apex: support codenames for min_sdk_version" into rvc-dev am: 95148f607e am: 0091763e97 am: 3eb6dba2a4 am: 0826a4b03c
Change-Id: I8e4df132bca6f0eef58056461936a8cf45eb88b0
This commit is contained in:
12
apex/apex.go
12
apex/apex.go
@@ -19,7 +19,6 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -1836,14 +1835,11 @@ func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext, do payloadDepsCa
|
||||
|
||||
func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int {
|
||||
ver := proptools.StringDefault(a.properties.Min_sdk_version, "current")
|
||||
if ver != "current" {
|
||||
minSdkVersion, err := strconv.Atoi(ver)
|
||||
if err != nil {
|
||||
ctx.PropertyErrorf("min_sdk_version", "should be \"current\" or <number>, but %q", ver)
|
||||
}
|
||||
return minSdkVersion
|
||||
intVer, err := android.ApiStrToNum(ctx, ver)
|
||||
if err != nil {
|
||||
ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
|
||||
}
|
||||
return android.FutureApiLevel
|
||||
return intVer
|
||||
}
|
||||
|
||||
// Ensures that the dependencies are marked as available for this APEX
|
||||
|
||||
@@ -1132,6 +1132,60 @@ func TestApexUseStubsAccordingToMinSdkVersionInUnbundledBuild(t *testing.T) {
|
||||
expectNoLink("liba", "shared_otherapex", "libz", "shared")
|
||||
}
|
||||
|
||||
func TestApexMinSdkVersion_SupportsCodeNames(t *testing.T) {
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
native_shared_libs: ["libx"],
|
||||
min_sdk_version: "R",
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "myapex.key",
|
||||
public_key: "testkey.avbpubkey",
|
||||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libx",
|
||||
shared_libs: ["libz"],
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
apex_available: [ "myapex" ],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libz",
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
stubs: {
|
||||
versions: ["29", "R"],
|
||||
},
|
||||
}
|
||||
`, func(fs map[string][]byte, config android.Config) {
|
||||
config.TestProductVariables.Platform_version_active_codenames = []string{"R"}
|
||||
})
|
||||
|
||||
expectLink := func(from, from_variant, to, to_variant string) {
|
||||
ldArgs := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld").Args["libFlags"]
|
||||
ensureContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
|
||||
}
|
||||
expectNoLink := func(from, from_variant, to, to_variant string) {
|
||||
ldArgs := ctx.ModuleForTests(from, "android_arm64_armv8-a_"+from_variant).Rule("ld").Args["libFlags"]
|
||||
ensureNotContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
|
||||
}
|
||||
// 9000 is quite a magic number.
|
||||
// Finalized SDK codenames are mapped as P(28), Q(29), ...
|
||||
// And, codenames which are not finalized yet(active_codenames + future_codenames) are numbered from 9000, 9001, ...
|
||||
// to distinguish them from finalized and future_api(10000)
|
||||
// In this test, "R" is assumed not finalized yet( listed in Platform_version_active_codenames) and translated into 9000
|
||||
// (refer android/api_levels.go)
|
||||
expectLink("libx", "shared_myapex", "libz", "shared_9000")
|
||||
expectNoLink("libx", "shared_myapex", "libz", "shared_29")
|
||||
expectNoLink("libx", "shared_myapex", "libz", "shared")
|
||||
}
|
||||
|
||||
func TestApexMinSdkVersionDefaultsToLatest(t *testing.T) {
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
@@ -1322,11 +1376,11 @@ func TestInvalidMinSdkVersion(t *testing.T) {
|
||||
}
|
||||
`)
|
||||
|
||||
testApexError(t, `"myapex" .*: min_sdk_version: should be "current" or <number>`, `
|
||||
testApexError(t, `"myapex" .*: min_sdk_version: SDK version should be .*`, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
min_sdk_version: "R",
|
||||
min_sdk_version: "abc",
|
||||
}
|
||||
|
||||
apex_key {
|
||||
|
||||
Reference in New Issue
Block a user