Merge changes I9f8df94f,I2d7f5c56,I0ebb7381,Ieefcfc1a
* changes:
Consolidate *MutatorContext and ModuleContext into BaseModuleContext
Consolidate baseContext, BaseContext, and BaseModuleContext
Rename ModuleBase receivers
Remove repetition in android package names
diff --git a/android/api_levels.go b/android/api_levels.go
index 51d4703..961685a 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -85,7 +85,7 @@
// * Numeric API levels are simply converted.
// * "minimum" and "current" are not currently handled since the former is
// 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]
if ok {
return num, nil
diff --git a/android/arch.go b/android/arch.go
index 04eb1e2..f4a3c06 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -1129,7 +1129,7 @@
var variantReplacer = strings.NewReplacer("-", "_", ".", "_")
-func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
+func (m *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
dst interface{}, src reflect.Value, field, srcPrefix string) reflect.Value {
src = src.FieldByName(field)
@@ -1167,16 +1167,16 @@
}
// Rewrite the module's properties structs to contain arch-specific values.
-func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
- arch := a.Arch()
- os := a.Os()
+func (m *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
+ arch := m.Arch()
+ os := m.Os()
- for i := range a.generalProperties {
- genProps := a.generalProperties[i]
- if a.archProperties[i] == nil {
+ for i := range m.generalProperties {
+ genProps := m.generalProperties[i]
+ if m.archProperties[i] == nil {
continue
}
- for _, archProperties := range a.archProperties[i] {
+ for _, archProperties := range m.archProperties[i] {
archPropValues := reflect.ValueOf(archProperties).Elem()
archProp := archPropValues.FieldByName("Arch")
@@ -1197,7 +1197,7 @@
if arch.ArchType != Common {
field := proptools.FieldNameForProperty(t.Name)
prefix := "arch." + t.Name
- archStruct := a.appendProperties(ctx, genProps, archProp, field, prefix)
+ archStruct := m.appendProperties(ctx, genProps, archProp, field, prefix)
// Handle arch-variant-specific properties in the form:
// arch: {
@@ -1209,7 +1209,7 @@
if v != "" {
field := proptools.FieldNameForProperty(v)
prefix := "arch." + t.Name + "." + v
- a.appendProperties(ctx, genProps, archStruct, field, prefix)
+ m.appendProperties(ctx, genProps, archStruct, field, prefix)
}
// Handle cpu-variant-specific properties in the form:
@@ -1223,7 +1223,7 @@
if c != "" {
field := proptools.FieldNameForProperty(c)
prefix := "arch." + t.Name + "." + c
- a.appendProperties(ctx, genProps, archStruct, field, prefix)
+ m.appendProperties(ctx, genProps, archStruct, field, prefix)
}
}
@@ -1236,7 +1236,7 @@
for _, feature := range arch.ArchFeatures {
field := proptools.FieldNameForProperty(feature)
prefix := "arch." + t.Name + "." + feature
- a.appendProperties(ctx, genProps, archStruct, field, prefix)
+ m.appendProperties(ctx, genProps, archStruct, field, prefix)
}
// Handle multilib-specific properties in the form:
@@ -1247,7 +1247,7 @@
// },
field = proptools.FieldNameForProperty(t.Multilib)
prefix = "multilib." + t.Multilib
- a.appendProperties(ctx, genProps, multilibProp, field, prefix)
+ m.appendProperties(ctx, genProps, multilibProp, field, prefix)
}
// Handle host-specific properties in the form:
@@ -1259,7 +1259,7 @@
if os.Class == Host || os.Class == HostCross {
field = "Host"
prefix = "target.host"
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
}
// Handle target OS generalities of the form:
@@ -1274,24 +1274,24 @@
if os.Linux() {
field = "Linux"
prefix = "target.linux"
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
if arch.ArchType != Common {
field = "Linux_" + arch.ArchType.Name
prefix = "target.linux_" + arch.ArchType.Name
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
}
}
if os.Bionic() {
field = "Bionic"
prefix = "target.bionic"
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
if arch.ArchType != Common {
field = "Bionic_" + t.Name
prefix = "target.bionic_" + t.Name
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
}
}
@@ -1321,18 +1321,18 @@
// },
field = os.Field
prefix = "target." + os.Name
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
if arch.ArchType != Common {
field = os.Field + "_" + t.Name
prefix = "target." + os.Name + "_" + t.Name
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
}
if (os.Class == Host || os.Class == HostCross) && os != Windows {
field := "Not_windows"
prefix := "target.not_windows"
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
}
// Handle 64-bit device properties in the form:
@@ -1352,11 +1352,11 @@
if ctx.Config().Android64() {
field := "Android64"
prefix := "target.android64"
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
} else {
field := "Android32"
prefix := "target.android32"
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
}
if (arch.ArchType == X86 && (hasArmAbi(arch) ||
@@ -1365,7 +1365,7 @@
hasX86AndroidArch(ctx.Config().Targets[Android])) {
field := "Arm_on_x86"
prefix := "target.arm_on_x86"
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
}
if (arch.ArchType == X86_64 && (hasArmAbi(arch) ||
hasArmAndroidArch(ctx.Config().Targets[Android]))) ||
@@ -1373,7 +1373,7 @@
hasX8664AndroidArch(ctx.Config().Targets[Android])) {
field := "Arm_on_x86_64"
prefix := "target.arm_on_x86_64"
- a.appendProperties(ctx, genProps, targetProp, field, prefix)
+ m.appendProperties(ctx, genProps, targetProp, field, prefix)
}
}
}
diff --git a/android/hooks.go b/android/hooks.go
index d55678e..2d2f797 100644
--- a/android/hooks.go
+++ b/android/hooks.go
@@ -27,7 +27,7 @@
// been applied.
type LoadHookContext interface {
// TODO: a new context that includes Config() but not Target(), etc.?
- BaseContext
+ BaseModuleContext
AppendProperties(...interface{})
PrependProperties(...interface{})
CreateModule(blueprint.ModuleFactory, ...interface{})
@@ -36,7 +36,7 @@
// Arch hooks are run after the module has been split into architecture variants, and can be used
// to add architecture-specific properties.
type ArchHookContext interface {
- BaseContext
+ BaseModuleContext
AppendProperties(...interface{})
PrependProperties(...interface{})
}
@@ -129,18 +129,18 @@
func LoadHookMutator(ctx TopDownMutatorContext) {
if m, ok := ctx.Module().(Module); ok {
- // Cast through *androidTopDownMutatorContext because AppendProperties is implemented
- // on *androidTopDownMutatorContext but not exposed through TopDownMutatorContext
- var loadHookCtx LoadHookContext = ctx.(*androidTopDownMutatorContext)
+ // Cast through *topDownMutatorContext because AppendProperties is implemented
+ // on *topDownMutatorContext but not exposed through TopDownMutatorContext
+ var loadHookCtx LoadHookContext = ctx.(*topDownMutatorContext)
m.base().hooks.runLoadHooks(loadHookCtx, m.base())
}
}
func archHookMutator(ctx TopDownMutatorContext) {
if m, ok := ctx.Module().(Module); ok {
- // Cast through *androidTopDownMutatorContext because AppendProperties is implemented
- // on *androidTopDownMutatorContext but not exposed through TopDownMutatorContext
- var archHookCtx ArchHookContext = ctx.(*androidTopDownMutatorContext)
+ // Cast through *topDownMutatorContext because AppendProperties is implemented
+ // on *topDownMutatorContext but not exposed through TopDownMutatorContext
+ var archHookCtx ArchHookContext = ctx.(*topDownMutatorContext)
m.base().hooks.runArchHooks(archHookCtx, m.base())
}
}
diff --git a/android/module.go b/android/module.go
index eb9b0fc..26e8e63 100644
--- a/android/module.go
+++ b/android/module.go
@@ -56,7 +56,59 @@
type ModuleBuildParams BuildParams
-type androidBaseContext interface {
+// 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
+// instead of a blueprint.Module, plus some extra methods that return Android-specific information
+// about the current module.
+type BaseModuleContext interface {
+ Module() Module
+ ModuleName() string
+ ModuleDir() string
+ ModuleType() string
+ Config() Config
+
+ OtherModuleName(m blueprint.Module) string
+ OtherModuleDir(m blueprint.Module) string
+ OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
+ OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
+ OtherModuleExists(name string) bool
+
+ GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module
+ GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
+ GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
+
+ VisitDirectDepsBlueprint(visit func(blueprint.Module))
+ VisitDirectDeps(visit func(Module))
+ VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
+ VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
+ // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
+ VisitDepsDepthFirst(visit func(Module))
+ // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
+ VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
+ WalkDeps(visit func(Module, Module) bool)
+ WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool)
+ // GetWalkPath is supposed to be called in visit function passed in WalkDeps()
+ // and returns a top-down dependency path from a start module to current child 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)
+
Target() Target
TargetPrimary() bool
MultiTargets() []Target
@@ -78,37 +130,12 @@
DeviceConfig() DeviceConfig
}
+// Deprecated: use BaseModuleContext instead
type BaseContext interface {
BaseModuleContext
- androidBaseContext
-}
-
-// 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 {
- androidBaseContext
BaseModuleContext
// Deprecated: use ModuleContext.Build instead.
@@ -117,8 +144,6 @@
ExpandSources(srcFiles, excludes []string) Paths
ExpandSource(srcFile, prop string) Path
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
- Glob(globPattern string, excludes []string) Paths
- GlobFiles(globPattern string, excludes []string) Paths
InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
InstallFile(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
@@ -136,30 +161,8 @@
HostRequiredModuleNames() []string
TargetRequiredModuleNames() []string
- // android.ModuleContext methods
- // These are duplicated instead of embedded so that can eventually be wrapped to take an
- // android.Module instead of a blueprint.Module
- OtherModuleName(m blueprint.Module) string
- OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
- OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
-
- GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module
- GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
- GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
-
ModuleSubDir() string
- VisitDirectDepsBlueprint(visit func(blueprint.Module))
- VisitDirectDeps(visit func(Module))
- VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
- VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
- // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
- VisitDepsDepthFirst(visit func(Module))
- // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
- VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
- WalkDeps(visit func(Module, Module) bool)
- WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool)
-
Variable(pctx PackageContext, name, value string)
Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
// Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
@@ -457,9 +460,9 @@
// The ModuleBase type is responsible for implementing the GenerateBuildActions
// method to support the blueprint.Module interface. This method will then call
// the module's GenerateAndroidBuildActions method once for each build variant
-// that is to be built. GenerateAndroidBuildActions is passed a
-// AndroidModuleContext rather than the usual blueprint.ModuleContext.
-// AndroidModuleContext exposes extra functionality specific to the Android build
+// that is to be built. GenerateAndroidBuildActions is passed a ModuleContext
+// rather than the usual blueprint.ModuleContext.
+// ModuleContext exposes extra functionality specific to the Android build
// system including details about the particular build variant that is to be
// generated.
//
@@ -526,83 +529,83 @@
prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
}
-func (a *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
+func (m *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
-func (a *ModuleBase) AddProperties(props ...interface{}) {
- a.registerProps = append(a.registerProps, props...)
+func (m *ModuleBase) AddProperties(props ...interface{}) {
+ m.registerProps = append(m.registerProps, props...)
}
-func (a *ModuleBase) GetProperties() []interface{} {
- return a.registerProps
+func (m *ModuleBase) GetProperties() []interface{} {
+ return m.registerProps
}
-func (a *ModuleBase) BuildParamsForTests() []BuildParams {
- return a.buildParams
+func (m *ModuleBase) BuildParamsForTests() []BuildParams {
+ return m.buildParams
}
-func (a *ModuleBase) RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams {
- return a.ruleParams
+func (m *ModuleBase) RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams {
+ return m.ruleParams
}
-func (a *ModuleBase) VariablesForTests() map[string]string {
- return a.variables
+func (m *ModuleBase) VariablesForTests() map[string]string {
+ return m.variables
}
-func (a *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
- a.prefer32 = prefer32
+func (m *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
+ m.prefer32 = prefer32
}
// Name returns the name of the module. It may be overridden by individual module types, for
// example prebuilts will prepend prebuilt_ to the name.
-func (a *ModuleBase) Name() string {
- return String(a.nameProperties.Name)
+func (m *ModuleBase) Name() string {
+ return String(m.nameProperties.Name)
}
// BaseModuleName returns the name of the module as specified in the blueprints file.
-func (a *ModuleBase) BaseModuleName() string {
- return String(a.nameProperties.Name)
+func (m *ModuleBase) BaseModuleName() string {
+ return String(m.nameProperties.Name)
}
-func (a *ModuleBase) base() *ModuleBase {
- return a
+func (m *ModuleBase) base() *ModuleBase {
+ return m
}
-func (a *ModuleBase) SetTarget(target Target, multiTargets []Target, primary bool) {
- a.commonProperties.CompileTarget = target
- a.commonProperties.CompileMultiTargets = multiTargets
- a.commonProperties.CompilePrimary = primary
+func (m *ModuleBase) SetTarget(target Target, multiTargets []Target, primary bool) {
+ m.commonProperties.CompileTarget = target
+ m.commonProperties.CompileMultiTargets = multiTargets
+ m.commonProperties.CompilePrimary = primary
}
-func (a *ModuleBase) Target() Target {
- return a.commonProperties.CompileTarget
+func (m *ModuleBase) Target() Target {
+ return m.commonProperties.CompileTarget
}
-func (a *ModuleBase) TargetPrimary() bool {
- return a.commonProperties.CompilePrimary
+func (m *ModuleBase) TargetPrimary() bool {
+ return m.commonProperties.CompilePrimary
}
-func (a *ModuleBase) MultiTargets() []Target {
- return a.commonProperties.CompileMultiTargets
+func (m *ModuleBase) MultiTargets() []Target {
+ return m.commonProperties.CompileMultiTargets
}
-func (a *ModuleBase) Os() OsType {
- return a.Target().Os
+func (m *ModuleBase) Os() OsType {
+ return m.Target().Os
}
-func (a *ModuleBase) Host() bool {
- return a.Os().Class == Host || a.Os().Class == HostCross
+func (m *ModuleBase) Host() bool {
+ return m.Os().Class == Host || m.Os().Class == HostCross
}
-func (a *ModuleBase) Arch() Arch {
- return a.Target().Arch
+func (m *ModuleBase) Arch() Arch {
+ return m.Target().Arch
}
-func (a *ModuleBase) ArchSpecific() bool {
- return a.commonProperties.ArchSpecific
+func (m *ModuleBase) ArchSpecific() bool {
+ return m.commonProperties.ArchSpecific
}
-func (a *ModuleBase) OsClassSupported() []OsClass {
- switch a.commonProperties.HostOrDeviceSupported {
+func (m *ModuleBase) OsClassSupported() []OsClass {
+ switch m.commonProperties.HostOrDeviceSupported {
case HostSupported:
return []OsClass{Host, HostCross}
case HostSupportedNoCross:
@@ -611,13 +614,13 @@
return []OsClass{Device}
case HostAndDeviceSupported, HostAndDeviceDefault:
var supported []OsClass
- if Bool(a.hostAndDeviceProperties.Host_supported) ||
- (a.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
- a.hostAndDeviceProperties.Host_supported == nil) {
+ if Bool(m.hostAndDeviceProperties.Host_supported) ||
+ (m.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
+ m.hostAndDeviceProperties.Host_supported == nil) {
supported = append(supported, Host, HostCross)
}
- if a.hostAndDeviceProperties.Device_supported == nil ||
- *a.hostAndDeviceProperties.Device_supported {
+ if m.hostAndDeviceProperties.Device_supported == nil ||
+ *m.hostAndDeviceProperties.Device_supported {
supported = append(supported, Device)
}
return supported
@@ -626,49 +629,49 @@
}
}
-func (a *ModuleBase) DeviceSupported() bool {
- return a.commonProperties.HostOrDeviceSupported == DeviceSupported ||
- a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
- (a.hostAndDeviceProperties.Device_supported == nil ||
- *a.hostAndDeviceProperties.Device_supported)
+func (m *ModuleBase) DeviceSupported() bool {
+ return m.commonProperties.HostOrDeviceSupported == DeviceSupported ||
+ m.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
+ (m.hostAndDeviceProperties.Device_supported == nil ||
+ *m.hostAndDeviceProperties.Device_supported)
}
-func (a *ModuleBase) Platform() bool {
- return !a.DeviceSpecific() && !a.SocSpecific() && !a.ProductSpecific() && !a.ProductServicesSpecific()
+func (m *ModuleBase) Platform() bool {
+ return !m.DeviceSpecific() && !m.SocSpecific() && !m.ProductSpecific() && !m.ProductServicesSpecific()
}
-func (a *ModuleBase) DeviceSpecific() bool {
- return Bool(a.commonProperties.Device_specific)
+func (m *ModuleBase) DeviceSpecific() bool {
+ return Bool(m.commonProperties.Device_specific)
}
-func (a *ModuleBase) SocSpecific() bool {
- return Bool(a.commonProperties.Vendor) || Bool(a.commonProperties.Proprietary) || Bool(a.commonProperties.Soc_specific)
+func (m *ModuleBase) SocSpecific() bool {
+ return Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Proprietary) || Bool(m.commonProperties.Soc_specific)
}
-func (a *ModuleBase) ProductSpecific() bool {
- return Bool(a.commonProperties.Product_specific)
+func (m *ModuleBase) ProductSpecific() bool {
+ return Bool(m.commonProperties.Product_specific)
}
-func (a *ModuleBase) ProductServicesSpecific() bool {
- return Bool(a.commonProperties.Product_services_specific)
+func (m *ModuleBase) ProductServicesSpecific() bool {
+ return Bool(m.commonProperties.Product_services_specific)
}
-func (a *ModuleBase) Enabled() bool {
- if a.commonProperties.Enabled == nil {
- return !a.Os().DefaultDisabled
+func (m *ModuleBase) Enabled() bool {
+ if m.commonProperties.Enabled == nil {
+ return !m.Os().DefaultDisabled
}
- return *a.commonProperties.Enabled
+ return *m.commonProperties.Enabled
}
-func (a *ModuleBase) SkipInstall() {
- a.commonProperties.SkipInstall = true
+func (m *ModuleBase) SkipInstall() {
+ m.commonProperties.SkipInstall = true
}
-func (a *ModuleBase) ExportedToMake() bool {
- return a.commonProperties.NamespaceExportedToMake
+func (m *ModuleBase) ExportedToMake() bool {
+ return m.commonProperties.NamespaceExportedToMake
}
-func (a *ModuleBase) computeInstallDeps(
+func (m *ModuleBase) computeInstallDeps(
ctx blueprint.ModuleContext) Paths {
result := Paths{}
@@ -683,35 +686,35 @@
return result
}
-func (a *ModuleBase) filesToInstall() Paths {
- return a.installFiles
+func (m *ModuleBase) filesToInstall() Paths {
+ return m.installFiles
}
-func (p *ModuleBase) NoAddressSanitizer() bool {
- return p.noAddressSanitizer
+func (m *ModuleBase) NoAddressSanitizer() bool {
+ return m.noAddressSanitizer
}
-func (p *ModuleBase) InstallInData() bool {
+func (m *ModuleBase) InstallInData() bool {
return false
}
-func (p *ModuleBase) InstallInSanitizerDir() bool {
+func (m *ModuleBase) InstallInSanitizerDir() bool {
return false
}
-func (p *ModuleBase) InstallInRecovery() bool {
- return Bool(p.commonProperties.Recovery)
+func (m *ModuleBase) InstallInRecovery() bool {
+ return Bool(m.commonProperties.Recovery)
}
-func (a *ModuleBase) Owner() string {
- return String(a.commonProperties.Owner)
+func (m *ModuleBase) Owner() string {
+ return String(m.commonProperties.Owner)
}
-func (a *ModuleBase) NoticeFile() OptionalPath {
- return a.noticeFile
+func (m *ModuleBase) NoticeFile() OptionalPath {
+ return m.noticeFile
}
-func (a *ModuleBase) generateModuleTarget(ctx ModuleContext) {
+func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
allInstalledFiles := Paths{}
allCheckbuildFiles := Paths{}
ctx.VisitAllModuleVariants(func(module Module) {
@@ -736,7 +739,7 @@
Default: !ctx.Config().EmbeddedInMake(),
})
deps = append(deps, name)
- a.installTarget = name
+ m.installTarget = name
}
if len(allCheckbuildFiles) > 0 {
@@ -747,7 +750,7 @@
Implicits: allCheckbuildFiles,
})
deps = append(deps, name)
- a.checkbuildTarget = name
+ m.checkbuildTarget = name
}
if len(deps) > 0 {
@@ -763,26 +766,26 @@
Implicits: deps,
})
- a.blueprintDir = ctx.ModuleDir()
+ m.blueprintDir = ctx.ModuleDir()
}
}
-func determineModuleKind(a *ModuleBase, ctx blueprint.BaseModuleContext) moduleKind {
- var socSpecific = Bool(a.commonProperties.Vendor) || Bool(a.commonProperties.Proprietary) || Bool(a.commonProperties.Soc_specific)
- var deviceSpecific = Bool(a.commonProperties.Device_specific)
- var productSpecific = Bool(a.commonProperties.Product_specific)
- var productServicesSpecific = Bool(a.commonProperties.Product_services_specific)
+func determineModuleKind(m *ModuleBase, ctx blueprint.BaseModuleContext) moduleKind {
+ var socSpecific = Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Proprietary) || Bool(m.commonProperties.Soc_specific)
+ var deviceSpecific = Bool(m.commonProperties.Device_specific)
+ var productSpecific = Bool(m.commonProperties.Product_specific)
+ var productServicesSpecific = Bool(m.commonProperties.Product_services_specific)
msg := "conflicting value set here"
if socSpecific && deviceSpecific {
ctx.PropertyErrorf("device_specific", "a module cannot be specific to SoC and device at the same time.")
- if Bool(a.commonProperties.Vendor) {
+ if Bool(m.commonProperties.Vendor) {
ctx.PropertyErrorf("vendor", msg)
}
- if Bool(a.commonProperties.Proprietary) {
+ if Bool(m.commonProperties.Proprietary) {
ctx.PropertyErrorf("proprietary", msg)
}
- if Bool(a.commonProperties.Soc_specific) {
+ if Bool(m.commonProperties.Soc_specific) {
ctx.PropertyErrorf("soc_specific", msg)
}
}
@@ -801,13 +804,13 @@
if deviceSpecific {
ctx.PropertyErrorf("device_specific", msg)
} else {
- if Bool(a.commonProperties.Vendor) {
+ if Bool(m.commonProperties.Vendor) {
ctx.PropertyErrorf("vendor", msg)
}
- if Bool(a.commonProperties.Proprietary) {
+ if Bool(m.commonProperties.Proprietary) {
ctx.PropertyErrorf("proprietary", msg)
}
- if Bool(a.commonProperties.Soc_specific) {
+ if Bool(m.commonProperties.Soc_specific) {
ctx.PropertyErrorf("soc_specific", msg)
}
}
@@ -826,25 +829,26 @@
}
}
-func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl {
- return androidBaseContextImpl{
- target: a.commonProperties.CompileTarget,
- targetPrimary: a.commonProperties.CompilePrimary,
- multiTargets: a.commonProperties.CompileMultiTargets,
- kind: determineModuleKind(a, ctx),
- config: ctx.Config().(Config),
+func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext {
+ return baseModuleContext{
+ BaseModuleContext: ctx,
+ target: m.commonProperties.CompileTarget,
+ targetPrimary: m.commonProperties.CompilePrimary,
+ multiTargets: m.commonProperties.CompileMultiTargets,
+ kind: determineModuleKind(m, ctx),
+ config: ctx.Config().(Config),
}
}
-func (a *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
- ctx := &androidModuleContext{
- module: a.module,
- ModuleContext: blueprintCtx,
- androidBaseContextImpl: a.androidBaseContextFactory(blueprintCtx),
- installDeps: a.computeInstallDeps(blueprintCtx),
- installFiles: a.installFiles,
- missingDeps: blueprintCtx.GetMissingDependencies(),
- variables: make(map[string]string),
+func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
+ ctx := &moduleContext{
+ module: m.module,
+ bp: blueprintCtx,
+ baseModuleContext: m.baseModuleContextFactory(blueprintCtx),
+ installDeps: m.computeInstallDeps(blueprintCtx),
+ installFiles: m.installFiles,
+ missingDeps: blueprintCtx.GetMissingDependencies(),
+ variables: make(map[string]string),
}
if ctx.config.captureBuild {
@@ -869,66 +873,79 @@
ctx.Variable(pctx, "moduleDescSuffix", s)
// Some common property checks for properties that will be used later in androidmk.go
- if a.commonProperties.Dist.Dest != nil {
- _, err := validateSafePath(*a.commonProperties.Dist.Dest)
+ if m.commonProperties.Dist.Dest != nil {
+ _, err := validateSafePath(*m.commonProperties.Dist.Dest)
if err != nil {
ctx.PropertyErrorf("dist.dest", "%s", err.Error())
}
}
- if a.commonProperties.Dist.Dir != nil {
- _, err := validateSafePath(*a.commonProperties.Dist.Dir)
+ if m.commonProperties.Dist.Dir != nil {
+ _, err := validateSafePath(*m.commonProperties.Dist.Dir)
if err != nil {
ctx.PropertyErrorf("dist.dir", "%s", err.Error())
}
}
- if a.commonProperties.Dist.Suffix != nil {
- if strings.Contains(*a.commonProperties.Dist.Suffix, "/") {
+ if m.commonProperties.Dist.Suffix != nil {
+ if strings.Contains(*m.commonProperties.Dist.Suffix, "/") {
ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
}
}
- if a.Enabled() {
- a.module.GenerateAndroidBuildActions(ctx)
+ if m.Enabled() {
+ ctx.VisitDirectDeps(func(dep Module) {
+ if !dep.Enabled() {
+ if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{ctx.OtherModuleName(dep)})
+ } else {
+ ctx.ModuleErrorf("depends on disabled module %q", ctx.OtherModuleName(dep))
+ }
+ }
+ })
+
+ m.module.GenerateAndroidBuildActions(ctx)
if ctx.Failed() {
return
}
- a.installFiles = append(a.installFiles, ctx.installFiles...)
- a.checkbuildFiles = append(a.checkbuildFiles, ctx.checkbuildFiles...)
+ m.installFiles = append(m.installFiles, ctx.installFiles...)
+ m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...)
- notice := proptools.StringDefault(a.commonProperties.Notice, "NOTICE")
- if m := SrcIsModule(notice); m != "" {
- a.noticeFile = ctx.ExpandOptionalSource(¬ice, "notice")
+ notice := proptools.StringDefault(m.commonProperties.Notice, "NOTICE")
+ if module := SrcIsModule(notice); module != "" {
+ m.noticeFile = ctx.ExpandOptionalSource(¬ice, "notice")
} else {
noticePath := filepath.Join(ctx.ModuleDir(), notice)
- a.noticeFile = ExistentPathForSource(ctx, noticePath)
+ m.noticeFile = ExistentPathForSource(ctx, noticePath)
}
}
- if a == ctx.FinalModule().(Module).base() {
- a.generateModuleTarget(ctx)
+ if m == ctx.FinalModule().(Module).base() {
+ m.generateModuleTarget(ctx)
if ctx.Failed() {
return
}
}
- a.buildParams = ctx.buildParams
- a.ruleParams = ctx.ruleParams
- a.variables = ctx.variables
+ m.buildParams = ctx.buildParams
+ m.ruleParams = ctx.ruleParams
+ m.variables = ctx.variables
}
-type androidBaseContextImpl struct {
+type baseModuleContext struct {
+ blueprint.BaseModuleContext
target Target
multiTargets []Target
targetPrimary bool
debug bool
kind moduleKind
config Config
+
+ walkPath []Module
}
-type androidModuleContext struct {
- blueprint.ModuleContext
- androidBaseContextImpl
+type moduleContext struct {
+ bp blueprint.ModuleContext
+ baseModuleContext
installDeps Paths
installFiles Paths
checkbuildFiles Paths
@@ -941,8 +958,8 @@
variables map[string]string
}
-func (a *androidModuleContext) ninjaError(desc string, outputs []string, err error) {
- a.ModuleContext.Build(pctx.PackageContext, blueprint.BuildParams{
+func (m *moduleContext) ninjaError(desc string, outputs []string, err error) {
+ m.bp.Build(pctx.PackageContext, blueprint.BuildParams{
Rule: ErrorRule,
Description: desc,
Outputs: outputs,
@@ -954,12 +971,8 @@
return
}
-func (a *androidModuleContext) Config() Config {
- return a.ModuleContext.Config().(Config)
-}
-
-func (a *androidModuleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
- a.Build(pctx, BuildParams(params))
+func (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
+ m.Build(pctx, BuildParams(params))
}
func convertBuildParams(params BuildParams) blueprint.BuildParams {
@@ -1002,29 +1015,29 @@
return bparams
}
-func (a *androidModuleContext) Variable(pctx PackageContext, name, value string) {
- if a.config.captureBuild {
- a.variables[name] = value
+func (m *moduleContext) Variable(pctx PackageContext, name, value string) {
+ if m.config.captureBuild {
+ m.variables[name] = value
}
- a.ModuleContext.Variable(pctx.PackageContext, name, value)
+ m.bp.Variable(pctx.PackageContext, name, value)
}
-func (a *androidModuleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
+func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
argNames ...string) blueprint.Rule {
- rule := a.ModuleContext.Rule(pctx.PackageContext, name, params, argNames...)
+ rule := m.bp.Rule(pctx.PackageContext, name, params, argNames...)
- if a.config.captureBuild {
- a.ruleParams[rule] = params
+ if m.config.captureBuild {
+ m.ruleParams[rule] = params
}
return rule
}
-func (a *androidModuleContext) Build(pctx PackageContext, params BuildParams) {
- if a.config.captureBuild {
- a.buildParams = append(a.buildParams, params)
+func (m *moduleContext) Build(pctx PackageContext, params BuildParams) {
+ if m.config.captureBuild {
+ m.buildParams = append(m.buildParams, params)
}
bparams := convertBuildParams(params)
@@ -1033,55 +1046,54 @@
bparams.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
}
- if a.missingDeps != nil {
- a.ninjaError(bparams.Description, bparams.Outputs,
+ if m.missingDeps != nil {
+ m.ninjaError(bparams.Description, bparams.Outputs,
fmt.Errorf("module %s missing dependencies: %s\n",
- a.ModuleName(), strings.Join(a.missingDeps, ", ")))
+ m.ModuleName(), strings.Join(m.missingDeps, ", ")))
return
}
- a.ModuleContext.Build(pctx.PackageContext, bparams)
+ m.bp.Build(pctx.PackageContext, bparams)
}
-func (a *androidModuleContext) GetMissingDependencies() []string {
- return a.missingDeps
+func (m *moduleContext) Module() Module {
+ return m.baseModuleContext.Module()
}
-func (a *androidModuleContext) AddMissingDependencies(deps []string) {
+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 {
+ return m.missingDeps
+}
+
+func (m *moduleContext) AddMissingDependencies(deps []string) {
if deps != nil {
- a.missingDeps = append(a.missingDeps, deps...)
- a.missingDeps = FirstUniqueStrings(a.missingDeps)
+ m.missingDeps = append(m.missingDeps, deps...)
+ m.missingDeps = FirstUniqueStrings(m.missingDeps)
}
}
-func (a *androidModuleContext) validateAndroidModule(module blueprint.Module) Module {
+func (b *baseModuleContext) validateAndroidModule(module blueprint.Module) Module {
aModule, _ := module.(Module)
- if aModule == nil {
- a.ModuleErrorf("module %q not an android module", a.OtherModuleName(aModule))
- return nil
- }
-
- if !aModule.Enabled() {
- if a.Config().AllowMissingDependencies() {
- a.AddMissingDependencies([]string{a.OtherModuleName(aModule)})
- } else {
- a.ModuleErrorf("depends on disabled module %q", a.OtherModuleName(aModule))
- }
- return nil
- }
-
return aModule
}
-func (a *androidModuleContext) getDirectDepInternal(name string, tag blueprint.DependencyTag) (blueprint.Module, blueprint.DependencyTag) {
+func (b *baseModuleContext) getDirectDepInternal(name string, tag blueprint.DependencyTag) (blueprint.Module, blueprint.DependencyTag) {
type dep struct {
mod blueprint.Module
tag blueprint.DependencyTag
}
var deps []dep
- a.VisitDirectDepsBlueprint(func(m blueprint.Module) {
- if aModule, _ := m.(Module); aModule != nil && aModule.base().BaseModuleName() == name {
- returnedTag := a.ModuleContext.OtherModuleDependencyTag(aModule)
+ b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
+ if aModule, _ := module.(Module); aModule != nil && aModule.base().BaseModuleName() == name {
+ returnedTag := b.BaseModuleContext.OtherModuleDependencyTag(aModule)
if tag == nil || returnedTag == tag {
deps = append(deps, dep{aModule, returnedTag})
}
@@ -1091,17 +1103,17 @@
return deps[0].mod, deps[0].tag
} else if len(deps) >= 2 {
panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
- name, a.ModuleName()))
+ name, b.ModuleName()))
} else {
return nil, nil
}
}
-func (a *androidModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module {
+func (b *baseModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module {
var deps []Module
- a.VisitDirectDepsBlueprint(func(m blueprint.Module) {
- if aModule, _ := m.(Module); aModule != nil {
- if a.ModuleContext.OtherModuleDependencyTag(aModule) == tag {
+ b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
+ if aModule, _ := module.(Module); aModule != nil {
+ if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
deps = append(deps, aModule)
}
}
@@ -1109,42 +1121,42 @@
return deps
}
-func (a *androidModuleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module {
- m, _ := a.getDirectDepInternal(name, tag)
- return m
+func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module {
+ module, _ := m.getDirectDepInternal(name, tag)
+ return module
}
-func (a *androidModuleContext) GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) {
- return a.getDirectDepInternal(name, nil)
+func (b *baseModuleContext) GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) {
+ return b.getDirectDepInternal(name, nil)
}
-func (a *androidModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
- a.ModuleContext.VisitDirectDeps(visit)
+func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
+ b.BaseModuleContext.VisitDirectDeps(visit)
}
-func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
- a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
- if aModule := a.validateAndroidModule(module); aModule != nil {
+func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
+ b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
+ if aModule := b.validateAndroidModule(module); aModule != nil {
visit(aModule)
}
})
}
-func (a *androidModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
- a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
- if aModule := a.validateAndroidModule(module); aModule != nil {
- if a.ModuleContext.OtherModuleDependencyTag(aModule) == tag {
+func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
+ b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
+ if aModule := b.validateAndroidModule(module); aModule != nil {
+ if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
visit(aModule)
}
}
})
}
-func (a *androidModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
- a.ModuleContext.VisitDirectDepsIf(
+func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
+ b.BaseModuleContext.VisitDirectDepsIf(
// pred
func(module blueprint.Module) bool {
- if aModule := a.validateAndroidModule(module); aModule != nil {
+ if aModule := b.validateAndroidModule(module); aModule != nil {
return pred(aModule)
} else {
return false
@@ -1156,19 +1168,19 @@
})
}
-func (a *androidModuleContext) VisitDepsDepthFirst(visit func(Module)) {
- a.ModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
- if aModule := a.validateAndroidModule(module); aModule != nil {
+func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
+ b.BaseModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
+ if aModule := b.validateAndroidModule(module); aModule != nil {
visit(aModule)
}
})
}
-func (a *androidModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
- a.ModuleContext.VisitDepsDepthFirstIf(
+func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
+ b.BaseModuleContext.VisitDepsDepthFirstIf(
// pred
func(module blueprint.Module) bool {
- if aModule := a.validateAndroidModule(module); aModule != nil {
+ if aModule := b.validateAndroidModule(module); aModule != nil {
return pred(aModule)
} else {
return false
@@ -1180,15 +1192,21 @@
})
}
-func (a *androidModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
- a.ModuleContext.WalkDeps(visit)
+func (b *baseModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
+ b.BaseModuleContext.WalkDeps(visit)
}
-func (a *androidModuleContext) WalkDeps(visit func(Module, Module) bool) {
- a.ModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
- childAndroidModule := a.validateAndroidModule(child)
- parentAndroidModule := a.validateAndroidModule(parent)
+func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) {
+ b.walkPath = []Module{b.Module()}
+ b.BaseModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
+ childAndroidModule, _ := child.(Module)
+ parentAndroidModule, _ := parent.(Module)
if childAndroidModule != nil && parentAndroidModule != nil {
+ // record walkPath before visit
+ for b.walkPath[len(b.walkPath)-1] != parentAndroidModule {
+ b.walkPath = b.walkPath[0 : len(b.walkPath)-1]
+ }
+ b.walkPath = append(b.walkPath, childAndroidModule)
return visit(childAndroidModule, parentAndroidModule)
} else {
return false
@@ -1196,143 +1214,151 @@
})
}
-func (a *androidModuleContext) VisitAllModuleVariants(visit func(Module)) {
- a.ModuleContext.VisitAllModuleVariants(func(module blueprint.Module) {
+func (b *baseModuleContext) GetWalkPath() []Module {
+ return b.walkPath
+}
+
+func (m *moduleContext) VisitAllModuleVariants(visit func(Module)) {
+ m.bp.VisitAllModuleVariants(func(module blueprint.Module) {
visit(module.(Module))
})
}
-func (a *androidModuleContext) PrimaryModule() Module {
- return a.ModuleContext.PrimaryModule().(Module)
+func (m *moduleContext) PrimaryModule() Module {
+ return m.bp.PrimaryModule().(Module)
}
-func (a *androidModuleContext) FinalModule() Module {
- return a.ModuleContext.FinalModule().(Module)
+func (m *moduleContext) FinalModule() Module {
+ return m.bp.FinalModule().(Module)
}
-func (a *androidBaseContextImpl) Target() Target {
- return a.target
+func (m *moduleContext) ModuleSubDir() string {
+ return m.bp.ModuleSubDir()
}
-func (a *androidBaseContextImpl) TargetPrimary() bool {
- return a.targetPrimary
+func (b *baseModuleContext) Target() Target {
+ return b.target
}
-func (a *androidBaseContextImpl) MultiTargets() []Target {
- return a.multiTargets
+func (b *baseModuleContext) TargetPrimary() bool {
+ return b.targetPrimary
}
-func (a *androidBaseContextImpl) Arch() Arch {
- return a.target.Arch
+func (b *baseModuleContext) MultiTargets() []Target {
+ return b.multiTargets
}
-func (a *androidBaseContextImpl) Os() OsType {
- return a.target.Os
+func (b *baseModuleContext) Arch() Arch {
+ return b.target.Arch
}
-func (a *androidBaseContextImpl) Host() bool {
- return a.target.Os.Class == Host || a.target.Os.Class == HostCross
+func (b *baseModuleContext) Os() OsType {
+ return b.target.Os
}
-func (a *androidBaseContextImpl) Device() bool {
- return a.target.Os.Class == Device
+func (b *baseModuleContext) Host() bool {
+ return b.target.Os.Class == Host || b.target.Os.Class == HostCross
}
-func (a *androidBaseContextImpl) Darwin() bool {
- return a.target.Os == Darwin
+func (b *baseModuleContext) Device() bool {
+ return b.target.Os.Class == Device
}
-func (a *androidBaseContextImpl) Fuchsia() bool {
- return a.target.Os == Fuchsia
+func (b *baseModuleContext) Darwin() bool {
+ return b.target.Os == Darwin
}
-func (a *androidBaseContextImpl) Windows() bool {
- return a.target.Os == Windows
+func (b *baseModuleContext) Fuchsia() bool {
+ return b.target.Os == Fuchsia
}
-func (a *androidBaseContextImpl) Debug() bool {
- return a.debug
+func (b *baseModuleContext) Windows() bool {
+ return b.target.Os == Windows
}
-func (a *androidBaseContextImpl) PrimaryArch() bool {
- if len(a.config.Targets[a.target.Os]) <= 1 {
+func (b *baseModuleContext) Debug() bool {
+ return b.debug
+}
+
+func (b *baseModuleContext) PrimaryArch() bool {
+ if len(b.config.Targets[b.target.Os]) <= 1 {
return true
}
- return a.target.Arch.ArchType == a.config.Targets[a.target.Os][0].Arch.ArchType
+ return b.target.Arch.ArchType == b.config.Targets[b.target.Os][0].Arch.ArchType
}
-func (a *androidBaseContextImpl) AConfig() Config {
- return a.config
+func (b *baseModuleContext) AConfig() Config {
+ return b.config
}
-func (a *androidBaseContextImpl) DeviceConfig() DeviceConfig {
- return DeviceConfig{a.config.deviceConfig}
+func (b *baseModuleContext) DeviceConfig() DeviceConfig {
+ return DeviceConfig{b.config.deviceConfig}
}
-func (a *androidBaseContextImpl) Platform() bool {
- return a.kind == platformModule
+func (b *baseModuleContext) Platform() bool {
+ return b.kind == platformModule
}
-func (a *androidBaseContextImpl) DeviceSpecific() bool {
- return a.kind == deviceSpecificModule
+func (b *baseModuleContext) DeviceSpecific() bool {
+ return b.kind == deviceSpecificModule
}
-func (a *androidBaseContextImpl) SocSpecific() bool {
- return a.kind == socSpecificModule
+func (b *baseModuleContext) SocSpecific() bool {
+ return b.kind == socSpecificModule
}
-func (a *androidBaseContextImpl) ProductSpecific() bool {
- return a.kind == productSpecificModule
+func (b *baseModuleContext) ProductSpecific() bool {
+ return b.kind == productSpecificModule
}
-func (a *androidBaseContextImpl) ProductServicesSpecific() bool {
- return a.kind == productServicesSpecificModule
+func (b *baseModuleContext) ProductServicesSpecific() bool {
+ return b.kind == productServicesSpecificModule
}
// Makes this module a platform module, i.e. not specific to soc, device,
// product, or product_services.
-func (a *ModuleBase) MakeAsPlatform() {
- a.commonProperties.Vendor = boolPtr(false)
- a.commonProperties.Proprietary = boolPtr(false)
- a.commonProperties.Soc_specific = boolPtr(false)
- a.commonProperties.Product_specific = boolPtr(false)
- a.commonProperties.Product_services_specific = boolPtr(false)
+func (m *ModuleBase) MakeAsPlatform() {
+ m.commonProperties.Vendor = boolPtr(false)
+ m.commonProperties.Proprietary = boolPtr(false)
+ m.commonProperties.Soc_specific = boolPtr(false)
+ m.commonProperties.Product_specific = boolPtr(false)
+ m.commonProperties.Product_services_specific = boolPtr(false)
}
-func (a *ModuleBase) EnableNativeBridgeSupportByDefault() {
- a.commonProperties.Native_bridge_supported = boolPtr(true)
+func (m *ModuleBase) EnableNativeBridgeSupportByDefault() {
+ m.commonProperties.Native_bridge_supported = boolPtr(true)
}
-func (a *androidModuleContext) InstallInData() bool {
- return a.module.InstallInData()
+func (m *moduleContext) InstallInData() bool {
+ return m.module.InstallInData()
}
-func (a *androidModuleContext) InstallInSanitizerDir() bool {
- return a.module.InstallInSanitizerDir()
+func (m *moduleContext) InstallInSanitizerDir() bool {
+ return m.module.InstallInSanitizerDir()
}
-func (a *androidModuleContext) InstallInRecovery() bool {
- return a.module.InstallInRecovery()
+func (m *moduleContext) InstallInRecovery() bool {
+ return m.module.InstallInRecovery()
}
-func (a *androidModuleContext) skipInstall(fullInstallPath OutputPath) bool {
- if a.module.base().commonProperties.SkipInstall {
+func (m *moduleContext) skipInstall(fullInstallPath OutputPath) bool {
+ if m.module.base().commonProperties.SkipInstall {
return true
}
// We'll need a solution for choosing which of modules with the same name in different
// namespaces to install. For now, reuse the list of namespaces exported to Make as the
// list of namespaces to install in a Soong-only build.
- if !a.module.base().commonProperties.NamespaceExportedToMake {
+ if !m.module.base().commonProperties.NamespaceExportedToMake {
return true
}
- if a.Device() {
- if a.Config().SkipDeviceInstall() {
+ if m.Device() {
+ if m.Config().SkipDeviceInstall() {
return true
}
- if a.Config().SkipMegaDeviceInstall(fullInstallPath.String()) {
+ if m.Config().SkipMegaDeviceInstall(fullInstallPath.String()) {
return true
}
}
@@ -1340,29 +1366,29 @@
return false
}
-func (a *androidModuleContext) InstallFile(installPath OutputPath, name string, srcPath Path,
+func (m *moduleContext) InstallFile(installPath OutputPath, name string, srcPath Path,
deps ...Path) OutputPath {
- return a.installFile(installPath, name, srcPath, Cp, deps)
+ return m.installFile(installPath, name, srcPath, Cp, deps)
}
-func (a *androidModuleContext) InstallExecutable(installPath OutputPath, name string, srcPath Path,
+func (m *moduleContext) InstallExecutable(installPath OutputPath, name string, srcPath Path,
deps ...Path) OutputPath {
- return a.installFile(installPath, name, srcPath, CpExecutable, deps)
+ return m.installFile(installPath, name, srcPath, CpExecutable, deps)
}
-func (a *androidModuleContext) installFile(installPath OutputPath, name string, srcPath Path,
+func (m *moduleContext) installFile(installPath OutputPath, name string, srcPath Path,
rule blueprint.Rule, deps []Path) OutputPath {
- fullInstallPath := installPath.Join(a, name)
- a.module.base().hooks.runInstallHooks(a, fullInstallPath, false)
+ fullInstallPath := installPath.Join(m, name)
+ m.module.base().hooks.runInstallHooks(m, fullInstallPath, false)
- if !a.skipInstall(fullInstallPath) {
+ if !m.skipInstall(fullInstallPath) {
- deps = append(deps, a.installDeps...)
+ deps = append(deps, m.installDeps...)
var implicitDeps, orderOnlyDeps Paths
- if a.Host() {
+ if m.Host() {
// Installed host modules might be used during the build, depend directly on their
// dependencies so their timestamp is updated whenever their dependency is updated
implicitDeps = deps
@@ -1370,73 +1396,73 @@
orderOnlyDeps = deps
}
- a.Build(pctx, BuildParams{
+ m.Build(pctx, BuildParams{
Rule: rule,
Description: "install " + fullInstallPath.Base(),
Output: fullInstallPath,
Input: srcPath,
Implicits: implicitDeps,
OrderOnly: orderOnlyDeps,
- Default: !a.Config().EmbeddedInMake(),
+ Default: !m.Config().EmbeddedInMake(),
})
- a.installFiles = append(a.installFiles, fullInstallPath)
+ m.installFiles = append(m.installFiles, fullInstallPath)
}
- a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
+ m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
return fullInstallPath
}
-func (a *androidModuleContext) InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath {
- fullInstallPath := installPath.Join(a, name)
- a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
+func (m *moduleContext) InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath {
+ fullInstallPath := installPath.Join(m, name)
+ m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)
- if !a.skipInstall(fullInstallPath) {
+ if !m.skipInstall(fullInstallPath) {
relPath, err := filepath.Rel(path.Dir(fullInstallPath.String()), srcPath.String())
if err != nil {
panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
}
- a.Build(pctx, BuildParams{
+ m.Build(pctx, BuildParams{
Rule: Symlink,
Description: "install symlink " + fullInstallPath.Base(),
Output: fullInstallPath,
OrderOnly: Paths{srcPath},
- Default: !a.Config().EmbeddedInMake(),
+ Default: !m.Config().EmbeddedInMake(),
Args: map[string]string{
"fromPath": relPath,
},
})
- a.installFiles = append(a.installFiles, fullInstallPath)
- a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
+ m.installFiles = append(m.installFiles, fullInstallPath)
+ m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
}
return fullInstallPath
}
// installPath/name -> absPath where absPath might be a path that is available only at runtime
// (e.g. /apex/...)
-func (a *androidModuleContext) InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath {
- fullInstallPath := installPath.Join(a, name)
- a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
+func (m *moduleContext) InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath {
+ fullInstallPath := installPath.Join(m, name)
+ m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)
- if !a.skipInstall(fullInstallPath) {
- a.Build(pctx, BuildParams{
+ if !m.skipInstall(fullInstallPath) {
+ m.Build(pctx, BuildParams{
Rule: Symlink,
Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
Output: fullInstallPath,
- Default: !a.Config().EmbeddedInMake(),
+ Default: !m.Config().EmbeddedInMake(),
Args: map[string]string{
"fromPath": absPath,
},
})
- a.installFiles = append(a.installFiles, fullInstallPath)
+ m.installFiles = append(m.installFiles, fullInstallPath)
}
return fullInstallPath
}
-func (a *androidModuleContext) CheckbuildFile(srcPath Path) {
- a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
+func (m *moduleContext) CheckbuildFile(srcPath Path) {
+ m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
}
type fileInstaller interface {
@@ -1551,54 +1577,54 @@
// be tagged with `android:"path" to support automatic source module dependency resolution.
//
// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
-func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) Paths {
- return PathsForModuleSrcExcludes(ctx, srcFiles, excludes)
+func (m *moduleContext) ExpandSources(srcFiles, excludes []string) Paths {
+ return PathsForModuleSrcExcludes(m, srcFiles, excludes)
}
// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
// be tagged with `android:"path" to support automatic source module dependency resolution.
//
// Deprecated: use PathForModuleSrc instead.
-func (ctx *androidModuleContext) ExpandSource(srcFile, prop string) Path {
- return PathForModuleSrc(ctx, srcFile)
+func (m *moduleContext) ExpandSource(srcFile, prop string) Path {
+ return PathForModuleSrc(m, srcFile)
}
// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
// the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module
// dependency resolution.
-func (ctx *androidModuleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath {
+func (m *moduleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath {
if srcFile != nil {
- return OptionalPathForPath(PathForModuleSrc(ctx, *srcFile))
+ return OptionalPathForPath(PathForModuleSrc(m, *srcFile))
}
return OptionalPath{}
}
-func (ctx *androidModuleContext) RequiredModuleNames() []string {
- return ctx.module.base().commonProperties.Required
+func (m *moduleContext) RequiredModuleNames() []string {
+ return m.module.base().commonProperties.Required
}
-func (ctx *androidModuleContext) HostRequiredModuleNames() []string {
- return ctx.module.base().commonProperties.Host_required
+func (m *moduleContext) HostRequiredModuleNames() []string {
+ return m.module.base().commonProperties.Host_required
}
-func (ctx *androidModuleContext) TargetRequiredModuleNames() []string {
- return ctx.module.base().commonProperties.Target_required
+func (m *moduleContext) TargetRequiredModuleNames() []string {
+ return m.module.base().commonProperties.Target_required
}
-func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Paths {
- ret, err := ctx.GlobWithDeps(globPattern, excludes)
+func (b *baseModuleContext) Glob(globPattern string, excludes []string) Paths {
+ ret, err := b.GlobWithDeps(globPattern, excludes)
if err != nil {
- ctx.ModuleErrorf("glob: %s", err.Error())
+ b.ModuleErrorf("glob: %s", err.Error())
}
- return pathsForModuleSrcFromFullPath(ctx, ret, true)
+ return pathsForModuleSrcFromFullPath(b, ret, true)
}
-func (ctx *androidModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
- ret, err := ctx.GlobWithDeps(globPattern, excludes)
+func (b *baseModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
+ ret, err := b.GlobWithDeps(globPattern, excludes)
if err != nil {
- ctx.ModuleErrorf("glob: %s", err.Error())
+ b.ModuleErrorf("glob: %s", err.Error())
}
- return pathsForModuleSrcFromFullPath(ctx, ret, false)
+ return pathsForModuleSrcFromFullPath(b, ret, false)
}
func init() {
diff --git a/android/mutator.go b/android/mutator.go
index 0e80249..081c2b2 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -66,8 +66,8 @@
}
type RegisterMutatorsContext interface {
- TopDown(name string, m AndroidTopDownMutator) MutatorHandle
- BottomUp(name string, m AndroidBottomUpMutator) MutatorHandle
+ TopDown(name string, m TopDownMutator) MutatorHandle
+ BottomUp(name string, m BottomUpMutator) MutatorHandle
}
type RegisterMutatorFunc func(RegisterMutatorsContext)
@@ -110,52 +110,27 @@
postDeps = append(postDeps, f)
}
-type AndroidTopDownMutator func(TopDownMutatorContext)
+type TopDownMutator func(TopDownMutatorContext)
type TopDownMutatorContext interface {
BaseModuleContext
- androidBaseContext
- OtherModuleExists(name string) bool
Rename(name string)
- Module() Module
-
- OtherModuleName(m blueprint.Module) string
- OtherModuleDir(m blueprint.Module) string
- OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
- OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
CreateModule(blueprint.ModuleFactory, ...interface{})
-
- GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
- GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
-
- VisitDirectDeps(visit func(Module))
- VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
- VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
- VisitDepsDepthFirst(visit func(Module))
- VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
- WalkDeps(visit func(Module, Module) bool)
- // GetWalkPath is supposed to be called in visit function passed in WalkDeps()
- // and returns a top-down dependency path from a start module to current child module.
- GetWalkPath() []Module
}
-type androidTopDownMutatorContext struct {
- blueprint.TopDownMutatorContext
- androidBaseContextImpl
- walkPath []Module
+type topDownMutatorContext struct {
+ bp blueprint.TopDownMutatorContext
+ baseModuleContext
}
-type AndroidBottomUpMutator func(BottomUpMutatorContext)
+type BottomUpMutator func(BottomUpMutatorContext)
type BottomUpMutatorContext interface {
BaseModuleContext
- androidBaseContext
- OtherModuleExists(name string) bool
Rename(name string)
- Module() blueprint.Module
AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string)
AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string)
@@ -168,17 +143,17 @@
ReplaceDependencies(string)
}
-type androidBottomUpMutatorContext struct {
- blueprint.BottomUpMutatorContext
- androidBaseContextImpl
+type bottomUpMutatorContext struct {
+ bp blueprint.BottomUpMutatorContext
+ baseModuleContext
}
-func (x *registerMutatorsContext) BottomUp(name string, m AndroidBottomUpMutator) MutatorHandle {
+func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle {
f := func(ctx blueprint.BottomUpMutatorContext) {
if a, ok := ctx.Module().(Module); ok {
- actx := &androidBottomUpMutatorContext{
- BottomUpMutatorContext: ctx,
- androidBaseContextImpl: a.base().androidBaseContextFactory(ctx),
+ actx := &bottomUpMutatorContext{
+ bp: ctx,
+ baseModuleContext: a.base().baseModuleContextFactory(ctx),
}
m(actx)
}
@@ -188,12 +163,12 @@
return mutator
}
-func (x *registerMutatorsContext) TopDown(name string, m AndroidTopDownMutator) MutatorHandle {
+func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) MutatorHandle {
f := func(ctx blueprint.TopDownMutatorContext) {
if a, ok := ctx.Module().(Module); ok {
- actx := &androidTopDownMutatorContext{
- TopDownMutatorContext: ctx,
- androidBaseContextImpl: a.base().androidBaseContextFactory(ctx),
+ actx := &topDownMutatorContext{
+ bp: ctx,
+ baseModuleContext: a.base().baseModuleContextFactory(ctx),
}
m(actx)
}
@@ -218,106 +193,13 @@
}
}
-func (a *androidTopDownMutatorContext) Config() Config {
- return a.config
-}
-
-func (a *androidBottomUpMutatorContext) Config() Config {
- return a.config
-}
-
-func (a *androidTopDownMutatorContext) Module() Module {
- module, _ := a.TopDownMutatorContext.Module().(Module)
- return module
-}
-
-func (a *androidTopDownMutatorContext) VisitDirectDeps(visit func(Module)) {
- a.TopDownMutatorContext.VisitDirectDeps(func(module blueprint.Module) {
- if aModule, _ := module.(Module); aModule != nil {
- visit(aModule)
- }
- })
-}
-
-func (a *androidTopDownMutatorContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
- a.TopDownMutatorContext.VisitDirectDeps(func(module blueprint.Module) {
- if aModule, _ := module.(Module); aModule != nil {
- if a.TopDownMutatorContext.OtherModuleDependencyTag(aModule) == tag {
- visit(aModule)
- }
- }
- })
-}
-
-func (a *androidTopDownMutatorContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
- a.TopDownMutatorContext.VisitDirectDepsIf(
- // pred
- func(module blueprint.Module) bool {
- if aModule, _ := module.(Module); aModule != nil {
- return pred(aModule)
- } else {
- return false
- }
- },
- // visit
- func(module blueprint.Module) {
- visit(module.(Module))
- })
-}
-
-func (a *androidTopDownMutatorContext) VisitDepsDepthFirst(visit func(Module)) {
- a.TopDownMutatorContext.VisitDepsDepthFirst(func(module blueprint.Module) {
- if aModule, _ := module.(Module); aModule != nil {
- visit(aModule)
- }
- })
-}
-
-func (a *androidTopDownMutatorContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
- a.TopDownMutatorContext.VisitDepsDepthFirstIf(
- // pred
- func(module blueprint.Module) bool {
- if aModule, _ := module.(Module); aModule != nil {
- return pred(aModule)
- } else {
- return false
- }
- },
- // visit
- func(module blueprint.Module) {
- visit(module.(Module))
- })
-}
-
-func (a *androidTopDownMutatorContext) WalkDeps(visit func(Module, Module) bool) {
- a.walkPath = []Module{a.Module()}
- a.TopDownMutatorContext.WalkDeps(func(child, parent blueprint.Module) bool {
- childAndroidModule, _ := child.(Module)
- parentAndroidModule, _ := parent.(Module)
- if childAndroidModule != nil && parentAndroidModule != nil {
- // record walkPath before visit
- for a.walkPath[len(a.walkPath)-1] != parentAndroidModule {
- a.walkPath = a.walkPath[0 : len(a.walkPath)-1]
- }
- a.walkPath = append(a.walkPath, childAndroidModule)
- return visit(childAndroidModule, parentAndroidModule)
- } else {
- return false
- }
- })
-}
-
-func (a *androidTopDownMutatorContext) GetWalkPath() []Module {
- return a.walkPath
-}
-
-func (a *androidTopDownMutatorContext) AppendProperties(props ...interface{}) {
+func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {
for _, p := range props {
- err := proptools.AppendMatchingProperties(a.Module().base().customizableProperties,
+ err := proptools.AppendMatchingProperties(t.Module().base().customizableProperties,
p, nil)
if err != nil {
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
- a.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
+ t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
} else {
panic(err)
}
@@ -325,16 +207,74 @@
}
}
-func (a *androidTopDownMutatorContext) PrependProperties(props ...interface{}) {
+func (t *topDownMutatorContext) PrependProperties(props ...interface{}) {
for _, p := range props {
- err := proptools.PrependMatchingProperties(a.Module().base().customizableProperties,
+ err := proptools.PrependMatchingProperties(t.Module().base().customizableProperties,
p, nil)
if err != nil {
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
- a.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
+ t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
} else {
panic(err)
}
}
}
}
+
+// android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that
+// has an overridden version in android.BaseModuleContext has to be manually forwarded to BaseModuleContext to avoid
+// ambiguous method errors, or it has to store a blueprint.TopDownMutatorContext non-embedded, in which case every
+// non-overridden method has to be forwarded. There are fewer non-overridden methods, so use the latter. The following
+// methods forward to the identical blueprint versions for topDownMutatorContext and bottomUpMutatorContext.
+
+func (t *topDownMutatorContext) Rename(name string) {
+ t.bp.Rename(name)
+}
+
+func (t *topDownMutatorContext) CreateModule(factory blueprint.ModuleFactory, props ...interface{}) {
+ t.bp.CreateModule(factory, props...)
+}
+
+func (b *bottomUpMutatorContext) Rename(name string) {
+ b.bp.Rename(name)
+}
+
+func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) {
+ b.bp.AddDependency(module, tag, name...)
+}
+
+func (b *bottomUpMutatorContext) AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) {
+ b.bp.AddReverseDependency(module, tag, name)
+}
+
+func (b *bottomUpMutatorContext) CreateVariations(variations ...string) []blueprint.Module {
+ return b.bp.CreateVariations(variations...)
+}
+
+func (b *bottomUpMutatorContext) CreateLocalVariations(variations ...string) []blueprint.Module {
+ return b.bp.CreateLocalVariations(variations...)
+}
+
+func (b *bottomUpMutatorContext) SetDependencyVariation(variation string) {
+ b.bp.SetDependencyVariation(variation)
+}
+
+func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag,
+ names ...string) {
+
+ b.bp.AddVariationDependencies(variations, tag, names...)
+}
+
+func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation,
+ tag blueprint.DependencyTag, names ...string) {
+
+ b.bp.AddFarVariationDependencies(variations, tag, names...)
+}
+
+func (b *bottomUpMutatorContext) AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) {
+ b.bp.AddInterVariantDependency(tag, from, to)
+}
+
+func (b *bottomUpMutatorContext) ReplaceDependencies(name string) {
+ b.bp.ReplaceDependencies(name)
+}
diff --git a/android/paths.go b/android/paths.go
index 3915ff4..20b8b82 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -41,9 +41,7 @@
var _ PathContext = ModuleContext(nil)
type ModuleInstallPathContext interface {
- PathContext
-
- androidBaseContext
+ BaseModuleContext
InstallInData() bool
InstallInSanitizerDir() bool
@@ -369,7 +367,7 @@
// 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
// filenames.
-func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string, incDirs bool) Paths {
+func pathsForModuleSrcFromFullPath(ctx BaseModuleContext, paths []string, incDirs bool) Paths {
prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
if prefix == "./" {
prefix = ""
diff --git a/android/paths_test.go b/android/paths_test.go
index 85c8d84..78cfbbe 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -200,7 +200,7 @@
}
type moduleInstallPathContextImpl struct {
- androidBaseContextImpl
+ baseModuleContext
inData bool
inSanitizerDir bool
@@ -212,7 +212,7 @@
}
func (m moduleInstallPathContextImpl) Config() Config {
- return m.androidBaseContextImpl.config
+ return m.baseModuleContext.config
}
func (moduleInstallPathContextImpl) AddNinjaFileDeps(deps ...string) {}
@@ -244,7 +244,7 @@
{
name: "host binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: hostTarget,
},
},
@@ -255,7 +255,7 @@
{
name: "system binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
},
},
@@ -265,7 +265,7 @@
{
name: "vendor binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: socSpecificModule,
},
@@ -276,7 +276,7 @@
{
name: "odm binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: deviceSpecificModule,
},
@@ -287,7 +287,7 @@
{
name: "product binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: productSpecificModule,
},
@@ -298,7 +298,7 @@
{
name: "product_services binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: productServicesSpecificModule,
},
@@ -310,7 +310,7 @@
{
name: "system native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
},
inData: true,
@@ -321,7 +321,7 @@
{
name: "vendor native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: socSpecificModule,
},
@@ -333,7 +333,7 @@
{
name: "odm native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: deviceSpecificModule,
},
@@ -345,7 +345,7 @@
{
name: "product native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: productSpecificModule,
},
@@ -358,7 +358,7 @@
{
name: "product_services native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: productServicesSpecificModule,
},
@@ -371,7 +371,7 @@
{
name: "sanitized system binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
},
inSanitizerDir: true,
@@ -382,7 +382,7 @@
{
name: "sanitized vendor binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: socSpecificModule,
},
@@ -394,7 +394,7 @@
{
name: "sanitized odm binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: deviceSpecificModule,
},
@@ -406,7 +406,7 @@
{
name: "sanitized product binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: productSpecificModule,
},
@@ -419,7 +419,7 @@
{
name: "sanitized product_services binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: productServicesSpecificModule,
},
@@ -432,7 +432,7 @@
{
name: "sanitized system native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
},
inData: true,
@@ -444,7 +444,7 @@
{
name: "sanitized vendor native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: socSpecificModule,
},
@@ -457,7 +457,7 @@
{
name: "sanitized odm native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: deviceSpecificModule,
},
@@ -470,7 +470,7 @@
{
name: "sanitized product native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: productSpecificModule,
},
@@ -483,7 +483,7 @@
{
name: "sanitized product_services native test binary",
ctx: &moduleInstallPathContextImpl{
- androidBaseContextImpl: androidBaseContextImpl{
+ baseModuleContext: baseModuleContext{
target: deviceTarget,
kind: productServicesSpecificModule,
},
@@ -497,7 +497,7 @@
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
- tc.ctx.androidBaseContextImpl.config = testConfig
+ tc.ctx.baseModuleContext.config = testConfig
output := PathForModuleInstall(tc.ctx, tc.in...)
if output.basePath.path != tc.out {
t.Errorf("unexpected path:\n got: %q\nwant: %q\n",
diff --git a/android/variable.go b/android/variable.go
index d039a16..b4f31c6 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -402,12 +402,12 @@
}
}
-func (a *ModuleBase) setVariableProperties(ctx BottomUpMutatorContext,
+func (m *ModuleBase) setVariableProperties(ctx BottomUpMutatorContext,
prefix string, productVariablePropertyValue reflect.Value, variableValue interface{}) {
printfIntoProperties(ctx, prefix, productVariablePropertyValue, variableValue)
- err := proptools.AppendMatchingProperties(a.generalProperties,
+ err := proptools.AppendMatchingProperties(m.generalProperties,
productVariablePropertyValue.Addr().Interface(), nil)
if err != nil {
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
diff --git a/apex/apex.go b/apex/apex.go
index aed7d6f..41a21c9 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -552,7 +552,7 @@
}
}
-func (a *apexBundle) getCertString(ctx android.BaseContext) string {
+func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
if overridden {
return ":" + certificate
diff --git a/cc/cc.go b/cc/cc.go
index e61857d..559fe4b 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -278,7 +278,7 @@
}
type BaseModuleContext interface {
- android.BaseContext
+ android.BaseModuleContext
ModuleContextIntf
}
@@ -641,7 +641,7 @@
}
type baseModuleContext struct {
- android.BaseContext
+ android.BaseModuleContext
moduleContextImpl
}
@@ -1040,7 +1040,7 @@
}
}
-func (c *Module) toolchain(ctx android.BaseContext) config.Toolchain {
+func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
if c.cachedToolchain == nil {
c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
}
@@ -1161,7 +1161,7 @@
func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
ctx := &baseModuleContext{
- BaseContext: actx,
+ BaseModuleContext: actx,
moduleContextImpl: moduleContextImpl{
mod: c,
},
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index ff990b5..44f773c 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -121,7 +121,7 @@
}
}
-func normalizeNdkApiLevel(ctx android.BaseContext, apiLevel string,
+func normalizeNdkApiLevel(ctx android.BaseModuleContext, apiLevel string,
arch android.Arch) (string, error) {
if apiLevel == "current" {
@@ -167,7 +167,7 @@
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.
if String(stub.properties.Unversioned_until) == "" {
return true, nil
diff --git a/java/app.go b/java/app.go
index 3c8f847..cf9354f 100644
--- a/java/app.go
+++ b/java/app.go
@@ -482,7 +482,7 @@
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())
if overridden {
return ":" + certificate
diff --git a/java/java.go b/java/java.go
index 5544f57..fee262d 100644
--- a/java/java.go
+++ b/java/java.go
@@ -380,8 +380,8 @@
}
type SdkLibraryDependency interface {
- SdkHeaderJars(ctx android.BaseContext, sdkVersion string) android.Paths
- SdkImplementationJars(ctx android.BaseContext, sdkVersion string) android.Paths
+ SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths
+ SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths
}
type SrcDependency interface {
@@ -448,11 +448,11 @@
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")
}
-func (j *Module) shouldInstrumentStatic(ctx android.BaseContext) bool {
+func (j *Module) shouldInstrumentStatic(ctx android.BaseModuleContext) bool {
return j.shouldInstrument(ctx) &&
(ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_STATIC") ||
ctx.Config().UnbundledBuild())
diff --git a/java/sdk.go b/java/sdk.go
index 506edfb..90b8fac 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -46,7 +46,7 @@
targetSdkVersion() string
}
-func sdkVersionOrDefault(ctx android.BaseContext, v string) string {
+func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string {
switch v {
case "", "current", "system_current", "test_current", "core_current":
return ctx.Config().DefaultAppTargetSdk()
@@ -57,7 +57,7 @@
// 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).
-func sdkVersionToNumber(ctx android.BaseContext, v string) (int, error) {
+func sdkVersionToNumber(ctx android.BaseModuleContext, v string) (int, error) {
switch v {
case "", "current", "test_current", "system_current", "core_current":
return ctx.Config().DefaultAppTargetSdkInt(), nil
@@ -71,7 +71,7 @@
}
}
-func sdkVersionToNumberAsString(ctx android.BaseContext, v string) (string, error) {
+func sdkVersionToNumberAsString(ctx android.BaseModuleContext, v string) (string, error) {
n, err := sdkVersionToNumber(ctx, v)
if err != nil {
return "", err
@@ -79,7 +79,7 @@
return strconv.Itoa(n), nil
}
-func decodeSdkDep(ctx android.BaseContext, sdkContext sdkContext) sdkDep {
+func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
v := sdkContext.sdkVersion()
// For PDK builds, use the latest SDK version instead of "current"
if ctx.Config().IsPdkBuild() && (v == "" || v == "current") {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 5b65c0c..e383533 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -591,7 +591,7 @@
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
if sdkVersion == "" {
api = "system"
@@ -615,7 +615,7 @@
}
// 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.
if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
return module.PrebuiltJars(ctx, sdkVersion)
@@ -631,7 +631,7 @@
}
// 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.
if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
return module.PrebuiltJars(ctx, sdkVersion)
@@ -840,13 +840,13 @@
}
// 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.
return module.stubsPath
}
// 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.
return module.stubsPath
}