Move string list utility functions to android package
Test: m checkbuild Change-Id: I50a7ccf9fd7ed82b688e3eb90489c0bc0af33287
This commit is contained in:
49
cc/util.go
49
cc/util.go
@@ -40,50 +40,11 @@ func libNamesToFlags(names []string) string {
|
||||
return android.JoinWithPrefix(names, "-l")
|
||||
}
|
||||
|
||||
func indexList(s string, list []string) int {
|
||||
for i, l := range list {
|
||||
if l == s {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
func inList(s string, list []string) bool {
|
||||
return indexList(s, list) != -1
|
||||
}
|
||||
|
||||
func filterList(list []string, filter []string) (remainder []string, filtered []string) {
|
||||
for _, l := range list {
|
||||
if inList(l, filter) {
|
||||
filtered = append(filtered, l)
|
||||
} else {
|
||||
remainder = append(remainder, l)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func removeListFromList(list []string, filter_out []string) (result []string) {
|
||||
result = make([]string, 0, len(list))
|
||||
for _, l := range list {
|
||||
if !inList(l, filter_out) {
|
||||
result = append(result, l)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func removeFromList(s string, list []string) (bool, []string) {
|
||||
i := indexList(s, list)
|
||||
if i != -1 {
|
||||
return true, append(list[:i], list[i+1:]...)
|
||||
} else {
|
||||
return false, list
|
||||
}
|
||||
}
|
||||
var indexList = android.IndexList
|
||||
var inList = android.InList
|
||||
var filterList = android.FilterList
|
||||
var removeListFromList = android.RemoveListFromList
|
||||
var removeFromList = android.RemoveFromList
|
||||
|
||||
var libNameRegexp = regexp.MustCompile(`^lib(.*)$`)
|
||||
|
||||
|
Reference in New Issue
Block a user