Support blueprint_go_binary in PathForModuleSrc

Allow blueprint_go_binary to be used as test data by supporting it in
PathForModuleSrc.

Also make python use GetDirectDepsWithTag instead of VisitDirectDeps
so it doesn't fail on the dependency to a Blueprint (non-Android)
module.

Fixes: 186528269
Test: manual
Change-Id: Ibc1d7caf7bf1fa5db805c3b885a95df4baee0ecf
This commit is contained in:
Colin Cross 2021-05-03 13:35:32 -07:00
parent c424b76f76
commit 0e446159bc
2 changed files with 11 additions and 5 deletions

View File

@ -24,6 +24,7 @@ import (
"strings" "strings"
"github.com/google/blueprint" "github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/pathtools" "github.com/google/blueprint/pathtools"
) )
@ -448,6 +449,12 @@ func getPathsFromModuleDep(ctx ModuleWithDepsPathContext, path, moduleName, tag
return outputFiles, nil return outputFiles, nil
} else if tag != "" { } else if tag != "" {
return nil, fmt.Errorf("path dependency %q is not an output file producing module", path) return nil, fmt.Errorf("path dependency %q is not an output file producing module", path)
} else if goBinary, ok := module.(bootstrap.GoBinaryTool); ok {
if rel, err := filepath.Rel(PathForOutput(ctx).String(), goBinary.InstallPath()); err == nil {
return Paths{PathForOutput(ctx, rel).WithoutRel()}, nil
} else {
return nil, fmt.Errorf("cannot find output path for %q: %w", goBinary.InstallPath(), err)
}
} else if srcProducer, ok := module.(SourceFileProducer); ok { } else if srcProducer, ok := module.(SourceFileProducer); ok {
return srcProducer.Srcs(), nil return srcProducer.Srcs(), nil
} else { } else {

View File

@ -444,11 +444,10 @@ func (p *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
var sharedLibs []string var sharedLibs []string
// if embedded launcher is enabled, we need to collect the shared library depenendencies of the // if embedded launcher is enabled, we need to collect the shared library depenendencies of the
// launcher // launcher
ctx.VisitDirectDeps(func(dep android.Module) { for _, dep := range ctx.GetDirectDepsWithTag(launcherSharedLibTag) {
if ctx.OtherModuleDependencyTag(dep) == launcherSharedLibTag { sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep)) }
}
})
p.installer.setAndroidMkSharedLibs(sharedLibs) p.installer.setAndroidMkSharedLibs(sharedLibs)
// Install the par file from installSource // Install the par file from installSource