Dedup exported flags from dependencies
Soong command lines have gotten very long due to hidl modules reexporting lots of libraries. Dedup the include dir flags. Test: m -j checkbuild Change-Id: I6ada1251012da42344e2c00ae66001a649023d2c
This commit is contained in:
20
cc/cc.go
20
cc/cc.go
@@ -1054,6 +1054,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||
}
|
||||
})
|
||||
|
||||
// Dedup exported flags from dependencies
|
||||
depPaths.Flags = firstUniqueElements(depPaths.Flags)
|
||||
|
||||
return depPaths
|
||||
}
|
||||
|
||||
@@ -1175,6 +1178,23 @@ func vendorMutator(mctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
}
|
||||
|
||||
// firstUniqueElements returns all unique elements of a slice, keeping the first copy of each
|
||||
// modifies the slice contents in place, and returns a subslice of the original slice
|
||||
func firstUniqueElements(list []string) []string {
|
||||
k := 0
|
||||
outer:
|
||||
for i := 0; i < len(list); i++ {
|
||||
for j := 0; j < k; j++ {
|
||||
if list[i] == list[j] {
|
||||
continue outer
|
||||
}
|
||||
}
|
||||
list[k] = list[i]
|
||||
k++
|
||||
}
|
||||
return list[:k]
|
||||
}
|
||||
|
||||
// lastUniqueElements returns all unique elements of a slice, keeping the last copy of each
|
||||
// modifies the slice contents in place, and returns a subslice of the original slice
|
||||
func lastUniqueElements(list []string) []string {
|
||||
|
Reference in New Issue
Block a user