diff options
author | Dan Willemsen <dwillemsen@google.com> | 2017-09-13 16:07:44 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2017-09-14 22:59:41 +0000 |
commit | 8eded0ac865bbe3df12a62afcbce0091320cddf3 (patch) | |
tree | c240c07b5be2beeade358b7ee4ea99174ec90f0c /genrule | |
parent | d6ba0d592c137727d387905c3c16bfc0a705f8c3 (diff) | |
download | build_soong-8eded0ac865bbe3df12a62afcbce0091320cddf3.tar.gz build_soong-8eded0ac865bbe3df12a62afcbce0091320cddf3.tar.bz2 build_soong-8eded0ac865bbe3df12a62afcbce0091320cddf3.zip |
Support using blueprint_go_binary as tools in genrules
Test: m
Test: Add genrule using go tool; m
Change-Id: I9a85348b6cf41f2cdb7684f787553c07de220d67
Diffstat (limited to 'genrule')
-rw-r--r-- | genrule/genrule.go | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/genrule/genrule.go b/genrule/genrule.go index 921a64e0..f390f813 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -20,6 +20,7 @@ import ( "strings" "github.com/google/blueprint" + "github.com/google/blueprint/bootstrap" "android/soong/android" "android/soong/shared" @@ -158,21 +159,31 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) { // 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)) |