Automatically reorder C/C++ link dependencies in Soong

This uses knowledge of transitive dependencies to reorder
linker command line arguments such that if module A depends
on module B, then module A is automatically listed before
module B in the linker command line.

This should mostly remove the need for Android.bp files to
list all of their static dependencies in link order

Bug: 66260943
Test: reorder the entries of static_libs in an Android.bp and see that linking still succeeds

Change-Id: I20f851ab9f2f30031254e4f30023b6140d15d6c3
This commit is contained in:
Jeff Gaston
2017-09-27 17:05:30 -07:00
parent af3cc2d23c
commit 294356f045
4 changed files with 414 additions and 42 deletions

View File

@@ -303,6 +303,32 @@ outer:
return list[:k]
}
func indexPathList(s Path, list []Path) int {
for i, l := range list {
if l == s {
return i
}
}
return -1
}
func inPathList(p Path, list []Path) bool {
return indexPathList(p, list) != -1
}
func FilterPathList(list []Path, filter []Path) (remainder []Path, filtered []Path) {
for _, l := range list {
if inPathList(l, filter) {
filtered = append(filtered, l)
} else {
remainder = append(remainder, l)
}
}
return
}
// HasExt returns true of any of the paths have extension ext, otherwise false
func (p Paths) HasExt(ext string) bool {
for _, path := range p {