From 4e115cc90de936fd68ce162c847370df5fb5021c Mon Sep 17 00:00:00 2001 From: Sam Delmerico Date: Thu, 19 Jan 2023 15:36:52 -0500 Subject: add androidmk cc-related variables to androidmk The adbd_test androidmk definition is missing some cc-related variables for cc_test in mixed builds. These variables should be populated from information from Bazel. Bug: 265758350 Change-Id: I59d017e2eb2f139188ba3383c457cc0055372b61 --- android/util.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'android/util.go') diff --git a/android/util.go b/android/util.go index a0f716047..234bda365 100644 --- a/android/util.go +++ b/android/util.go @@ -136,6 +136,32 @@ func InList(s string, list []string) bool { return IndexList(s, list) != -1 } +func setFromList[T comparable](l []T) map[T]bool { + m := make(map[T]bool, len(l)) + for _, t := range l { + m[t] = true + } + return m +} + +// ListDifference checks if the two lists contain the same elements +func ListDifference[T comparable](l1, l2 []T) []T { + diff := []T{} + m1 := setFromList(l1) + m2 := setFromList(l2) + for _, t := range l1 { + if _, ok := m2[t]; !ok { + diff = append(diff, t) + } + } + for _, t := range l2 { + if _, ok := m1[t]; !ok { + diff = append(diff, t) + } + } + return diff +} + // Returns true if the given string s is prefixed with any string in the given prefix list. func HasAnyPrefix(s string, prefixList []string) bool { for _, prefix := range prefixList { -- cgit v1.2.3-59-g8ed1b