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

@@ -65,7 +65,14 @@ func (ctx *TestContext) ModuleForTests(name, variant string) TestingModule {
})
if module == nil {
panic(fmt.Errorf("failed to find module %q variant %q", name, variant))
// find all the modules that do exist
allModuleNames := []string{}
ctx.VisitAllModules(func(m blueprint.Module) {
allModuleNames = append(allModuleNames, m.(Module).Name()+"("+ctx.ModuleSubDir(m)+")")
})
panic(fmt.Errorf("failed to find module %q variant %q."+
"\nall modules: %v", name, variant, allModuleNames))
}
return TestingModule{module}