Merge changes from topics "soong-apilevel", "soong-config-apilevel"

* changes:
  Convert more versions in config to ApiLevel.
  Replace FutureApiLevel with an ApiLevel.
  Replace ApiStrToNum uses with ApiLevel.
This commit is contained in:
Dan Albert
2020-09-24 21:02:07 +00:00
committed by Gerrit Code Review
22 changed files with 184 additions and 183 deletions

View File

@@ -19,8 +19,6 @@ import (
"io"
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
"sync"
@@ -1520,20 +1518,18 @@ func LinkageMutator(mctx android.BottomUpMutatorContext) {
}
func normalizeVersions(ctx android.BaseModuleContext, versions []string) {
numVersions := make([]int, len(versions))
var previous android.ApiLevel
for i, v := range versions {
numVer, err := android.ApiStrToNum(ctx, v)
ver, err := android.ApiLevelFromUser(ctx, v)
if err != nil {
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)
if i > 0 && ver.LessThanOrEqualTo(previous) {
ctx.PropertyErrorf("versions", "not sorted: %v", versions)
}
versions[i] = ver.String()
previous = ver
}
}