Loading android/util.go +14 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,20 @@ func JoinWithSuffix(strs []string, suffix string, separator string) string { return string(ret) } func SortedIntKeys(m interface{}) []int { v := reflect.ValueOf(m) if v.Kind() != reflect.Map { panic(fmt.Sprintf("%#v is not a map", m)) } keys := v.MapKeys() s := make([]int, 0, len(keys)) for _, key := range keys { s = append(s, int(key.Int())) } sort.Ints(s) return s } func SortedStringKeys(m interface{}) []string { v := reflect.ValueOf(m) if v.Kind() != reflect.Map { Loading dexpreopt/config.go +0 −11 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package dexpreopt import ( "encoding/json" "fmt" "sort" "strings" "github.com/google/blueprint" Loading Loading @@ -142,16 +141,6 @@ func (libPaths LibraryPaths) AddLibraryPaths(otherPaths LibraryPaths) { } } // Return sorted names of the libraries in the map. func (libPaths LibraryPaths) Names() []string { keys := make([]string, 0, len(libPaths)) for k := range libPaths { keys = append(keys, k) } sort.Strings(keys) return keys } type ModuleConfig struct { Name string DexLocation string // dex location on device Loading dexpreopt/dexpreopt.go +1 −11 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ import ( "fmt" "path/filepath" "runtime" "sort" "strings" "android/soong/android" Loading Loading @@ -208,15 +207,6 @@ type classLoaderContextMap map[int]*classLoaderContext const anySdkVersion int = 9999 // should go last in class loader context func (m classLoaderContextMap) getSortedKeys() []int { keys := make([]int, 0, len(m)) for k := range m { keys = append(keys, k) } sort.Ints(keys) return keys } func (m classLoaderContextMap) getValue(sdkVer int) *classLoaderContext { if _, ok := m[sdkVer]; !ok { m[sdkVer] = &classLoaderContext{} Loading Loading @@ -342,7 +332,7 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g cmd := rule.Command(). Text(`eval "$(`).Tool(globalSoong.ConstructContext). Text(` --target-sdk-version ${target_sdk_version}`) for _, ver := range classLoaderContexts.getSortedKeys() { for _, ver := range android.SortedIntKeys(classLoaderContexts) { clc := classLoaderContexts.getValue(ver) verString := fmt.Sprintf("%d", ver) if ver == anySdkVersion { Loading java/androidmk.go +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries { entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile) } entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs.Names()...) entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", android.SortedStringKeys(library.exportedSdkLibs)...) if len(library.additionalCheckedModules) != 0 { entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...) Loading java/java_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -1495,7 +1495,7 @@ func TestJavaSdkLibrary(t *testing.T) { // test if baz has exported SDK lib names foo and bar to qux qux := ctx.ModuleForTests("qux", "android_common") if quxLib, ok := qux.Module().(*Library); ok { sdkLibs := quxLib.ExportedSdkLibs().Names() sdkLibs := android.SortedStringKeys(quxLib.ExportedSdkLibs()) if w := []string{"bar", "foo", "fred", "quuz"}; !reflect.DeepEqual(w, sdkLibs) { t.Errorf("qux should export %q but exports %q", w, sdkLibs) } Loading Loading
android/util.go +14 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,20 @@ func JoinWithSuffix(strs []string, suffix string, separator string) string { return string(ret) } func SortedIntKeys(m interface{}) []int { v := reflect.ValueOf(m) if v.Kind() != reflect.Map { panic(fmt.Sprintf("%#v is not a map", m)) } keys := v.MapKeys() s := make([]int, 0, len(keys)) for _, key := range keys { s = append(s, int(key.Int())) } sort.Ints(s) return s } func SortedStringKeys(m interface{}) []string { v := reflect.ValueOf(m) if v.Kind() != reflect.Map { Loading
dexpreopt/config.go +0 −11 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package dexpreopt import ( "encoding/json" "fmt" "sort" "strings" "github.com/google/blueprint" Loading Loading @@ -142,16 +141,6 @@ func (libPaths LibraryPaths) AddLibraryPaths(otherPaths LibraryPaths) { } } // Return sorted names of the libraries in the map. func (libPaths LibraryPaths) Names() []string { keys := make([]string, 0, len(libPaths)) for k := range libPaths { keys = append(keys, k) } sort.Strings(keys) return keys } type ModuleConfig struct { Name string DexLocation string // dex location on device Loading
dexpreopt/dexpreopt.go +1 −11 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ import ( "fmt" "path/filepath" "runtime" "sort" "strings" "android/soong/android" Loading Loading @@ -208,15 +207,6 @@ type classLoaderContextMap map[int]*classLoaderContext const anySdkVersion int = 9999 // should go last in class loader context func (m classLoaderContextMap) getSortedKeys() []int { keys := make([]int, 0, len(m)) for k := range m { keys = append(keys, k) } sort.Ints(keys) return keys } func (m classLoaderContextMap) getValue(sdkVer int) *classLoaderContext { if _, ok := m[sdkVer]; !ok { m[sdkVer] = &classLoaderContext{} Loading Loading @@ -342,7 +332,7 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g cmd := rule.Command(). Text(`eval "$(`).Tool(globalSoong.ConstructContext). Text(` --target-sdk-version ${target_sdk_version}`) for _, ver := range classLoaderContexts.getSortedKeys() { for _, ver := range android.SortedIntKeys(classLoaderContexts) { clc := classLoaderContexts.getValue(ver) verString := fmt.Sprintf("%d", ver) if ver == anySdkVersion { Loading
java/androidmk.go +1 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries { entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile) } entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs.Names()...) entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", android.SortedStringKeys(library.exportedSdkLibs)...) if len(library.additionalCheckedModules) != 0 { entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...) Loading
java/java_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -1495,7 +1495,7 @@ func TestJavaSdkLibrary(t *testing.T) { // test if baz has exported SDK lib names foo and bar to qux qux := ctx.ModuleForTests("qux", "android_common") if quxLib, ok := qux.Module().(*Library); ok { sdkLibs := quxLib.ExportedSdkLibs().Names() sdkLibs := android.SortedStringKeys(quxLib.ExportedSdkLibs()) if w := []string{"bar", "foo", "fred", "quuz"}; !reflect.DeepEqual(w, sdkLibs) { t.Errorf("qux should export %q but exports %q", w, sdkLibs) } Loading