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
This commit is contained in:
Colin Cross
2017-11-28 17:34:01 -08:00
parent f2a56f0e0d
commit 0875c52de7
21 changed files with 479 additions and 243 deletions

View File

@@ -23,8 +23,6 @@ import (
"path"
"path/filepath"
"strings"
"github.com/google/blueprint"
)
// This singleton generates CMakeLists.txt files. It does so for each blueprint Android.bp resulting in a cc.Module
@@ -35,7 +33,7 @@ func init() {
android.RegisterSingletonType("cmakelists_generator", cMakeListsGeneratorSingleton)
}
func cMakeListsGeneratorSingleton() blueprint.Singleton {
func cMakeListsGeneratorSingleton() android.Singleton {
return &cmakelistsGeneratorSingleton{}
}
@@ -57,14 +55,14 @@ const (
// This is done to ease investigating bug reports.
var outputDebugInfo = false
func (c *cmakelistsGeneratorSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
func (c *cmakelistsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonContext) {
if getEnvVariable(envVariableGenerateCMakeLists, ctx) != envVariableTrue {
return
}
outputDebugInfo = (getEnvVariable(envVariableGenerateDebugInfo, ctx) == envVariableTrue)
ctx.VisitAllModules(func(module blueprint.Module) {
ctx.VisitAllModules(func(module android.Module) {
if ccModule, ok := module.(*Module); ok {
if compiledModule, ok := ccModule.compiler.(CompiledInterface); ok {
generateCLionProject(compiledModule, ctx, ccModule)
@@ -81,7 +79,7 @@ func (c *cmakelistsGeneratorSingleton) GenerateBuildActions(ctx blueprint.Single
return
}
func getEnvVariable(name string, ctx blueprint.SingletonContext) string {
func getEnvVariable(name string, ctx android.SingletonContext) string {
// Using android.Config.Getenv instead of os.getEnv to guarantee soong will
// re-run in case this environment variable changes.
return ctx.Config().(android.Config).Getenv(name)
@@ -116,7 +114,7 @@ func linkAggregateCMakeListsFiles(path string, info os.FileInfo, err error) erro
return nil
}
func generateCLionProject(compiledModule CompiledInterface, ctx blueprint.SingletonContext, ccModule *Module) {
func generateCLionProject(compiledModule CompiledInterface, ctx android.SingletonContext, ccModule *Module) {
srcs := compiledModule.Srcs()
if len(srcs) == 0 {
return
@@ -287,7 +285,7 @@ func categorizeParameter(parameter string) parameterType {
return flag
}
func parseCompilerParameters(params []string, ctx blueprint.SingletonContext, f *os.File) compilerParameters {
func parseCompilerParameters(params []string, ctx android.SingletonContext, f *os.File) compilerParameters {
var compilerParameters = makeCompilerParameters()
for i, str := range params {
@@ -388,7 +386,7 @@ func concatenateParams(c1 *compilerParameters, c2 compilerParameters) {
c1.flags = append(c1.flags, c2.flags...)
}
func evalVariable(ctx blueprint.SingletonContext, str string) (string, error) {
func evalVariable(ctx android.SingletonContext, str string) (string, error) {
evaluated, err := ctx.Eval(pctx, str)
if err == nil {
return evaluated, nil
@@ -396,7 +394,7 @@ func evalVariable(ctx blueprint.SingletonContext, str string) (string, error) {
return "", err
}
func getCMakeListsForModule(module *Module, ctx blueprint.SingletonContext) string {
func getCMakeListsForModule(module *Module, ctx android.SingletonContext) string {
return filepath.Join(getAndroidSrcRootDirectory(ctx),
cLionOutputProjectsDirectory,
path.Dir(ctx.BlueprintFile(module)),
@@ -406,7 +404,7 @@ func getCMakeListsForModule(module *Module, ctx blueprint.SingletonContext) stri
cMakeListsFilename)
}
func getAndroidSrcRootDirectory(ctx blueprint.SingletonContext) string {
func getAndroidSrcRootDirectory(ctx android.SingletonContext) string {
srcPath, _ := filepath.Abs(android.PathForSource(ctx).String())
return srcPath
}