Loading android/base_module_context.go +45 −6 Original line number Diff line number Diff line Loading @@ -136,12 +136,14 @@ type BaseModuleContext interface { // multiple direct dependencies on the same module visit will be called multiple times on // that module and OtherModuleDependencyTag will return a different tag for each. // // The Module passed to the visit function should not be retained outside of the visit function, it may be // The ModuleProxy passed to the visit function should not be retained outside of the visit function, it may be // invalidated by future mutators. VisitDirectDepsProxyAllowDisabled(visit func(proxy Module)) VisitDirectDepsProxyAllowDisabled(visit func(proxy ModuleProxy)) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) VisitDirectDepsProxyWithTag(tag blueprint.DependencyTag, visit func(proxy ModuleProxy)) // VisitDirectDepsIf calls pred for each direct dependency, and if pred returns true calls visit. If there are // multiple direct dependencies on the same module pred and visit will be called multiple times on that module and // OtherModuleDependencyTag will return a different tag for each. It skips any Loading Loading @@ -173,7 +175,7 @@ type BaseModuleContext interface { // // The Modules passed to the visit function should not be retained outside of the visit function, they may be // invalidated by future mutators. WalkDepsProxy(visit func(child, parent Module) bool) WalkDepsProxy(visit func(child, parent ModuleProxy) 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. Loading Loading @@ -314,6 +316,7 @@ func (b *baseModuleContext) getMissingDependencies() []string { type AllowDisabledModuleDependency interface { blueprint.DependencyTag AllowDisabledModuleDependency(target Module) bool AllowDisabledModuleDependencyProxy(ctx OtherModuleProviderContext, target ModuleProxy) bool } type AlwaysAllowDisabledModuleDependencyTag struct{} Loading @@ -322,6 +325,10 @@ func (t AlwaysAllowDisabledModuleDependencyTag) AllowDisabledModuleDependency(Mo return true } func (t AlwaysAllowDisabledModuleDependencyTag) AllowDisabledModuleDependencyProxy(OtherModuleProviderContext, ModuleProxy) bool { return true } func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag blueprint.DependencyTag, strict bool) Module { aModule, _ := module.(Module) Loading @@ -346,6 +353,28 @@ func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag b return aModule } func (b *baseModuleContext) validateAndroidModuleProxy( module blueprint.ModuleProxy, tag blueprint.DependencyTag, strict bool) *ModuleProxy { aModule := ModuleProxy{module: module} if !strict { return &aModule } if !OtherModuleProviderOrDefault(b, module, CommonPropertiesProviderKey).Enabled { if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependencyProxy(b, aModule) { if b.Config().AllowMissingDependencies() { b.AddMissingDependencies([]string{b.OtherModuleName(aModule)}) } else { b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule)) } } return nil } return &aModule } type dep struct { mod blueprint.Module tag blueprint.DependencyTag Loading Loading @@ -426,7 +455,7 @@ func (b *baseModuleContext) VisitDirectDepsAllowDisabled(visit func(Module)) { }) } func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy Module)) { func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy ModuleProxy)) { b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) { visit(ModuleProxy{ module: module, Loading @@ -437,13 +466,23 @@ func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy M func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) { b.bp.VisitDirectDeps(func(module blueprint.Module) { if b.bp.OtherModuleDependencyTag(module) == tag { if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil { if aModule := b.validateAndroidModule(module, tag, b.strictVisitDeps); aModule != nil { visit(aModule) } } }) } func (b *baseModuleContext) VisitDirectDepsProxyWithTag(tag blueprint.DependencyTag, visit func(proxy ModuleProxy)) { b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) { if b.bp.OtherModuleDependencyTag(module) == tag { if aModule := b.validateAndroidModuleProxy(module, tag, b.strictVisitDeps); aModule != nil { visit(*aModule) } } }) } func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) { b.bp.VisitDirectDepsIf( // pred Loading Loading @@ -505,7 +544,7 @@ func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) { }) } func (b *baseModuleContext) WalkDepsProxy(visit func(Module, Module) bool) { func (b *baseModuleContext) WalkDepsProxy(visit func(ModuleProxy, ModuleProxy) bool) { b.walkPath = []Module{ModuleProxy{blueprint.CreateModuleProxy(b.Module())}} b.tagPath = []blueprint.DependencyTag{} b.bp.WalkDepsProxy(func(child, parent blueprint.ModuleProxy) bool { Loading android/prebuilt.go +4 −4 Original line number Diff line number Diff line Loading @@ -362,10 +362,10 @@ func GetEmbeddedPrebuilt(module Module) *Prebuilt { // the right module. This function is only safe to call after all TransitionMutators // have run, e.g. in GenerateAndroidBuildActions. func PrebuiltGetPreferred(ctx BaseModuleContext, module Module) Module { if !module.IsReplacedByPrebuilt() { if !OtherModuleProviderOrDefault(ctx, module, CommonPropertiesProviderKey).ReplacedByPrebuilt { return module } if IsModulePrebuilt(module) { if _, ok := OtherModuleProvider(ctx, module, PrebuiltModuleProviderKey); ok { // If we're given a prebuilt then assume there's no source module around. return module } Loading @@ -373,11 +373,11 @@ func PrebuiltGetPreferred(ctx BaseModuleContext, module Module) Module { sourceModDepFound := false var prebuiltMod Module ctx.WalkDeps(func(child, parent Module) bool { ctx.WalkDepsProxy(func(child, parent ModuleProxy) bool { if prebuiltMod != nil { return false } if parent == ctx.Module() { if ctx.EqualModules(parent, ctx.Module()) { // First level: Only recurse if the module is found as a direct dependency. sourceModDepFound = child == module return sourceModDepFound Loading android/proto.go +4 −4 Original line number Diff line number Diff line Loading @@ -74,14 +74,14 @@ func GetProtoFlags(ctx ModuleContext, p *ProtoProperties) ProtoFlags { flags = append(flags, JoinWithPrefix(rootProtoIncludeDirs.Strings(), "-I")) } ctx.VisitDirectDepsWithTag(ProtoPluginDepTag, func(dep Module) { if hostTool, ok := dep.(HostToolProvider); !ok || !hostTool.HostToolPath().Valid() { ctx.VisitDirectDepsProxyWithTag(ProtoPluginDepTag, func(dep ModuleProxy) { if h, ok := OtherModuleProvider(ctx, dep, HostToolProviderKey); !ok || !h.HostToolPath.Valid() { ctx.PropertyErrorf("proto.plugin", "module %q is not a host tool provider", ctx.OtherModuleName(dep)) } else { plugin := String(p.Proto.Plugin) deps = append(deps, hostTool.HostToolPath().Path()) flags = append(flags, "--plugin=protoc-gen-"+plugin+"="+hostTool.HostToolPath().String()) deps = append(deps, h.HostToolPath.Path()) flags = append(flags, "--plugin=protoc-gen-"+plugin+"="+h.HostToolPath.String()) } }) Loading cc/sanitize.go +1 −4 Original line number Diff line number Diff line Loading @@ -1830,10 +1830,7 @@ func sanitizerLibrariesTxtFactory() android.Module { type sanitizerLibraryDependencyTag struct { blueprint.BaseDependencyTag } func (t sanitizerLibraryDependencyTag) AllowDisabledModuleDependency(target android.Module) bool { return true android.AlwaysAllowDisabledModuleDependencyTag } var _ android.AllowDisabledModuleDependency = (*sanitizerLibraryDependencyTag)(nil) Loading dexpreopt/config.go +6 −0 Original line number Diff line number Diff line Loading @@ -462,6 +462,12 @@ func (d dex2oatDependencyTag) AllowDisabledModuleDependency(target android.Modul return target.IsReplacedByPrebuilt() } func (d dex2oatDependencyTag) AllowDisabledModuleDependencyProxy( ctx android.OtherModuleProviderContext, target android.ModuleProxy) bool { return android.OtherModuleProviderOrDefault( ctx, target, android.CommonPropertiesProviderKey).ReplacedByPrebuilt } // Dex2oatDepTag represents the dependency onto the dex2oatd module. It is added to any module that // needs dexpreopting and so it makes no sense for it to be checked for visibility or included in // the apex. Loading Loading
android/base_module_context.go +45 −6 Original line number Diff line number Diff line Loading @@ -136,12 +136,14 @@ type BaseModuleContext interface { // multiple direct dependencies on the same module visit will be called multiple times on // that module and OtherModuleDependencyTag will return a different tag for each. // // The Module passed to the visit function should not be retained outside of the visit function, it may be // The ModuleProxy passed to the visit function should not be retained outside of the visit function, it may be // invalidated by future mutators. VisitDirectDepsProxyAllowDisabled(visit func(proxy Module)) VisitDirectDepsProxyAllowDisabled(visit func(proxy ModuleProxy)) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) VisitDirectDepsProxyWithTag(tag blueprint.DependencyTag, visit func(proxy ModuleProxy)) // VisitDirectDepsIf calls pred for each direct dependency, and if pred returns true calls visit. If there are // multiple direct dependencies on the same module pred and visit will be called multiple times on that module and // OtherModuleDependencyTag will return a different tag for each. It skips any Loading Loading @@ -173,7 +175,7 @@ type BaseModuleContext interface { // // The Modules passed to the visit function should not be retained outside of the visit function, they may be // invalidated by future mutators. WalkDepsProxy(visit func(child, parent Module) bool) WalkDepsProxy(visit func(child, parent ModuleProxy) 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. Loading Loading @@ -314,6 +316,7 @@ func (b *baseModuleContext) getMissingDependencies() []string { type AllowDisabledModuleDependency interface { blueprint.DependencyTag AllowDisabledModuleDependency(target Module) bool AllowDisabledModuleDependencyProxy(ctx OtherModuleProviderContext, target ModuleProxy) bool } type AlwaysAllowDisabledModuleDependencyTag struct{} Loading @@ -322,6 +325,10 @@ func (t AlwaysAllowDisabledModuleDependencyTag) AllowDisabledModuleDependency(Mo return true } func (t AlwaysAllowDisabledModuleDependencyTag) AllowDisabledModuleDependencyProxy(OtherModuleProviderContext, ModuleProxy) bool { return true } func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag blueprint.DependencyTag, strict bool) Module { aModule, _ := module.(Module) Loading @@ -346,6 +353,28 @@ func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag b return aModule } func (b *baseModuleContext) validateAndroidModuleProxy( module blueprint.ModuleProxy, tag blueprint.DependencyTag, strict bool) *ModuleProxy { aModule := ModuleProxy{module: module} if !strict { return &aModule } if !OtherModuleProviderOrDefault(b, module, CommonPropertiesProviderKey).Enabled { if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependencyProxy(b, aModule) { if b.Config().AllowMissingDependencies() { b.AddMissingDependencies([]string{b.OtherModuleName(aModule)}) } else { b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule)) } } return nil } return &aModule } type dep struct { mod blueprint.Module tag blueprint.DependencyTag Loading Loading @@ -426,7 +455,7 @@ func (b *baseModuleContext) VisitDirectDepsAllowDisabled(visit func(Module)) { }) } func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy Module)) { func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy ModuleProxy)) { b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) { visit(ModuleProxy{ module: module, Loading @@ -437,13 +466,23 @@ func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy M func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) { b.bp.VisitDirectDeps(func(module blueprint.Module) { if b.bp.OtherModuleDependencyTag(module) == tag { if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil { if aModule := b.validateAndroidModule(module, tag, b.strictVisitDeps); aModule != nil { visit(aModule) } } }) } func (b *baseModuleContext) VisitDirectDepsProxyWithTag(tag blueprint.DependencyTag, visit func(proxy ModuleProxy)) { b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) { if b.bp.OtherModuleDependencyTag(module) == tag { if aModule := b.validateAndroidModuleProxy(module, tag, b.strictVisitDeps); aModule != nil { visit(*aModule) } } }) } func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) { b.bp.VisitDirectDepsIf( // pred Loading Loading @@ -505,7 +544,7 @@ func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) { }) } func (b *baseModuleContext) WalkDepsProxy(visit func(Module, Module) bool) { func (b *baseModuleContext) WalkDepsProxy(visit func(ModuleProxy, ModuleProxy) bool) { b.walkPath = []Module{ModuleProxy{blueprint.CreateModuleProxy(b.Module())}} b.tagPath = []blueprint.DependencyTag{} b.bp.WalkDepsProxy(func(child, parent blueprint.ModuleProxy) bool { Loading
android/prebuilt.go +4 −4 Original line number Diff line number Diff line Loading @@ -362,10 +362,10 @@ func GetEmbeddedPrebuilt(module Module) *Prebuilt { // the right module. This function is only safe to call after all TransitionMutators // have run, e.g. in GenerateAndroidBuildActions. func PrebuiltGetPreferred(ctx BaseModuleContext, module Module) Module { if !module.IsReplacedByPrebuilt() { if !OtherModuleProviderOrDefault(ctx, module, CommonPropertiesProviderKey).ReplacedByPrebuilt { return module } if IsModulePrebuilt(module) { if _, ok := OtherModuleProvider(ctx, module, PrebuiltModuleProviderKey); ok { // If we're given a prebuilt then assume there's no source module around. return module } Loading @@ -373,11 +373,11 @@ func PrebuiltGetPreferred(ctx BaseModuleContext, module Module) Module { sourceModDepFound := false var prebuiltMod Module ctx.WalkDeps(func(child, parent Module) bool { ctx.WalkDepsProxy(func(child, parent ModuleProxy) bool { if prebuiltMod != nil { return false } if parent == ctx.Module() { if ctx.EqualModules(parent, ctx.Module()) { // First level: Only recurse if the module is found as a direct dependency. sourceModDepFound = child == module return sourceModDepFound Loading
android/proto.go +4 −4 Original line number Diff line number Diff line Loading @@ -74,14 +74,14 @@ func GetProtoFlags(ctx ModuleContext, p *ProtoProperties) ProtoFlags { flags = append(flags, JoinWithPrefix(rootProtoIncludeDirs.Strings(), "-I")) } ctx.VisitDirectDepsWithTag(ProtoPluginDepTag, func(dep Module) { if hostTool, ok := dep.(HostToolProvider); !ok || !hostTool.HostToolPath().Valid() { ctx.VisitDirectDepsProxyWithTag(ProtoPluginDepTag, func(dep ModuleProxy) { if h, ok := OtherModuleProvider(ctx, dep, HostToolProviderKey); !ok || !h.HostToolPath.Valid() { ctx.PropertyErrorf("proto.plugin", "module %q is not a host tool provider", ctx.OtherModuleName(dep)) } else { plugin := String(p.Proto.Plugin) deps = append(deps, hostTool.HostToolPath().Path()) flags = append(flags, "--plugin=protoc-gen-"+plugin+"="+hostTool.HostToolPath().String()) deps = append(deps, h.HostToolPath.Path()) flags = append(flags, "--plugin=protoc-gen-"+plugin+"="+h.HostToolPath.String()) } }) Loading
cc/sanitize.go +1 −4 Original line number Diff line number Diff line Loading @@ -1830,10 +1830,7 @@ func sanitizerLibrariesTxtFactory() android.Module { type sanitizerLibraryDependencyTag struct { blueprint.BaseDependencyTag } func (t sanitizerLibraryDependencyTag) AllowDisabledModuleDependency(target android.Module) bool { return true android.AlwaysAllowDisabledModuleDependencyTag } var _ android.AllowDisabledModuleDependency = (*sanitizerLibraryDependencyTag)(nil) Loading
dexpreopt/config.go +6 −0 Original line number Diff line number Diff line Loading @@ -462,6 +462,12 @@ func (d dex2oatDependencyTag) AllowDisabledModuleDependency(target android.Modul return target.IsReplacedByPrebuilt() } func (d dex2oatDependencyTag) AllowDisabledModuleDependencyProxy( ctx android.OtherModuleProviderContext, target android.ModuleProxy) bool { return android.OtherModuleProviderOrDefault( ctx, target, android.CommonPropertiesProviderKey).ReplacedByPrebuilt } // Dex2oatDepTag represents the dependency onto the dex2oatd module. It is added to any module that // needs dexpreopting and so it makes no sense for it to be checked for visibility or included in // the apex. Loading