Support using blueprint_go_binary as tools in genrules
Test: m
Test: Add genrule using go tool; m
Change-Id: I9a85348b6cf41f2cdb7684f787553c07de220d67
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 921a64e..f390f81 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -20,6 +20,7 @@
"strings"
"github.com/google/blueprint"
+ "github.com/google/blueprint/bootstrap"
"android/soong/android"
"android/soong/shared"
@@ -158,21 +159,31 @@
// Nothing to do
case hostToolDepTag:
tool := ctx.OtherModuleName(module)
+ var path android.OptionalPath
if t, ok := module.(HostToolProvider); ok {
- p := t.HostToolPath()
- if p.Valid() {
- g.deps = append(g.deps, p.Path())
- if _, exists := tools[tool]; !exists {
- tools[tool] = p.Path()
- } else {
- ctx.ModuleErrorf("multiple tools for %q, %q and %q", tool, tools[tool], p.Path().String())
- }
+ path = t.HostToolPath()
+ } else if t, ok := module.(bootstrap.GoBinaryTool); ok {
+ if s, err := filepath.Rel(android.PathForOutput(ctx).String(), t.InstallPath()); err == nil {
+ path = android.OptionalPathForPath(android.PathForOutput(ctx, s))
} else {
- ctx.ModuleErrorf("host tool %q missing output file", tool)
+ ctx.ModuleErrorf("cannot find path for %q: %v", tool, err)
+ break
}
} else {
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:
ctx.ModuleErrorf("unknown dependency on %q", ctx.OtherModuleName(module))