Fix apex_test.go and add it to Android.bp

apex_test.go wasn't listed in the Android.bp file, which allowed
it to bitrot.  Make the API level methods take a PathContext
so that they can be called from a test using configErrorWrapper.
Also fix an int that was converted to a string.

Test: apex_test.go
Change-Id: I1ff87134c837bd5d344d22550baabde10d1b0b2e
This commit is contained in:
Colin Cross
2020-10-02 10:26:04 -07:00
parent 973f46703b
commit 9f720ce52a
4 changed files with 26 additions and 23 deletions

View File

@@ -42,7 +42,7 @@ type ApexInfo struct {
InApexes []string
}
func (i ApexInfo) mergedName(ctx EarlyModuleContext) string {
func (i ApexInfo) mergedName(ctx PathContext) string {
name := "apex" + strconv.Itoa(i.MinSdkVersion(ctx).FinalOrFutureInt())
for _, sdk := range i.RequiredSdks {
name += "_" + sdk.Name + "_" + sdk.Version
@@ -50,7 +50,7 @@ func (i ApexInfo) mergedName(ctx EarlyModuleContext) string {
return name
}
func (this *ApexInfo) MinSdkVersion(ctx EarlyModuleContext) ApiLevel {
func (this *ApexInfo) MinSdkVersion(ctx PathContext) ApiLevel {
return ApiLevelOrPanic(ctx, this.MinSdkVersionStr)
}
@@ -358,7 +358,7 @@ func (a byApexName) Less(i, j int) bool { return a[i].ApexVariationName < a[j].A
// mergeApexVariations deduplicates APEX variations that would build identically into a common
// variation. It returns the reduced list of variations and a list of aliases from the original
// variation names to the new variation names.
func mergeApexVariations(ctx EarlyModuleContext, apexVariations []ApexInfo) (merged []ApexInfo, aliases [][2]string) {
func mergeApexVariations(ctx PathContext, apexVariations []ApexInfo) (merged []ApexInfo, aliases [][2]string) {
sort.Sort(byApexName(apexVariations))
seen := make(map[string]int)
for _, apexInfo := range apexVariations {