summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2018-09-28 10:19:18 -0700
committer Colin Cross <ccross@android.com> 2018-09-28 10:25:45 -0700
commit2465c3d99833988c726a145896bf180f304de18b (patch)
treeae73e795f34c6d31207b98a79acf78cbbd7daee5
parentf25112a70f385261b62bc6c5821518c2659ac1b6 (diff)
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
-rw-r--r--android/androidmk.go36
-rw-r--r--android/module.go10
-rw-r--r--android/singleton.go5
3 files changed, 38 insertions, 13 deletions
diff --git a/android/androidmk.go b/android/androidmk.go
index 44c266ad3..5df4a8560 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -25,6 +25,7 @@ import (
"strings"
"github.com/google/blueprint"
+ "github.com/google/blueprint/bootstrap"
)
func init() {
@@ -64,13 +65,13 @@ func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
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 (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
})
}
-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 @@ func translateAndroidMk(ctx SingletonContext, mkFile string, mods []Module) erro
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 @@ func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.M
}
}()
- 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()
diff --git a/android/module.go b/android/module.go
index 4dc4e9c32..92b11ed0d 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1527,16 +1527,16 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
}
}
-type AndroidModulesByName struct {
- slice []Module
+type ModulesByName struct {
+ slice []blueprint.Module
ctx interface {
ModuleName(blueprint.Module) string
ModuleSubDir(blueprint.Module) string
}
}
-func (s AndroidModulesByName) Len() int { return len(s.slice) }
-func (s AndroidModulesByName) Less(i, j int) bool {
+func (s ModulesByName) Len() int { return len(s.slice) }
+func (s ModulesByName) Less(i, j int) bool {
mi, mj := s.slice[i], s.slice[j]
ni, nj := s.ctx.ModuleName(mi), s.ctx.ModuleName(mj)
@@ -1546,7 +1546,7 @@ func (s AndroidModulesByName) Less(i, j int) bool {
return s.ctx.ModuleSubDir(mi) < s.ctx.ModuleSubDir(mj)
}
}
-func (s AndroidModulesByName) Swap(i, j int) { s.slice[i], s.slice[j] = s.slice[j], s.slice[i] }
+func (s ModulesByName) Swap(i, j int) { s.slice[i], s.slice[j] = s.slice[j], s.slice[i] }
// Collect information for opening IDE project files in java/jdeps.go.
type IDEInfo interface {
diff --git a/android/singleton.go b/android/singleton.go
index fa1efdc0f..f926435b1 100644
--- a/android/singleton.go
+++ b/android/singleton.go
@@ -48,6 +48,7 @@ type SingletonContext interface {
// are expanded in the scope of the PackageContext.
Eval(pctx PackageContext, ninjaStr string) (string, error)
+ VisitAllModulesBlueprint(visit func(blueprint.Module))
VisitAllModules(visit func(Module))
VisitAllModulesIf(pred func(Module) bool, visit func(Module))
// Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
@@ -138,6 +139,10 @@ func predAdaptor(pred func(Module) bool) func(blueprint.Module) bool {
}
}
+func (s singletonContextAdaptor) VisitAllModulesBlueprint(visit func(blueprint.Module)) {
+ s.SingletonContext.VisitAllModules(visit)
+}
+
func (s singletonContextAdaptor) VisitAllModules(visit func(Module)) {
s.SingletonContext.VisitAllModules(visitAdaptor(visit))
}