From b69301ee9696d83a75f88ad38d6e27cc6f14b76a Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 1 Dec 2017 10:48:26 -0800 Subject: [PATCH] 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 --- java/aapt2.go | 4 ++++ java/app_test.go | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/java/aapt2.go b/java/aapt2.go index cebd6d157..84e3729fe 100644 --- a/java/aapt2.go +++ b/java/aapt2.go @@ -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 } diff --git a/java/app_test.go b/java/app_test.go index 35230d45f..73ac3f78e 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -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())