Add phony targets for go binary modules

Add custom handling to androidmk.go for the bootstrap.GoBinaryTool
interface in order to create .PHONY targets for each tool written
in go.

Bug: 64539926
Test: m checkbuild
Test: m androidmk
Test: m multiproduct_kati
Change-Id: Ic65faa27a6ee4dfbd54ed6d208091db7c1d657a2
diff --git a/android/androidmk.go b/android/androidmk.go
index 44c266a..5df4a85 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -25,6 +25,7 @@
 	"strings"
 
 	"github.com/google/blueprint"
+	"github.com/google/blueprint/bootstrap"
 )
 
 func init() {
@@ -64,13 +65,13 @@
 		return
 	}
 
-	var androidMkModulesList []Module
+	var androidMkModulesList []blueprint.Module
 
-	ctx.VisitAllModules(func(module Module) {
+	ctx.VisitAllModulesBlueprint(func(module blueprint.Module) {
 		androidMkModulesList = append(androidMkModulesList, module)
 	})
 
-	sort.Sort(AndroidModulesByName{androidMkModulesList, ctx})
+	sort.Sort(ModulesByName{androidMkModulesList, ctx})
 
 	transMk := PathForOutput(ctx, "Android"+String(ctx.Config().productVariables.Make_suffix)+".mk")
 	if ctx.Failed() {
@@ -88,7 +89,7 @@
 	})
 }
 
-func translateAndroidMk(ctx SingletonContext, mkFile string, mods []Module) error {
+func translateAndroidMk(ctx SingletonContext, mkFile string, mods []blueprint.Module) error {
 	buf := &bytes.Buffer{}
 
 	fmt.Fprintln(buf, "LOCAL_MODULE_MAKEFILE := $(lastword $(MAKEFILE_LIST))")
@@ -101,8 +102,8 @@
 			return err
 		}
 
-		if ctx.PrimaryModule(mod) == mod {
-			type_stats[ctx.ModuleType(mod)] += 1
+		if amod, ok := mod.(Module); ok && ctx.PrimaryModule(amod) == amod {
+			type_stats[ctx.ModuleType(amod)] += 1
 		}
 	}
 
@@ -148,10 +149,29 @@
 		}
 	}()
 
-	provider, ok := mod.(AndroidMkDataProvider)
-	if !ok {
+	switch x := mod.(type) {
+	case AndroidMkDataProvider:
+		return translateAndroidModule(ctx, w, mod, x)
+	case bootstrap.GoBinaryTool:
+		return translateGoBinaryModule(ctx, w, mod, x)
+	default:
 		return nil
 	}
+}
+
+func translateGoBinaryModule(ctx SingletonContext, w io.Writer, mod blueprint.Module,
+	goBinary bootstrap.GoBinaryTool) error {
+
+	name := ctx.ModuleName(mod)
+	fmt.Fprintln(w, ".PHONY:", name)
+	fmt.Fprintln(w, name+":", goBinary.InstallPath())
+	fmt.Fprintln(w, "")
+
+	return nil
+}
+
+func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Module,
+	provider AndroidMkDataProvider) error {
 
 	name := provider.BaseModuleName()
 	amod := mod.(Module).base()