Merge "Clean up sortedKeys function"
am: b6fd6f75f2
Change-Id: I4461b1ce3b82cac45682ed8bdc9bf1cee4ed7419
This commit is contained in:
commit
a0ea84a72c
4 changed files with 15 additions and 29 deletions
|
@ -18,7 +18,6 @@ import (
|
|||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/scanner"
|
||||
|
||||
|
@ -1658,17 +1657,8 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|||
return
|
||||
}
|
||||
|
||||
sortedKeys := func(m map[string]Paths) []string {
|
||||
s := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
s = append(s, k)
|
||||
}
|
||||
sort.Strings(s)
|
||||
return s
|
||||
}
|
||||
|
||||
// Ensure ancestor directories are in modulesInDir
|
||||
dirs := sortedKeys(modulesInDir)
|
||||
dirs := SortedStringKeys(modulesInDir)
|
||||
for _, dir := range dirs {
|
||||
dir := parentDir(dir)
|
||||
for dir != "." && dir != "/" {
|
||||
|
@ -1681,7 +1671,6 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|||
}
|
||||
|
||||
// Make directories build their direct subdirectories
|
||||
dirs = sortedKeys(modulesInDir)
|
||||
for _, dir := range dirs {
|
||||
p := parentDir(dir)
|
||||
if p != "." && p != "/" {
|
||||
|
@ -1738,8 +1727,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|||
}
|
||||
|
||||
// Wrap those into host|host-cross|target phony rules
|
||||
osClasses := sortedKeys(osClass)
|
||||
for _, class := range osClasses {
|
||||
for _, class := range SortedStringKeys(osClass) {
|
||||
ctx.Build(pctx, BuildParams{
|
||||
Rule: blueprint.Phony,
|
||||
Output: PathForPhony(ctx, class),
|
||||
|
|
|
@ -16,6 +16,7 @@ package android
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"sort"
|
||||
|
@ -77,10 +78,15 @@ func JoinWithSuffix(strs []string, suffix string, separator string) string {
|
|||
return string(ret)
|
||||
}
|
||||
|
||||
func sortedKeys(m map[string][]string) []string {
|
||||
s := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
s = append(s, k)
|
||||
func SortedStringKeys(m interface{}) []string {
|
||||
v := reflect.ValueOf(m)
|
||||
if v.Kind() != reflect.Map {
|
||||
panic(fmt.Sprintf("%#v is not a map", m))
|
||||
}
|
||||
keys := v.MapKeys()
|
||||
s := make([]string, 0, len(keys))
|
||||
for _, key := range keys {
|
||||
s = append(s, key.String())
|
||||
}
|
||||
sort.Strings(s)
|
||||
return s
|
||||
|
|
|
@ -30,6 +30,7 @@ blueprint_go_binary {
|
|||
"androidmk-parser",
|
||||
"blueprint-parser",
|
||||
"bpfix-lib",
|
||||
"soong-android",
|
||||
],
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"android/soong/android"
|
||||
mkparser "android/soong/androidmk/parser"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
bpparser "github.com/google/blueprint/parser"
|
||||
|
@ -335,15 +335,6 @@ func classifyLocalOrGlobalPath(value bpparser.Expression) (string, bpparser.Expr
|
|||
}
|
||||
}
|
||||
|
||||
func sortedMapKeys(inputMap map[string]string) (sortedKeys []string) {
|
||||
keys := make([]string, 0, len(inputMap))
|
||||
for key := range inputMap {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
// splitAndAssign splits a Make list into components and then
|
||||
// creates the corresponding variable assignments.
|
||||
func splitAndAssign(ctx variableAssignmentContext, splitFunc listSplitFunc, namesByClassification map[string]string) error {
|
||||
|
@ -357,7 +348,7 @@ func splitAndAssign(ctx variableAssignmentContext, splitFunc listSplitFunc, name
|
|||
return err
|
||||
}
|
||||
|
||||
for _, nameClassification := range sortedMapKeys(namesByClassification) {
|
||||
for _, nameClassification := range android.SortedStringKeys(namesByClassification) {
|
||||
name := namesByClassification[nameClassification]
|
||||
if component, ok := lists[nameClassification]; ok && !emptyList(component) {
|
||||
err = setVariable(ctx.file, ctx.append, ctx.prefix, name, component, true)
|
||||
|
|
Loading…
Reference in a new issue