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
This commit is contained in:
@@ -20,16 +20,6 @@ import (
|
||||
"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 @@ type androidBaseContext interface {
|
||||
Host() bool
|
||||
Device() bool
|
||||
Debug() bool
|
||||
AConfig() Config
|
||||
}
|
||||
|
||||
type AndroidBaseContext interface {
|
||||
@@ -299,7 +290,8 @@ func (a *AndroidModuleBase) DynamicDependencies(ctx blueprint.DynamicDependerMod
|
||||
actx := &androidDynamicDependerContext{
|
||||
DynamicDependerModuleContext: ctx,
|
||||
androidBaseContextImpl: androidBaseContextImpl{
|
||||
arch: a.commonProperties.CompileArch,
|
||||
arch: a.commonProperties.CompileArch,
|
||||
config: ctx.Config().(Config),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -314,7 +306,8 @@ func (a *AndroidModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
||||
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 @@ func (a *AndroidModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
||||
}
|
||||
|
||||
type androidBaseContextImpl struct {
|
||||
arch Arch
|
||||
debug bool
|
||||
arch Arch
|
||||
debug bool
|
||||
config Config
|
||||
}
|
||||
|
||||
type androidModuleContext struct {
|
||||
@@ -382,10 +376,14 @@ func (a *androidBaseContextImpl) Debug() bool {
|
||||
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
|
||||
|
Reference in New Issue
Block a user