Apex: support codenames for min_sdk_version
Apex can use codenames like "Q", "R" for its min_sdk_version property.
Also, cc_library can use codenames for its stubs.versions.
Bug: 152655956
Test: m
Merged-In: I077ad7b2ac5d90b4c8708921e43846206f05ba70
Change-Id: I077ad7b2ac5d90b4c8708921e43846206f05ba70
(cherry picked from commit 29e91d2121
)
This commit is contained in:
@@ -1489,18 +1489,22 @@ func LatestStubsVersionFor(config android.Config, name string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func checkVersions(ctx android.BaseModuleContext, versions []string) {
|
||||
func normalizeVersions(ctx android.BaseModuleContext, versions []string) {
|
||||
numVersions := make([]int, len(versions))
|
||||
for i, v := range versions {
|
||||
numVer, err := strconv.Atoi(v)
|
||||
numVer, err := android.ApiStrToNum(ctx, v)
|
||||
if err != nil {
|
||||
ctx.PropertyErrorf("versions", "%q is not a number", v)
|
||||
ctx.PropertyErrorf("versions", "%s", err.Error())
|
||||
return
|
||||
}
|
||||
numVersions[i] = numVer
|
||||
}
|
||||
if !sort.IsSorted(sort.IntSlice(numVersions)) {
|
||||
ctx.PropertyErrorf("versions", "not sorted: %v", versions)
|
||||
}
|
||||
for i, v := range numVersions {
|
||||
versions[i] = strconv.Itoa(v)
|
||||
}
|
||||
}
|
||||
|
||||
func createVersionVariations(mctx android.BottomUpMutatorContext, versions []string) {
|
||||
@@ -1522,7 +1526,7 @@ func VersionMutator(mctx android.BottomUpMutatorContext) {
|
||||
if library, ok := mctx.Module().(LinkableInterface); ok && !library.InRecovery() {
|
||||
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 {
|
||||
versions := library.StubsVersions()
|
||||
checkVersions(mctx, versions)
|
||||
normalizeVersions(mctx, versions)
|
||||
if mctx.Failed() {
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user