Sort compiled resources by output path

Soong was keeping the compiled resources in the same order as the
input resources, which are sorted lexicographically. Converting the
path names in pathsToAapt2Paths results in a list that is no longer
lexicographically sorted.

Make sorts the inputs to aapt2 link by compiled resource name, so
do the same in Soong.

Bug: 69917341
Test: no change to framework-res.apk when converting to Soong
Change-Id: I29e8339b9969b0d323d469dac140c7e172b7ebfa
This commit is contained in:
Colin Cross 2017-12-01 10:48:26 -08:00
parent 890ff551f7
commit b69301ee96
2 changed files with 10 additions and 1 deletions

View file

@ -16,6 +16,7 @@ package java
import (
"path/filepath"
"sort"
"strconv"
"strings"
@ -85,6 +86,9 @@ func aapt2Compile(ctx android.ModuleContext, dir android.Path, paths android.Pat
})
}
sort.Slice(ret, func(i, j int) bool {
return ret[i].String() < ret[j].String()
})
return ret
}

View file

@ -17,6 +17,7 @@ package java
import (
"android/soong/android"
"reflect"
"sort"
"testing"
)
@ -79,7 +80,11 @@ func TestApp(t *testing.T) {
t.Errorf("expected aapt2 compile inputs expected:\n %#v\n got:\n %#v",
resourceFiles, compile.Inputs.Strings())
}
expectedLinkImplicits = append(expectedLinkImplicits, compile.Outputs.Strings()...)
compiledResourceOutputs := compile.Outputs.Strings()
sort.Strings(compiledResourceOutputs)
expectedLinkImplicits = append(expectedLinkImplicits, compiledResourceOutputs...)
list := foo.Output("aapt2/res.list")
expectedLinkImplicits = append(expectedLinkImplicits, list.Output.String())