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