Support using blueprint_go_binary as tools in genrules

Test: m
Test: Add genrule using go tool; m
Change-Id: I9a85348b6cf41f2cdb7684f787553c07de220d67
This commit is contained in:
Dan Willemsen
2017-09-13 16:07:44 -07:00
parent d6ba0d592c
commit 8eded0ac86

View File

@@ -20,6 +20,7 @@ import (
"strings" "strings"
"github.com/google/blueprint" "github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"android/soong/android" "android/soong/android"
"android/soong/shared" "android/soong/shared"
@@ -158,21 +159,31 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Nothing to do // Nothing to do
case hostToolDepTag: case hostToolDepTag:
tool := ctx.OtherModuleName(module) tool := ctx.OtherModuleName(module)
var path android.OptionalPath
if t, ok := module.(HostToolProvider); ok { if t, ok := module.(HostToolProvider); ok {
p := t.HostToolPath() path = t.HostToolPath()
if p.Valid() { } else if t, ok := module.(bootstrap.GoBinaryTool); ok {
g.deps = append(g.deps, p.Path()) if s, err := filepath.Rel(android.PathForOutput(ctx).String(), t.InstallPath()); err == nil {
if _, exists := tools[tool]; !exists { path = android.OptionalPathForPath(android.PathForOutput(ctx, s))
tools[tool] = p.Path()
} else { } else {
ctx.ModuleErrorf("multiple tools for %q, %q and %q", tool, tools[tool], p.Path().String()) ctx.ModuleErrorf("cannot find path for %q: %v", tool, err)
} break
} else {
ctx.ModuleErrorf("host tool %q missing output file", tool)
} }
} else { } else {
ctx.ModuleErrorf("%q is not a host tool provider", tool) ctx.ModuleErrorf("%q is not a host tool provider", tool)
break
}
if path.Valid() {
g.deps = append(g.deps, path.Path())
if _, exists := tools[tool]; !exists {
tools[tool] = path.Path()
} else {
ctx.ModuleErrorf("multiple tools for %q, %q and %q", tool, tools[tool], path.Path().String())
}
} else {
ctx.ModuleErrorf("host tool %q missing output file", tool)
} }
default: default:
ctx.ModuleErrorf("unknown dependency on %q", ctx.OtherModuleName(module)) ctx.ModuleErrorf("unknown dependency on %q", ctx.OtherModuleName(module))