Move config into common and provide helper
Using ctx.Config().(Config) everywhere is a mouthful, and it is
inefficient to do the type assertion. Put the Config interface into
the context, and provide an AConfig() to return the Config already
converted to the right type.
Change-Id: I301a1fd7d2a005580aabca7866a37c5d42ad8c69
diff --git a/common/module.go b/common/module.go
index e61d313..d497076 100644
--- a/common/module.go
+++ b/common/module.go
@@ -20,16 +20,6 @@
"github.com/google/blueprint"
)
-type Config interface {
- CpPreserveSymlinksFlags() string
- SrcDir() string
- IntermediatesDir() string
- Getenv(string) string
- EnvDeps() map[string]string
- DeviceOut() string
- HostOut() string
-}
-
var (
DeviceSharedLibrary = "shared_library"
DeviceStaticLibrary = "static_library"
@@ -44,6 +34,7 @@
Host() bool
Device() bool
Debug() bool
+ AConfig() Config
}
type AndroidBaseContext interface {
@@ -299,7 +290,8 @@
actx := &androidDynamicDependerContext{
DynamicDependerModuleContext: ctx,
androidBaseContextImpl: androidBaseContextImpl{
- arch: a.commonProperties.CompileArch,
+ arch: a.commonProperties.CompileArch,
+ config: ctx.Config().(Config),
},
}
@@ -314,7 +306,8 @@
androidCtx := &androidModuleContext{
ModuleContext: ctx,
androidBaseContextImpl: androidBaseContextImpl{
- arch: a.commonProperties.CompileArch,
+ arch: a.commonProperties.CompileArch,
+ config: ctx.Config().(Config),
},
installDeps: a.computeInstallDeps(ctx),
installFiles: a.installFiles,
@@ -340,8 +333,9 @@
}
type androidBaseContextImpl struct {
- arch Arch
- debug bool
+ arch Arch
+ debug bool
+ config Config
}
type androidModuleContext struct {
@@ -382,10 +376,14 @@
return a.debug
}
+func (a *androidBaseContextImpl) AConfig() Config {
+ return a.config
+}
+
func (a *androidModuleContext) InstallFileName(installPath, name, srcPath string,
deps ...string) string {
- config := a.Config().(Config)
+ config := a.AConfig()
var fullInstallPath string
if a.arch.HostOrDevice.Device() {
// TODO: replace unset with a device name once we have device targeting