Consolidate baseContext, BaseContext, and BaseModuleContext
blueprint.BaseModuleContext is the set of methods available to all module-specific calls (GenerateBuildActions or mutators). The android package split the same functionality across baseContext (nee androidBaseContext), BaseModuleContext, and BaseContext. Consolidate all of them into android.BaseModuleContext. Test: m checkbuild Change-Id: I2d7f5c56fd4424032cb93edff6dc730ff33e4f1e
This commit is contained in:
@@ -85,7 +85,7 @@ func getApiLevelsMap(config Config) map[string]int {
|
|||||||
// * Numeric API levels are simply converted.
|
// * Numeric API levels are simply converted.
|
||||||
// * "minimum" and "current" are not currently handled since the former is
|
// * "minimum" and "current" are not currently handled since the former is
|
||||||
// NDK specific and the latter has inconsistent meaning.
|
// NDK specific and the latter has inconsistent meaning.
|
||||||
func ApiStrToNum(ctx BaseContext, apiLevel string) (int, error) {
|
func ApiStrToNum(ctx BaseModuleContext, apiLevel string) (int, error) {
|
||||||
num, ok := getApiLevelsMap(ctx.Config())[apiLevel]
|
num, ok := getApiLevelsMap(ctx.Config())[apiLevel]
|
||||||
if ok {
|
if ok {
|
||||||
return num, nil
|
return num, nil
|
||||||
|
@@ -27,7 +27,7 @@ import (
|
|||||||
// been applied.
|
// been applied.
|
||||||
type LoadHookContext interface {
|
type LoadHookContext interface {
|
||||||
// TODO: a new context that includes Config() but not Target(), etc.?
|
// TODO: a new context that includes Config() but not Target(), etc.?
|
||||||
BaseContext
|
BaseModuleContext
|
||||||
AppendProperties(...interface{})
|
AppendProperties(...interface{})
|
||||||
PrependProperties(...interface{})
|
PrependProperties(...interface{})
|
||||||
CreateModule(blueprint.ModuleFactory, ...interface{})
|
CreateModule(blueprint.ModuleFactory, ...interface{})
|
||||||
@@ -36,7 +36,7 @@ type LoadHookContext interface {
|
|||||||
// Arch hooks are run after the module has been split into architecture variants, and can be used
|
// Arch hooks are run after the module has been split into architecture variants, and can be used
|
||||||
// to add architecture-specific properties.
|
// to add architecture-specific properties.
|
||||||
type ArchHookContext interface {
|
type ArchHookContext interface {
|
||||||
BaseContext
|
BaseModuleContext
|
||||||
AppendProperties(...interface{})
|
AppendProperties(...interface{})
|
||||||
PrependProperties(...interface{})
|
PrependProperties(...interface{})
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,30 @@ type BuildParams struct {
|
|||||||
|
|
||||||
type ModuleBuildParams BuildParams
|
type ModuleBuildParams BuildParams
|
||||||
|
|
||||||
type baseContext interface {
|
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
|
||||||
|
// a Config instead of an interface{}, plus some extra methods that return Android-specific information
|
||||||
|
// about the current module.
|
||||||
|
type BaseModuleContext interface {
|
||||||
|
ModuleName() string
|
||||||
|
ModuleDir() string
|
||||||
|
ModuleType() string
|
||||||
|
Config() Config
|
||||||
|
|
||||||
|
ContainsProperty(name string) bool
|
||||||
|
Errorf(pos scanner.Position, fmt string, args ...interface{})
|
||||||
|
ModuleErrorf(fmt string, args ...interface{})
|
||||||
|
PropertyErrorf(property, fmt string, args ...interface{})
|
||||||
|
Failed() bool
|
||||||
|
|
||||||
|
// GlobWithDeps returns a list of files that match the specified pattern but do not match any
|
||||||
|
// of the patterns in excludes. It also adds efficient dependencies to rerun the primary
|
||||||
|
// builder whenever a file matching the pattern as added or removed, without rerunning if a
|
||||||
|
// file that does not match the pattern is added to a searched directory.
|
||||||
|
GlobWithDeps(pattern string, excludes []string) ([]string, error)
|
||||||
|
|
||||||
|
Fs() pathtools.FileSystem
|
||||||
|
AddNinjaFileDeps(deps ...string)
|
||||||
|
|
||||||
Target() Target
|
Target() Target
|
||||||
TargetPrimary() bool
|
TargetPrimary() bool
|
||||||
MultiTargets() []Target
|
MultiTargets() []Target
|
||||||
@@ -78,37 +101,12 @@ type baseContext interface {
|
|||||||
DeviceConfig() DeviceConfig
|
DeviceConfig() DeviceConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: use BaseModuleContext instead
|
||||||
type BaseContext interface {
|
type BaseContext interface {
|
||||||
BaseModuleContext
|
BaseModuleContext
|
||||||
baseContext
|
|
||||||
}
|
|
||||||
|
|
||||||
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
|
|
||||||
// a Config instead of an interface{}.
|
|
||||||
type BaseModuleContext interface {
|
|
||||||
ModuleName() string
|
|
||||||
ModuleDir() string
|
|
||||||
ModuleType() string
|
|
||||||
Config() Config
|
|
||||||
|
|
||||||
ContainsProperty(name string) bool
|
|
||||||
Errorf(pos scanner.Position, fmt string, args ...interface{})
|
|
||||||
ModuleErrorf(fmt string, args ...interface{})
|
|
||||||
PropertyErrorf(property, fmt string, args ...interface{})
|
|
||||||
Failed() bool
|
|
||||||
|
|
||||||
// GlobWithDeps returns a list of files that match the specified pattern but do not match any
|
|
||||||
// of the patterns in excludes. It also adds efficient dependencies to rerun the primary
|
|
||||||
// builder whenever a file matching the pattern as added or removed, without rerunning if a
|
|
||||||
// file that does not match the pattern is added to a searched directory.
|
|
||||||
GlobWithDeps(pattern string, excludes []string) ([]string, error)
|
|
||||||
|
|
||||||
Fs() pathtools.FileSystem
|
|
||||||
AddNinjaFileDeps(deps ...string)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModuleContext interface {
|
type ModuleContext interface {
|
||||||
baseContext
|
|
||||||
BaseModuleContext
|
BaseModuleContext
|
||||||
|
|
||||||
// Deprecated: use ModuleContext.Build instead.
|
// Deprecated: use ModuleContext.Build instead.
|
||||||
@@ -826,25 +824,26 @@ func determineModuleKind(m *ModuleBase, ctx blueprint.BaseModuleContext) moduleK
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) baseContextFactory(ctx blueprint.BaseModuleContext) baseContextImpl {
|
func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext {
|
||||||
return baseContextImpl{
|
return baseModuleContext{
|
||||||
target: m.commonProperties.CompileTarget,
|
BaseModuleContext: ctx,
|
||||||
targetPrimary: m.commonProperties.CompilePrimary,
|
target: m.commonProperties.CompileTarget,
|
||||||
multiTargets: m.commonProperties.CompileMultiTargets,
|
targetPrimary: m.commonProperties.CompilePrimary,
|
||||||
kind: determineModuleKind(m, ctx),
|
multiTargets: m.commonProperties.CompileMultiTargets,
|
||||||
config: ctx.Config().(Config),
|
kind: determineModuleKind(m, ctx),
|
||||||
|
config: ctx.Config().(Config),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
||||||
ctx := &moduleContext{
|
ctx := &moduleContext{
|
||||||
module: m.module,
|
module: m.module,
|
||||||
ModuleContext: blueprintCtx,
|
ModuleContext: blueprintCtx,
|
||||||
baseContextImpl: m.baseContextFactory(blueprintCtx),
|
baseModuleContext: m.baseModuleContextFactory(blueprintCtx),
|
||||||
installDeps: m.computeInstallDeps(blueprintCtx),
|
installDeps: m.computeInstallDeps(blueprintCtx),
|
||||||
installFiles: m.installFiles,
|
installFiles: m.installFiles,
|
||||||
missingDeps: blueprintCtx.GetMissingDependencies(),
|
missingDeps: blueprintCtx.GetMissingDependencies(),
|
||||||
variables: make(map[string]string),
|
variables: make(map[string]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.config.captureBuild {
|
if ctx.config.captureBuild {
|
||||||
@@ -917,7 +916,8 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||||||
m.variables = ctx.variables
|
m.variables = ctx.variables
|
||||||
}
|
}
|
||||||
|
|
||||||
type baseContextImpl struct {
|
type baseModuleContext struct {
|
||||||
|
blueprint.BaseModuleContext
|
||||||
target Target
|
target Target
|
||||||
multiTargets []Target
|
multiTargets []Target
|
||||||
targetPrimary bool
|
targetPrimary bool
|
||||||
@@ -928,7 +928,7 @@ type baseContextImpl struct {
|
|||||||
|
|
||||||
type moduleContext struct {
|
type moduleContext struct {
|
||||||
blueprint.ModuleContext
|
blueprint.ModuleContext
|
||||||
baseContextImpl
|
baseModuleContext
|
||||||
installDeps Paths
|
installDeps Paths
|
||||||
installFiles Paths
|
installFiles Paths
|
||||||
checkbuildFiles Paths
|
checkbuildFiles Paths
|
||||||
@@ -1210,82 +1210,82 @@ func (m *moduleContext) FinalModule() Module {
|
|||||||
return m.ModuleContext.FinalModule().(Module)
|
return m.ModuleContext.FinalModule().(Module)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Target() Target {
|
func (b *baseModuleContext) Target() Target {
|
||||||
return b.target
|
return b.target
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) TargetPrimary() bool {
|
func (b *baseModuleContext) TargetPrimary() bool {
|
||||||
return b.targetPrimary
|
return b.targetPrimary
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) MultiTargets() []Target {
|
func (b *baseModuleContext) MultiTargets() []Target {
|
||||||
return b.multiTargets
|
return b.multiTargets
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Arch() Arch {
|
func (b *baseModuleContext) Arch() Arch {
|
||||||
return b.target.Arch
|
return b.target.Arch
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Os() OsType {
|
func (b *baseModuleContext) Os() OsType {
|
||||||
return b.target.Os
|
return b.target.Os
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Host() bool {
|
func (b *baseModuleContext) Host() bool {
|
||||||
return b.target.Os.Class == Host || b.target.Os.Class == HostCross
|
return b.target.Os.Class == Host || b.target.Os.Class == HostCross
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Device() bool {
|
func (b *baseModuleContext) Device() bool {
|
||||||
return b.target.Os.Class == Device
|
return b.target.Os.Class == Device
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Darwin() bool {
|
func (b *baseModuleContext) Darwin() bool {
|
||||||
return b.target.Os == Darwin
|
return b.target.Os == Darwin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Fuchsia() bool {
|
func (b *baseModuleContext) Fuchsia() bool {
|
||||||
return b.target.Os == Fuchsia
|
return b.target.Os == Fuchsia
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Windows() bool {
|
func (b *baseModuleContext) Windows() bool {
|
||||||
return b.target.Os == Windows
|
return b.target.Os == Windows
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Debug() bool {
|
func (b *baseModuleContext) Debug() bool {
|
||||||
return b.debug
|
return b.debug
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) PrimaryArch() bool {
|
func (b *baseModuleContext) PrimaryArch() bool {
|
||||||
if len(b.config.Targets[b.target.Os]) <= 1 {
|
if len(b.config.Targets[b.target.Os]) <= 1 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return b.target.Arch.ArchType == b.config.Targets[b.target.Os][0].Arch.ArchType
|
return b.target.Arch.ArchType == b.config.Targets[b.target.Os][0].Arch.ArchType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) AConfig() Config {
|
func (b *baseModuleContext) AConfig() Config {
|
||||||
return b.config
|
return b.config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) DeviceConfig() DeviceConfig {
|
func (b *baseModuleContext) DeviceConfig() DeviceConfig {
|
||||||
return DeviceConfig{b.config.deviceConfig}
|
return DeviceConfig{b.config.deviceConfig}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) Platform() bool {
|
func (b *baseModuleContext) Platform() bool {
|
||||||
return b.kind == platformModule
|
return b.kind == platformModule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) DeviceSpecific() bool {
|
func (b *baseModuleContext) DeviceSpecific() bool {
|
||||||
return b.kind == deviceSpecificModule
|
return b.kind == deviceSpecificModule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) SocSpecific() bool {
|
func (b *baseModuleContext) SocSpecific() bool {
|
||||||
return b.kind == socSpecificModule
|
return b.kind == socSpecificModule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) ProductSpecific() bool {
|
func (b *baseModuleContext) ProductSpecific() bool {
|
||||||
return b.kind == productSpecificModule
|
return b.kind == productSpecificModule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseContextImpl) ProductServicesSpecific() bool {
|
func (b *baseModuleContext) ProductServicesSpecific() bool {
|
||||||
return b.kind == productServicesSpecificModule
|
return b.kind == productServicesSpecificModule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -114,7 +114,6 @@ type TopDownMutator func(TopDownMutatorContext)
|
|||||||
|
|
||||||
type TopDownMutatorContext interface {
|
type TopDownMutatorContext interface {
|
||||||
BaseModuleContext
|
BaseModuleContext
|
||||||
baseContext
|
|
||||||
|
|
||||||
OtherModuleExists(name string) bool
|
OtherModuleExists(name string) bool
|
||||||
Rename(name string)
|
Rename(name string)
|
||||||
@@ -143,7 +142,7 @@ type TopDownMutatorContext interface {
|
|||||||
|
|
||||||
type topDownMutatorContext struct {
|
type topDownMutatorContext struct {
|
||||||
blueprint.TopDownMutatorContext
|
blueprint.TopDownMutatorContext
|
||||||
baseContextImpl
|
baseModuleContext
|
||||||
walkPath []Module
|
walkPath []Module
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +150,6 @@ type BottomUpMutator func(BottomUpMutatorContext)
|
|||||||
|
|
||||||
type BottomUpMutatorContext interface {
|
type BottomUpMutatorContext interface {
|
||||||
BaseModuleContext
|
BaseModuleContext
|
||||||
baseContext
|
|
||||||
|
|
||||||
OtherModuleExists(name string) bool
|
OtherModuleExists(name string) bool
|
||||||
Rename(name string)
|
Rename(name string)
|
||||||
@@ -170,7 +168,7 @@ type BottomUpMutatorContext interface {
|
|||||||
|
|
||||||
type bottomUpMutatorContext struct {
|
type bottomUpMutatorContext struct {
|
||||||
blueprint.BottomUpMutatorContext
|
blueprint.BottomUpMutatorContext
|
||||||
baseContextImpl
|
baseModuleContext
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle {
|
func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle {
|
||||||
@@ -178,7 +176,7 @@ func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) Mutat
|
|||||||
if a, ok := ctx.Module().(Module); ok {
|
if a, ok := ctx.Module().(Module); ok {
|
||||||
actx := &bottomUpMutatorContext{
|
actx := &bottomUpMutatorContext{
|
||||||
BottomUpMutatorContext: ctx,
|
BottomUpMutatorContext: ctx,
|
||||||
baseContextImpl: a.base().baseContextFactory(ctx),
|
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
||||||
}
|
}
|
||||||
m(actx)
|
m(actx)
|
||||||
}
|
}
|
||||||
@@ -193,7 +191,7 @@ func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) Mutator
|
|||||||
if a, ok := ctx.Module().(Module); ok {
|
if a, ok := ctx.Module().(Module); ok {
|
||||||
actx := &topDownMutatorContext{
|
actx := &topDownMutatorContext{
|
||||||
TopDownMutatorContext: ctx,
|
TopDownMutatorContext: ctx,
|
||||||
baseContextImpl: a.base().baseContextFactory(ctx),
|
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
||||||
}
|
}
|
||||||
m(actx)
|
m(actx)
|
||||||
}
|
}
|
||||||
|
@@ -41,9 +41,7 @@ var _ PathContext = SingletonContext(nil)
|
|||||||
var _ PathContext = ModuleContext(nil)
|
var _ PathContext = ModuleContext(nil)
|
||||||
|
|
||||||
type ModuleInstallPathContext interface {
|
type ModuleInstallPathContext interface {
|
||||||
PathContext
|
BaseModuleContext
|
||||||
|
|
||||||
baseContext
|
|
||||||
|
|
||||||
InstallInData() bool
|
InstallInData() bool
|
||||||
InstallInSanitizerDir() bool
|
InstallInSanitizerDir() bool
|
||||||
|
@@ -200,7 +200,7 @@ func p(in interface{}) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type moduleInstallPathContextImpl struct {
|
type moduleInstallPathContextImpl struct {
|
||||||
baseContextImpl
|
baseModuleContext
|
||||||
|
|
||||||
inData bool
|
inData bool
|
||||||
inSanitizerDir bool
|
inSanitizerDir bool
|
||||||
@@ -212,7 +212,7 @@ func (moduleInstallPathContextImpl) Fs() pathtools.FileSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m moduleInstallPathContextImpl) Config() Config {
|
func (m moduleInstallPathContextImpl) Config() Config {
|
||||||
return m.baseContextImpl.config
|
return m.baseModuleContext.config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (moduleInstallPathContextImpl) AddNinjaFileDeps(deps ...string) {}
|
func (moduleInstallPathContextImpl) AddNinjaFileDeps(deps ...string) {}
|
||||||
@@ -244,7 +244,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "host binary",
|
name: "host binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: hostTarget,
|
target: hostTarget,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -255,7 +255,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "system binary",
|
name: "system binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -265,7 +265,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "vendor binary",
|
name: "vendor binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: socSpecificModule,
|
kind: socSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -276,7 +276,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "odm binary",
|
name: "odm binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: deviceSpecificModule,
|
kind: deviceSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -287,7 +287,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "product binary",
|
name: "product binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productSpecificModule,
|
kind: productSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -298,7 +298,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "product_services binary",
|
name: "product_services binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productServicesSpecificModule,
|
kind: productServicesSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -310,7 +310,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "system native test binary",
|
name: "system native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
@@ -321,7 +321,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "vendor native test binary",
|
name: "vendor native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: socSpecificModule,
|
kind: socSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -333,7 +333,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "odm native test binary",
|
name: "odm native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: deviceSpecificModule,
|
kind: deviceSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -345,7 +345,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "product native test binary",
|
name: "product native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productSpecificModule,
|
kind: productSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -358,7 +358,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "product_services native test binary",
|
name: "product_services native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productServicesSpecificModule,
|
kind: productServicesSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -371,7 +371,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized system binary",
|
name: "sanitized system binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
},
|
},
|
||||||
inSanitizerDir: true,
|
inSanitizerDir: true,
|
||||||
@@ -382,7 +382,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized vendor binary",
|
name: "sanitized vendor binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: socSpecificModule,
|
kind: socSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -394,7 +394,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized odm binary",
|
name: "sanitized odm binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: deviceSpecificModule,
|
kind: deviceSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -406,7 +406,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized product binary",
|
name: "sanitized product binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productSpecificModule,
|
kind: productSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -419,7 +419,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized product_services binary",
|
name: "sanitized product_services binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productServicesSpecificModule,
|
kind: productServicesSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -432,7 +432,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized system native test binary",
|
name: "sanitized system native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
@@ -444,7 +444,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized vendor native test binary",
|
name: "sanitized vendor native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: socSpecificModule,
|
kind: socSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -457,7 +457,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized odm native test binary",
|
name: "sanitized odm native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: deviceSpecificModule,
|
kind: deviceSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -470,7 +470,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized product native test binary",
|
name: "sanitized product native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productSpecificModule,
|
kind: productSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -483,7 +483,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sanitized product_services native test binary",
|
name: "sanitized product_services native test binary",
|
||||||
ctx: &moduleInstallPathContextImpl{
|
ctx: &moduleInstallPathContextImpl{
|
||||||
baseContextImpl: baseContextImpl{
|
baseModuleContext: baseModuleContext{
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productServicesSpecificModule,
|
kind: productServicesSpecificModule,
|
||||||
},
|
},
|
||||||
@@ -497,7 +497,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
tc.ctx.baseContextImpl.config = testConfig
|
tc.ctx.baseModuleContext.config = testConfig
|
||||||
output := PathForModuleInstall(tc.ctx, tc.in...)
|
output := PathForModuleInstall(tc.ctx, tc.in...)
|
||||||
if output.basePath.path != tc.out {
|
if output.basePath.path != tc.out {
|
||||||
t.Errorf("unexpected path:\n got: %q\nwant: %q\n",
|
t.Errorf("unexpected path:\n got: %q\nwant: %q\n",
|
||||||
|
@@ -552,7 +552,7 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *apexBundle) getCertString(ctx android.BaseContext) string {
|
func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
|
||||||
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
|
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
|
||||||
if overridden {
|
if overridden {
|
||||||
return ":" + certificate
|
return ":" + certificate
|
||||||
|
8
cc/cc.go
8
cc/cc.go
@@ -278,7 +278,7 @@ type ModuleContext interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BaseModuleContext interface {
|
type BaseModuleContext interface {
|
||||||
android.BaseContext
|
android.BaseModuleContext
|
||||||
ModuleContextIntf
|
ModuleContextIntf
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,7 +641,7 @@ func installToBootstrap(name string, config android.Config) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type baseModuleContext struct {
|
type baseModuleContext struct {
|
||||||
android.BaseContext
|
android.BaseModuleContext
|
||||||
moduleContextImpl
|
moduleContextImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1040,7 +1040,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) toolchain(ctx android.BaseContext) config.Toolchain {
|
func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
|
||||||
if c.cachedToolchain == nil {
|
if c.cachedToolchain == nil {
|
||||||
c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
|
c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
|
||||||
}
|
}
|
||||||
@@ -1161,7 +1161,7 @@ func (c *Module) deps(ctx DepsContext) Deps {
|
|||||||
|
|
||||||
func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
|
func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
|
||||||
ctx := &baseModuleContext{
|
ctx := &baseModuleContext{
|
||||||
BaseContext: actx,
|
BaseModuleContext: actx,
|
||||||
moduleContextImpl: moduleContextImpl{
|
moduleContextImpl: moduleContextImpl{
|
||||||
mod: c,
|
mod: c,
|
||||||
},
|
},
|
||||||
|
@@ -121,7 +121,7 @@ func intMax(a int, b int) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeNdkApiLevel(ctx android.BaseContext, apiLevel string,
|
func normalizeNdkApiLevel(ctx android.BaseModuleContext, apiLevel string,
|
||||||
arch android.Arch) (string, error) {
|
arch android.Arch) (string, error) {
|
||||||
|
|
||||||
if apiLevel == "current" {
|
if apiLevel == "current" {
|
||||||
@@ -167,7 +167,7 @@ func getFirstGeneratedVersion(firstSupportedVersion string, platformVersion int)
|
|||||||
return strconv.Atoi(firstSupportedVersion)
|
return strconv.Atoi(firstSupportedVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldUseVersionScript(ctx android.BaseContext, stub *stubDecorator) (bool, error) {
|
func shouldUseVersionScript(ctx android.BaseModuleContext, stub *stubDecorator) (bool, error) {
|
||||||
// unversioned_until is normally empty, in which case we should use the version script.
|
// unversioned_until is normally empty, in which case we should use the version script.
|
||||||
if String(stub.properties.Unversioned_until) == "" {
|
if String(stub.properties.Unversioned_until) == "" {
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@@ -482,7 +482,7 @@ func collectAppDeps(ctx android.ModuleContext) ([]jniLib, []Certificate) {
|
|||||||
return jniLibs, certificates
|
return jniLibs, certificates
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) getCertString(ctx android.BaseContext) string {
|
func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string {
|
||||||
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
|
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
|
||||||
if overridden {
|
if overridden {
|
||||||
return ":" + certificate
|
return ":" + certificate
|
||||||
|
@@ -380,8 +380,8 @@ type Dependency interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SdkLibraryDependency interface {
|
type SdkLibraryDependency interface {
|
||||||
SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths
|
SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths
|
||||||
SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths
|
SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
type SrcDependency interface {
|
type SrcDependency interface {
|
||||||
@@ -448,11 +448,11 @@ type jniLib struct {
|
|||||||
target android.Target
|
target android.Target
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) shouldInstrument(ctx android.BaseContext) bool {
|
func (j *Module) shouldInstrument(ctx android.BaseModuleContext) bool {
|
||||||
return j.properties.Instrument && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT")
|
return j.properties.Instrument && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) shouldInstrumentStatic(ctx android.BaseContext) bool {
|
func (j *Module) shouldInstrumentStatic(ctx android.BaseModuleContext) bool {
|
||||||
return j.shouldInstrument(ctx) &&
|
return j.shouldInstrument(ctx) &&
|
||||||
(ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_STATIC") ||
|
(ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_STATIC") ||
|
||||||
ctx.Config().UnbundledBuild())
|
ctx.Config().UnbundledBuild())
|
||||||
|
@@ -46,7 +46,7 @@ type sdkContext interface {
|
|||||||
targetSdkVersion() string
|
targetSdkVersion() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func sdkVersionOrDefault(ctx android.BaseContext, v string) string {
|
func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string {
|
||||||
switch v {
|
switch v {
|
||||||
case "", "current", "system_current", "test_current", "core_current":
|
case "", "current", "system_current", "test_current", "core_current":
|
||||||
return ctx.Config().DefaultAppTargetSdk()
|
return ctx.Config().DefaultAppTargetSdk()
|
||||||
@@ -57,7 +57,7 @@ func sdkVersionOrDefault(ctx android.BaseContext, v string) string {
|
|||||||
|
|
||||||
// Returns a sdk version as a number. For modules targeting an unreleased SDK (meaning it does not yet have a number)
|
// Returns a sdk version as a number. For modules targeting an unreleased SDK (meaning it does not yet have a number)
|
||||||
// it returns android.FutureApiLevel (10000).
|
// it returns android.FutureApiLevel (10000).
|
||||||
func sdkVersionToNumber(ctx android.BaseContext, v string) (int, error) {
|
func sdkVersionToNumber(ctx android.BaseModuleContext, v string) (int, error) {
|
||||||
switch v {
|
switch v {
|
||||||
case "", "current", "test_current", "system_current", "core_current":
|
case "", "current", "test_current", "system_current", "core_current":
|
||||||
return ctx.Config().DefaultAppTargetSdkInt(), nil
|
return ctx.Config().DefaultAppTargetSdkInt(), nil
|
||||||
@@ -71,7 +71,7 @@ func sdkVersionToNumber(ctx android.BaseContext, v string) (int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sdkVersionToNumberAsString(ctx android.BaseContext, v string) (string, error) {
|
func sdkVersionToNumberAsString(ctx android.BaseModuleContext, v string) (string, error) {
|
||||||
n, err := sdkVersionToNumber(ctx, v)
|
n, err := sdkVersionToNumber(ctx, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -79,7 +79,7 @@ func sdkVersionToNumberAsString(ctx android.BaseContext, v string) (string, erro
|
|||||||
return strconv.Itoa(n), nil
|
return strconv.Itoa(n), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
|
func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
||||||
v := sdkContext.sdkVersion()
|
v := sdkContext.sdkVersion()
|
||||||
// For PDK builds, use the latest SDK version instead of "current"
|
// For PDK builds, use the latest SDK version instead of "current"
|
||||||
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
|
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
|
||||||
|
@@ -591,7 +591,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) {
|
|||||||
mctx.CreateModule(android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory), &etcProps)
|
mctx.CreateModule(android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory), &etcProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) PrebuiltJars(ctx android.BaseContext, sdkVersion string) android.Paths {
|
func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
|
||||||
var api, v string
|
var api, v string
|
||||||
if sdkVersion == "" {
|
if sdkVersion == "" {
|
||||||
api = "system"
|
api = "system"
|
||||||
@@ -615,7 +615,7 @@ func (module *SdkLibrary) PrebuiltJars(ctx android.BaseContext, sdkVersion strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// to satisfy SdkLibraryDependency interface
|
// to satisfy SdkLibraryDependency interface
|
||||||
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths {
|
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
|
||||||
// This module is just a wrapper for the stubs.
|
// This module is just a wrapper for the stubs.
|
||||||
if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
return module.PrebuiltJars(ctx, sdkVersion)
|
return module.PrebuiltJars(ctx, sdkVersion)
|
||||||
@@ -631,7 +631,7 @@ func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseContext, sdkVersion stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// to satisfy SdkLibraryDependency interface
|
// to satisfy SdkLibraryDependency interface
|
||||||
func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths {
|
func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
|
||||||
// This module is just a wrapper for the stubs.
|
// This module is just a wrapper for the stubs.
|
||||||
if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
return module.PrebuiltJars(ctx, sdkVersion)
|
return module.PrebuiltJars(ctx, sdkVersion)
|
||||||
@@ -840,13 +840,13 @@ func (module *sdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// to satisfy SdkLibraryDependency interface
|
// to satisfy SdkLibraryDependency interface
|
||||||
func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths {
|
func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
|
||||||
// This module is just a wrapper for the prebuilt stubs.
|
// This module is just a wrapper for the prebuilt stubs.
|
||||||
return module.stubsPath
|
return module.stubsPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// to satisfy SdkLibraryDependency interface
|
// to satisfy SdkLibraryDependency interface
|
||||||
func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths {
|
func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
|
||||||
// This module is just a wrapper for the stubs.
|
// This module is just a wrapper for the stubs.
|
||||||
return module.stubsPath
|
return module.stubsPath
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user