Add missing dependencies when linking tests

Linking tests needs the same dependencies that linking binaries
got in https://github.com/google/blueprint/pull/222.

Test: m checkbuild
Change-Id: I33330f3184b8c0fd2bc20b48736c20d6edeaea68
This commit is contained in:
Colin Cross 2018-10-05 11:12:53 -07:00
parent 3f13f07565
commit 0e58dc0176

View file

@ -561,11 +561,13 @@ func buildGoTest(ctx blueprint.ModuleContext, testRoot, testPkgArchive,
Optional: true,
})
var linkDeps []string
libDirFlags := []string{"-L " + testRoot}
testDeps := []string{}
ctx.VisitDepsDepthFirstIf(isGoPackageProducer,
func(module blueprint.Module) {
dep := module.(goPackageProducer)
linkDeps = append(linkDeps, dep.GoPackageTarget())
libDir := dep.GoPkgRoot()
libDirFlags = append(libDirFlags, "-L "+libDir)
testDeps = append(testDeps, dep.GoTestTargets()...)
@ -584,9 +586,10 @@ func buildGoTest(ctx blueprint.ModuleContext, testRoot, testPkgArchive,
})
ctx.Build(pctx, blueprint.BuildParams{
Rule: link,
Outputs: []string{testFile},
Inputs: []string{testArchive},
Rule: link,
Outputs: []string{testFile},
Inputs: []string{testArchive},
Implicits: linkDeps,
Args: map[string]string{
"libDirFlags": strings.Join(libDirFlags, " "),
},