Wrap PackageContext and SingletonContext
Wrap blueprint.PackageContext so that the *Func methods can provide
an android.Config instead of an interface{}. The modified signatures
means that every method in ModuleContext and SingletonContext
that takes a blueprint.PackageContext now needs to be wrapped to
take an android.PackageContext.
SingletonContext wasn't previously wrapped at all, but as long
as it is, wrap everything like ModuleContext does. This requires
updating every Singleton to use the android-specific methods.
Test: builds, all Soong tests pass
Change-Id: I4f22085ebca7def6c5cde49e8210b59d994ba625
diff --git a/android/androidmk.go b/android/androidmk.go
index 19d5ea6..aff43fa 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -53,13 +53,13 @@
type AndroidMkExtraFunc func(w io.Writer, outputFile Path)
-func AndroidMkSingleton() blueprint.Singleton {
+func AndroidMkSingleton() Singleton {
return &androidMkSingleton{}
}
type androidMkSingleton struct{}
-func (c *androidMkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
+func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
config := ctx.Config().(Config)
if !config.EmbeddedInMake() {
@@ -68,10 +68,8 @@
var androidMkModulesList []Module
- ctx.VisitAllModules(func(module blueprint.Module) {
- if amod, ok := module.(Module); ok {
- androidMkModulesList = append(androidMkModulesList, amod)
- }
+ ctx.VisitAllModules(func(module Module) {
+ androidMkModulesList = append(androidMkModulesList, module)
})
sort.Sort(AndroidModulesByName{androidMkModulesList, ctx})
@@ -86,14 +84,13 @@
ctx.Errorf(err.Error())
}
- ctx.Build(pctx, blueprint.BuildParams{
- Rule: blueprint.Phony,
- Outputs: []string{transMk.String()},
- Optional: true,
+ ctx.Build(pctx, BuildParams{
+ Rule: blueprint.Phony,
+ Output: transMk,
})
}
-func translateAndroidMk(ctx blueprint.SingletonContext, mkFile string, mods []Module) error {
+func translateAndroidMk(ctx SingletonContext, mkFile string, mods []Module) error {
buf := &bytes.Buffer{}
fmt.Fprintln(buf, "LOCAL_MODULE_MAKEFILE := $(lastword $(MAKEFILE_LIST))")
@@ -145,7 +142,7 @@
return ioutil.WriteFile(mkFile, buf.Bytes(), 0666)
}
-func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod blueprint.Module) error {
+func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.Module) error {
provider, ok := mod.(AndroidMkDataProvider)
if !ok {
return nil