Add EarlyModuleContext for LoadHookContext
Make LoadHookContext embed a new EarlyModuleContext instead of BaseModuleContext to reduce its API surface in preparation for moving it to run during parsing instead of mutators. Test: m checkbuild Change-Id: I1cd3ff3b636e7e24991a9184d7521903473e505a
This commit is contained in:
@@ -26,8 +26,8 @@ import (
|
|||||||
// before the module has been split into architecture variants, and before defaults modules have
|
// before the module has been split into architecture variants, and before defaults modules have
|
||||||
// been applied.
|
// been applied.
|
||||||
type LoadHookContext interface {
|
type LoadHookContext interface {
|
||||||
// TODO: a new context that includes Config() but not Target(), etc.?
|
EarlyModuleContext
|
||||||
BaseModuleContext
|
|
||||||
AppendProperties(...interface{})
|
AppendProperties(...interface{})
|
||||||
PrependProperties(...interface{})
|
PrependProperties(...interface{})
|
||||||
CreateModule(ModuleFactory, ...interface{}) Module
|
CreateModule(ModuleFactory, ...interface{}) Module
|
||||||
|
@@ -55,16 +55,51 @@ type BuildParams struct {
|
|||||||
|
|
||||||
type ModuleBuildParams BuildParams
|
type ModuleBuildParams BuildParams
|
||||||
|
|
||||||
|
// EarlyModuleContext provides methods that can be called early, as soon as the properties have
|
||||||
|
// been parsed into the module and before any mutators have run.
|
||||||
|
type EarlyModuleContext interface {
|
||||||
|
Module() Module
|
||||||
|
ModuleName() string
|
||||||
|
ModuleDir() string
|
||||||
|
ModuleType() string
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
AddNinjaFileDeps(deps ...string)
|
||||||
|
|
||||||
|
DeviceSpecific() bool
|
||||||
|
SocSpecific() bool
|
||||||
|
ProductSpecific() bool
|
||||||
|
SystemExtSpecific() bool
|
||||||
|
Platform() bool
|
||||||
|
|
||||||
|
Config() Config
|
||||||
|
DeviceConfig() DeviceConfig
|
||||||
|
|
||||||
|
// Deprecated: use Config()
|
||||||
|
AConfig() Config
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
Glob(globPattern string, excludes []string) Paths
|
||||||
|
GlobFiles(globPattern string, excludes []string) Paths
|
||||||
|
Fs() pathtools.FileSystem
|
||||||
|
}
|
||||||
|
|
||||||
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
|
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
|
||||||
// a Config instead of an interface{}, and some methods have been wrapped to use an android.Module
|
// a Config instead of an interface{}, and some methods have been wrapped to use an android.Module
|
||||||
// instead of a blueprint.Module, plus some extra methods that return Android-specific information
|
// instead of a blueprint.Module, plus some extra methods that return Android-specific information
|
||||||
// about the current module.
|
// about the current module.
|
||||||
type BaseModuleContext interface {
|
type BaseModuleContext interface {
|
||||||
Module() Module
|
EarlyModuleContext
|
||||||
ModuleName() string
|
|
||||||
ModuleDir() string
|
|
||||||
ModuleType() string
|
|
||||||
Config() Config
|
|
||||||
|
|
||||||
OtherModuleName(m blueprint.Module) string
|
OtherModuleName(m blueprint.Module) string
|
||||||
OtherModuleDir(m blueprint.Module) string
|
OtherModuleDir(m blueprint.Module) string
|
||||||
@@ -91,24 +126,6 @@ type BaseModuleContext interface {
|
|||||||
// and returns a top-down dependency path from a start module to current child module.
|
// and returns a top-down dependency path from a start module to current child module.
|
||||||
GetWalkPath() []Module
|
GetWalkPath() []Module
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
Glob(globPattern string, excludes []string) Paths
|
|
||||||
GlobFiles(globPattern string, excludes []string) Paths
|
|
||||||
|
|
||||||
Fs() pathtools.FileSystem
|
|
||||||
AddNinjaFileDeps(deps ...string)
|
|
||||||
|
|
||||||
AddMissingDependencies(missingDeps []string)
|
AddMissingDependencies(missingDeps []string)
|
||||||
|
|
||||||
Target() Target
|
Target() Target
|
||||||
@@ -123,18 +140,11 @@ type BaseModuleContext interface {
|
|||||||
Windows() bool
|
Windows() bool
|
||||||
Debug() bool
|
Debug() bool
|
||||||
PrimaryArch() bool
|
PrimaryArch() bool
|
||||||
Platform() bool
|
|
||||||
DeviceSpecific() bool
|
|
||||||
SocSpecific() bool
|
|
||||||
ProductSpecific() bool
|
|
||||||
SystemExtSpecific() bool
|
|
||||||
AConfig() Config
|
|
||||||
DeviceConfig() DeviceConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use BaseModuleContext instead
|
// Deprecated: use EarlyModuleContext instead
|
||||||
type BaseContext interface {
|
type BaseContext interface {
|
||||||
BaseModuleContext
|
EarlyModuleContext
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModuleContext interface {
|
type ModuleContext interface {
|
||||||
@@ -1002,18 +1012,25 @@ func determineModuleKind(m *ModuleBase, ctx blueprint.BaseModuleContext) moduleK
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext {
|
func (m *ModuleBase) earlyModuleContextFactory(ctx blueprint.BaseModuleContext) earlyModuleContext {
|
||||||
return baseModuleContext{
|
return earlyModuleContext{
|
||||||
BaseModuleContext: ctx,
|
BaseModuleContext: ctx,
|
||||||
os: m.commonProperties.CompileOS,
|
|
||||||
target: m.commonProperties.CompileTarget,
|
|
||||||
targetPrimary: m.commonProperties.CompilePrimary,
|
|
||||||
multiTargets: m.commonProperties.CompileMultiTargets,
|
|
||||||
kind: determineModuleKind(m, ctx),
|
kind: determineModuleKind(m, ctx),
|
||||||
config: ctx.Config().(Config),
|
config: ctx.Config().(Config),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext {
|
||||||
|
return baseModuleContext{
|
||||||
|
bp: ctx,
|
||||||
|
earlyModuleContext: m.earlyModuleContextFactory(ctx),
|
||||||
|
os: m.commonProperties.CompileOS,
|
||||||
|
target: m.commonProperties.CompileTarget,
|
||||||
|
targetPrimary: m.commonProperties.CompilePrimary,
|
||||||
|
multiTargets: m.commonProperties.CompileMultiTargets,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
||||||
ctx := &moduleContext{
|
ctx := &moduleContext{
|
||||||
module: m.module,
|
module: m.module,
|
||||||
@@ -1116,21 +1133,95 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||||||
m.variables = ctx.variables
|
m.variables = ctx.variables
|
||||||
}
|
}
|
||||||
|
|
||||||
type baseModuleContext struct {
|
type earlyModuleContext struct {
|
||||||
blueprint.BaseModuleContext
|
blueprint.BaseModuleContext
|
||||||
|
|
||||||
|
kind moduleKind
|
||||||
|
config Config
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) Glob(globPattern string, excludes []string) Paths {
|
||||||
|
ret, err := e.GlobWithDeps(globPattern, excludes)
|
||||||
|
if err != nil {
|
||||||
|
e.ModuleErrorf("glob: %s", err.Error())
|
||||||
|
}
|
||||||
|
return pathsForModuleSrcFromFullPath(e, ret, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
||||||
|
ret, err := e.GlobWithDeps(globPattern, excludes)
|
||||||
|
if err != nil {
|
||||||
|
e.ModuleErrorf("glob: %s", err.Error())
|
||||||
|
}
|
||||||
|
return pathsForModuleSrcFromFullPath(e, ret, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) Module() Module {
|
||||||
|
module, _ := e.BaseModuleContext.Module().(Module)
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) Config() Config {
|
||||||
|
return e.BaseModuleContext.Config().(Config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) AConfig() Config {
|
||||||
|
return e.config
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) DeviceConfig() DeviceConfig {
|
||||||
|
return DeviceConfig{e.config.deviceConfig}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) Platform() bool {
|
||||||
|
return e.kind == platformModule
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) DeviceSpecific() bool {
|
||||||
|
return e.kind == deviceSpecificModule
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) SocSpecific() bool {
|
||||||
|
return e.kind == socSpecificModule
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) ProductSpecific() bool {
|
||||||
|
return e.kind == productSpecificModule
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *earlyModuleContext) SystemExtSpecific() bool {
|
||||||
|
return e.kind == systemExtSpecificModule
|
||||||
|
}
|
||||||
|
|
||||||
|
type baseModuleContext struct {
|
||||||
|
bp blueprint.BaseModuleContext
|
||||||
|
earlyModuleContext
|
||||||
os OsType
|
os OsType
|
||||||
target Target
|
target Target
|
||||||
multiTargets []Target
|
multiTargets []Target
|
||||||
targetPrimary bool
|
targetPrimary bool
|
||||||
debug bool
|
debug bool
|
||||||
kind moduleKind
|
|
||||||
config Config
|
|
||||||
|
|
||||||
walkPath []Module
|
walkPath []Module
|
||||||
|
|
||||||
strictVisitDeps bool // If true, enforce that all dependencies are enabled
|
strictVisitDeps bool // If true, enforce that all dependencies are enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *baseModuleContext) OtherModuleName(m blueprint.Module) string { return b.bp.OtherModuleName(m) }
|
||||||
|
func (b *baseModuleContext) OtherModuleDir(m blueprint.Module) string { return b.bp.OtherModuleDir(m) }
|
||||||
|
func (b *baseModuleContext) OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) {
|
||||||
|
b.bp.OtherModuleErrorf(m, fmt, args)
|
||||||
|
}
|
||||||
|
func (b *baseModuleContext) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag {
|
||||||
|
return b.bp.OtherModuleDependencyTag(m)
|
||||||
|
}
|
||||||
|
func (b *baseModuleContext) OtherModuleExists(name string) bool { return b.bp.OtherModuleExists(name) }
|
||||||
|
func (b *baseModuleContext) OtherModuleType(m blueprint.Module) string { return b.bp.OtherModuleType(m) }
|
||||||
|
|
||||||
|
func (b *baseModuleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module {
|
||||||
|
return b.bp.GetDirectDepWithTag(name, tag)
|
||||||
|
}
|
||||||
|
|
||||||
type moduleContext struct {
|
type moduleContext struct {
|
||||||
bp blueprint.ModuleContext
|
bp blueprint.ModuleContext
|
||||||
baseModuleContext
|
baseModuleContext
|
||||||
@@ -1245,16 +1336,6 @@ func (m *moduleContext) Build(pctx PackageContext, params BuildParams) {
|
|||||||
|
|
||||||
m.bp.Build(pctx.PackageContext, convertBuildParams(params))
|
m.bp.Build(pctx.PackageContext, convertBuildParams(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) Module() Module {
|
|
||||||
module, _ := b.BaseModuleContext.Module().(Module)
|
|
||||||
return module
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *baseModuleContext) Config() Config {
|
|
||||||
return b.BaseModuleContext.Config().(Config)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *moduleContext) GetMissingDependencies() []string {
|
func (m *moduleContext) GetMissingDependencies() []string {
|
||||||
var missingDeps []string
|
var missingDeps []string
|
||||||
missingDeps = append(missingDeps, m.Module().base().commonProperties.MissingDeps...)
|
missingDeps = append(missingDeps, m.Module().base().commonProperties.MissingDeps...)
|
||||||
@@ -1302,7 +1383,7 @@ func (b *baseModuleContext) getDirectDepInternal(name string, tag blueprint.Depe
|
|||||||
var deps []dep
|
var deps []dep
|
||||||
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
||||||
if aModule, _ := module.(Module); aModule != nil && aModule.base().BaseModuleName() == name {
|
if aModule, _ := module.(Module); aModule != nil && aModule.base().BaseModuleName() == name {
|
||||||
returnedTag := b.BaseModuleContext.OtherModuleDependencyTag(aModule)
|
returnedTag := b.bp.OtherModuleDependencyTag(aModule)
|
||||||
if tag == nil || returnedTag == tag {
|
if tag == nil || returnedTag == tag {
|
||||||
deps = append(deps, dep{aModule, returnedTag})
|
deps = append(deps, dep{aModule, returnedTag})
|
||||||
}
|
}
|
||||||
@@ -1322,7 +1403,7 @@ func (b *baseModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []
|
|||||||
var deps []Module
|
var deps []Module
|
||||||
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
||||||
if aModule, _ := module.(Module); aModule != nil {
|
if aModule, _ := module.(Module); aModule != nil {
|
||||||
if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
if b.bp.OtherModuleDependencyTag(aModule) == tag {
|
||||||
deps = append(deps, aModule)
|
deps = append(deps, aModule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1340,11 +1421,11 @@ func (b *baseModuleContext) GetDirectDep(name string) (blueprint.Module, bluepri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
||||||
b.BaseModuleContext.VisitDirectDeps(visit)
|
b.bp.VisitDirectDeps(visit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
||||||
b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
||||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
visit(aModule)
|
visit(aModule)
|
||||||
}
|
}
|
||||||
@@ -1352,9 +1433,9 @@ func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
||||||
b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
||||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
if b.bp.OtherModuleDependencyTag(aModule) == tag {
|
||||||
visit(aModule)
|
visit(aModule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1362,7 +1443,7 @@ func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
||||||
b.BaseModuleContext.VisitDirectDepsIf(
|
b.bp.VisitDirectDepsIf(
|
||||||
// pred
|
// pred
|
||||||
func(module blueprint.Module) bool {
|
func(module blueprint.Module) bool {
|
||||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
@@ -1378,7 +1459,7 @@ func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
||||||
b.BaseModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
|
b.bp.VisitDepsDepthFirst(func(module blueprint.Module) {
|
||||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
visit(aModule)
|
visit(aModule)
|
||||||
}
|
}
|
||||||
@@ -1386,7 +1467,7 @@ func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
||||||
b.BaseModuleContext.VisitDepsDepthFirstIf(
|
b.bp.VisitDepsDepthFirstIf(
|
||||||
// pred
|
// pred
|
||||||
func(module blueprint.Module) bool {
|
func(module blueprint.Module) bool {
|
||||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
@@ -1402,12 +1483,12 @@ func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
|
func (b *baseModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
|
||||||
b.BaseModuleContext.WalkDeps(visit)
|
b.bp.WalkDeps(visit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) {
|
func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) {
|
||||||
b.walkPath = []Module{b.Module()}
|
b.walkPath = []Module{b.Module()}
|
||||||
b.BaseModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
|
b.bp.WalkDeps(func(child, parent blueprint.Module) bool {
|
||||||
childAndroidModule, _ := child.(Module)
|
childAndroidModule, _ := child.(Module)
|
||||||
parentAndroidModule, _ := parent.(Module)
|
parentAndroidModule, _ := parent.(Module)
|
||||||
if childAndroidModule != nil && parentAndroidModule != nil {
|
if childAndroidModule != nil && parentAndroidModule != nil {
|
||||||
@@ -1496,34 +1577,6 @@ func (b *baseModuleContext) PrimaryArch() bool {
|
|||||||
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 *baseModuleContext) AConfig() Config {
|
|
||||||
return b.config
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *baseModuleContext) DeviceConfig() DeviceConfig {
|
|
||||||
return DeviceConfig{b.config.deviceConfig}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *baseModuleContext) Platform() bool {
|
|
||||||
return b.kind == platformModule
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *baseModuleContext) DeviceSpecific() bool {
|
|
||||||
return b.kind == deviceSpecificModule
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *baseModuleContext) SocSpecific() bool {
|
|
||||||
return b.kind == socSpecificModule
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *baseModuleContext) ProductSpecific() bool {
|
|
||||||
return b.kind == productSpecificModule
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *baseModuleContext) SystemExtSpecific() bool {
|
|
||||||
return b.kind == systemExtSpecificModule
|
|
||||||
}
|
|
||||||
|
|
||||||
// Makes this module a platform module, i.e. not specific to soc, device,
|
// Makes this module a platform module, i.e. not specific to soc, device,
|
||||||
// product, or system_ext.
|
// product, or system_ext.
|
||||||
func (m *ModuleBase) MakeAsPlatform() {
|
func (m *ModuleBase) MakeAsPlatform() {
|
||||||
@@ -1888,22 +1941,6 @@ func (m *moduleContext) TargetRequiredModuleNames() []string {
|
|||||||
return m.module.base().commonProperties.Target_required
|
return m.module.base().commonProperties.Target_required
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) Glob(globPattern string, excludes []string) Paths {
|
|
||||||
ret, err := b.GlobWithDeps(globPattern, excludes)
|
|
||||||
if err != nil {
|
|
||||||
b.ModuleErrorf("glob: %s", err.Error())
|
|
||||||
}
|
|
||||||
return pathsForModuleSrcFromFullPath(b, ret, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *baseModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
|
||||||
ret, err := b.GlobWithDeps(globPattern, excludes)
|
|
||||||
if err != nil {
|
|
||||||
b.ModuleErrorf("glob: %s", err.Error())
|
|
||||||
}
|
|
||||||
return pathsForModuleSrcFromFullPath(b, ret, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterSingletonType("buildtarget", BuildTargetSingleton)
|
RegisterSingletonType("buildtarget", BuildTargetSingleton)
|
||||||
}
|
}
|
||||||
|
@@ -409,7 +409,7 @@ func expandOneSrcPath(ctx ModuleContext, s string, expandedExcludes []string) (P
|
|||||||
// each string. If incDirs is false, strip paths with a trailing '/' from the list.
|
// each string. If incDirs is false, strip paths with a trailing '/' from the list.
|
||||||
// It intended for use in globs that only list files that exist, so it allows '$' in
|
// It intended for use in globs that only list files that exist, so it allows '$' in
|
||||||
// filenames.
|
// filenames.
|
||||||
func pathsForModuleSrcFromFullPath(ctx BaseModuleContext, paths []string, incDirs bool) Paths {
|
func pathsForModuleSrcFromFullPath(ctx EarlyModuleContext, paths []string, incDirs bool) Paths {
|
||||||
prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
|
prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
|
||||||
if prefix == "./" {
|
if prefix == "./" {
|
||||||
prefix = ""
|
prefix = ""
|
||||||
|
@@ -286,7 +286,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: socSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: socSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
in: []string{"bin", "my_test"},
|
in: []string{"bin", "my_test"},
|
||||||
@@ -298,7 +300,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: deviceSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: deviceSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
in: []string{"bin", "my_test"},
|
in: []string{"bin", "my_test"},
|
||||||
@@ -310,7 +314,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: productSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
in: []string{"bin", "my_test"},
|
in: []string{"bin", "my_test"},
|
||||||
@@ -322,7 +328,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: systemExtSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: systemExtSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
in: []string{"bin", "my_test"},
|
in: []string{"bin", "my_test"},
|
||||||
@@ -384,7 +392,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: socSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: socSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
},
|
},
|
||||||
@@ -397,7 +407,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: deviceSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: deviceSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
},
|
},
|
||||||
@@ -410,7 +422,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: productSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
},
|
},
|
||||||
@@ -424,7 +438,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: systemExtSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: systemExtSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
},
|
},
|
||||||
@@ -450,7 +466,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: socSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: socSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inSanitizerDir: true,
|
inSanitizerDir: true,
|
||||||
},
|
},
|
||||||
@@ -463,7 +481,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: deviceSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: deviceSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inSanitizerDir: true,
|
inSanitizerDir: true,
|
||||||
},
|
},
|
||||||
@@ -476,7 +496,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: productSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inSanitizerDir: true,
|
inSanitizerDir: true,
|
||||||
},
|
},
|
||||||
@@ -490,7 +512,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: systemExtSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: systemExtSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inSanitizerDir: true,
|
inSanitizerDir: true,
|
||||||
},
|
},
|
||||||
@@ -517,7 +541,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: socSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: socSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
inSanitizerDir: true,
|
inSanitizerDir: true,
|
||||||
@@ -531,7 +557,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: deviceSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: deviceSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
inSanitizerDir: true,
|
inSanitizerDir: true,
|
||||||
@@ -545,7 +573,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: productSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: productSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
inSanitizerDir: true,
|
inSanitizerDir: true,
|
||||||
@@ -559,7 +589,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
baseModuleContext: baseModuleContext{
|
baseModuleContext: baseModuleContext{
|
||||||
os: deviceTarget.Os,
|
os: deviceTarget.Os,
|
||||||
target: deviceTarget,
|
target: deviceTarget,
|
||||||
kind: systemExtSpecificModule,
|
earlyModuleContext: earlyModuleContext{
|
||||||
|
kind: systemExtSpecificModule,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
inData: true,
|
inData: true,
|
||||||
inSanitizerDir: true,
|
inSanitizerDir: true,
|
||||||
|
@@ -897,7 +897,7 @@ func (a *AndroidAppImport) processVariants(ctx android.LoadHookContext) {
|
|||||||
MergePropertiesFromVariant(ctx, &a.properties, archProps, archType.Name)
|
MergePropertiesFromVariant(ctx, &a.properties, archProps, archType.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MergePropertiesFromVariant(ctx android.BaseModuleContext,
|
func MergePropertiesFromVariant(ctx android.EarlyModuleContext,
|
||||||
dst interface{}, variantGroup reflect.Value, variant string) {
|
dst interface{}, variantGroup reflect.Value, variant string) {
|
||||||
src := variantGroup.FieldByName(proptools.FieldNameForProperty(variant))
|
src := variantGroup.FieldByName(proptools.FieldNameForProperty(variant))
|
||||||
if !src.IsValid() {
|
if !src.IsValid() {
|
||||||
|
@@ -58,7 +58,7 @@ func sdkVersionOrDefault(ctx android.BaseModuleContext, 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.BaseModuleContext, v string) (int, error) {
|
func sdkVersionToNumber(ctx android.EarlyModuleContext, v string) (int, error) {
|
||||||
switch v {
|
switch v {
|
||||||
case "", "none", "current", "test_current", "system_current", "core_current", "core_platform":
|
case "", "none", "current", "test_current", "system_current", "core_current", "core_platform":
|
||||||
return ctx.Config().DefaultAppTargetSdkInt(), nil
|
return ctx.Config().DefaultAppTargetSdkInt(), nil
|
||||||
@@ -72,7 +72,7 @@ func sdkVersionToNumber(ctx android.BaseModuleContext, v string) (int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sdkVersionToNumberAsString(ctx android.BaseModuleContext, v string) (string, error) {
|
func sdkVersionToNumberAsString(ctx android.EarlyModuleContext, v string) (string, error) {
|
||||||
n, err := sdkVersionToNumber(ctx, v)
|
n, err := sdkVersionToNumber(ctx, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -80,7 +80,7 @@ func sdkVersionToNumberAsString(ctx android.BaseModuleContext, v string) (string
|
|||||||
return strconv.Itoa(n), nil
|
return strconv.Itoa(n), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
func decodeSdkDep(ctx android.EarlyModuleContext, 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"
|
||||||
|
@@ -375,7 +375,7 @@ func (module *SdkLibrary) sdkVersionForScope(apiScope apiScope) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the sdk version for use when compiling the stubs library.
|
// Get the sdk version for use when compiling the stubs library.
|
||||||
func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.BaseModuleContext, apiScope apiScope) string {
|
func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.LoadHookContext, apiScope apiScope) string {
|
||||||
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
||||||
if sdkDep.hasStandardLibs() {
|
if sdkDep.hasStandardLibs() {
|
||||||
// If building against a standard sdk then use the sdk version appropriate for the scope.
|
// If building against a standard sdk then use the sdk version appropriate for the scope.
|
||||||
|
Reference in New Issue
Block a user