| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 1 | // Copyright 2015 Google Inc. All rights reserved. | 
|  | 2 | // | 
|  | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | // you may not use this file except in compliance with the License. | 
|  | 5 | // You may obtain a copy of the License at | 
|  | 6 | // | 
|  | 7 | //     http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | // | 
|  | 9 | // Unless required by applicable law or agreed to in writing, software | 
|  | 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 12 | // See the License for the specific language governing permissions and | 
|  | 13 | // limitations under the License. | 
|  | 14 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 15 | package android | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 16 |  | 
| Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 17 | import ( | 
| Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 18 | "github.com/google/blueprint" | 
| Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 19 | "github.com/google/blueprint/proptools" | 
| Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 20 | ) | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 21 |  | 
| Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 22 | // Phases: | 
|  | 23 | //   run Pre-arch mutators | 
|  | 24 | //   run archMutator | 
|  | 25 | //   run Pre-deps mutators | 
|  | 26 | //   run depsMutator | 
|  | 27 | //   run PostDeps mutators | 
|  | 28 | //   continue on to GenerateAndroidBuildActions | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 29 |  | 
| Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 30 | func registerMutatorsToContext(ctx *blueprint.Context, mutators []*mutator) { | 
|  | 31 | for _, t := range mutators { | 
|  | 32 | var handle blueprint.MutatorHandle | 
|  | 33 | if t.bottomUpMutator != nil { | 
|  | 34 | handle = ctx.RegisterBottomUpMutator(t.name, t.bottomUpMutator) | 
|  | 35 | } else if t.topDownMutator != nil { | 
|  | 36 | handle = ctx.RegisterTopDownMutator(t.name, t.topDownMutator) | 
|  | 37 | } | 
|  | 38 | if t.parallel { | 
|  | 39 | handle.Parallel() | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 40 | } | 
|  | 41 | } | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 42 | } | 
|  | 43 |  | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 44 | func registerMutators(ctx *blueprint.Context, preArch, preDeps, postDeps []RegisterMutatorFunc) { | 
|  | 45 | mctx := ®isterMutatorsContext{} | 
| Nan Zhang | db0b9a3 | 2017-02-27 10:12:13 -0800 | [diff] [blame] | 46 |  | 
|  | 47 | register := func(funcs []RegisterMutatorFunc) { | 
|  | 48 | for _, f := range funcs { | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 49 | f(mctx) | 
| Nan Zhang | db0b9a3 | 2017-02-27 10:12:13 -0800 | [diff] [blame] | 50 | } | 
|  | 51 | } | 
|  | 52 |  | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 53 | register(preArch) | 
| Nan Zhang | db0b9a3 | 2017-02-27 10:12:13 -0800 | [diff] [blame] | 54 |  | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 55 | register(preDeps) | 
|  | 56 |  | 
|  | 57 | mctx.BottomUp("deps", depsMutator).Parallel() | 
|  | 58 |  | 
|  | 59 | register(postDeps) | 
|  | 60 |  | 
|  | 61 | registerMutatorsToContext(ctx, mctx.mutators) | 
| Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 62 | } | 
|  | 63 |  | 
|  | 64 | type registerMutatorsContext struct { | 
|  | 65 | mutators []*mutator | 
|  | 66 | } | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 67 |  | 
|  | 68 | type RegisterMutatorsContext interface { | 
|  | 69 | TopDown(name string, m AndroidTopDownMutator) MutatorHandle | 
|  | 70 | BottomUp(name string, m AndroidBottomUpMutator) MutatorHandle | 
|  | 71 | } | 
|  | 72 |  | 
|  | 73 | type RegisterMutatorFunc func(RegisterMutatorsContext) | 
|  | 74 |  | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 75 | var preArch = []RegisterMutatorFunc{ | 
| Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 76 | registerLoadHookMutator, | 
| Dan Willemsen | 6e72ef7 | 2018-01-26 18:27:02 -0800 | [diff] [blame] | 77 | RegisterNamespaceMutator, | 
| Colin Cross | 5ea9bcc | 2017-07-27 15:41:32 -0700 | [diff] [blame] | 78 | RegisterPrebuiltsPreArchMutators, | 
| Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 79 | RegisterDefaultsPreArchMutators, | 
| Paul Duffin | 2e61fa6 | 2019-03-28 14:10:57 +0000 | [diff] [blame] | 80 | registerVisibilityRuleGatherer, | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 81 | } | 
|  | 82 |  | 
| Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 83 | func registerArchMutator(ctx RegisterMutatorsContext) { | 
|  | 84 | ctx.BottomUp("arch", archMutator).Parallel() | 
|  | 85 | ctx.TopDown("arch_hooks", archHookMutator).Parallel() | 
|  | 86 | } | 
|  | 87 |  | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 88 | var preDeps = []RegisterMutatorFunc{ | 
| Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 89 | registerArchMutator, | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 90 | } | 
|  | 91 |  | 
|  | 92 | var postDeps = []RegisterMutatorFunc{ | 
| Colin Cross | 1b48842 | 2019-03-04 22:33:56 -0800 | [diff] [blame] | 93 | registerPathDepsMutator, | 
| Colin Cross | 5ea9bcc | 2017-07-27 15:41:32 -0700 | [diff] [blame] | 94 | RegisterPrebuiltsPostDepsMutators, | 
| Paul Duffin | 2e61fa6 | 2019-03-28 14:10:57 +0000 | [diff] [blame] | 95 | registerVisibilityRuleEnforcer, | 
| Steven Moreland | 65b3fd9 | 2017-12-06 14:18:35 -0800 | [diff] [blame] | 96 | registerNeverallowMutator, | 
| Jaewoong Jung | b639a6a | 2019-05-10 15:16:29 -0700 | [diff] [blame] | 97 | RegisterOverridePostDepsMutators, | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 98 | } | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 99 |  | 
|  | 100 | func PreArchMutators(f RegisterMutatorFunc) { | 
|  | 101 | preArch = append(preArch, f) | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | func PreDepsMutators(f RegisterMutatorFunc) { | 
|  | 105 | preDeps = append(preDeps, f) | 
|  | 106 | } | 
|  | 107 |  | 
|  | 108 | func PostDepsMutators(f RegisterMutatorFunc) { | 
|  | 109 | postDeps = append(postDeps, f) | 
|  | 110 | } | 
|  | 111 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 112 | type AndroidTopDownMutator func(TopDownMutatorContext) | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 113 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 114 | type TopDownMutatorContext interface { | 
| Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 115 | BaseModuleContext | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 116 | androidBaseContext | 
| Colin Cross | 3f68a13 | 2017-10-23 17:10:29 -0700 | [diff] [blame] | 117 |  | 
|  | 118 | OtherModuleExists(name string) bool | 
|  | 119 | Rename(name string) | 
| Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 120 | Module() Module | 
| Colin Cross | 3f68a13 | 2017-10-23 17:10:29 -0700 | [diff] [blame] | 121 |  | 
|  | 122 | OtherModuleName(m blueprint.Module) string | 
| Paul Duffin | 2e61fa6 | 2019-03-28 14:10:57 +0000 | [diff] [blame] | 123 | OtherModuleDir(m blueprint.Module) string | 
| Colin Cross | 3f68a13 | 2017-10-23 17:10:29 -0700 | [diff] [blame] | 124 | OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) | 
|  | 125 | OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag | 
|  | 126 |  | 
|  | 127 | CreateModule(blueprint.ModuleFactory, ...interface{}) | 
|  | 128 |  | 
|  | 129 | GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module | 
|  | 130 | GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) | 
|  | 131 |  | 
| Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 132 | VisitDirectDeps(visit func(Module)) | 
| Colin Cross | ee6143c | 2017-12-30 17:54:27 -0800 | [diff] [blame] | 133 | VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) | 
| Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 134 | VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) | 
|  | 135 | VisitDepsDepthFirst(visit func(Module)) | 
|  | 136 | VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) | 
|  | 137 | WalkDeps(visit func(Module, Module) bool) | 
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 138 | // GetWalkPath is supposed to be called in visit function passed in WalkDeps() | 
|  | 139 | // and returns a top-down dependency path from a start module to current child module. | 
|  | 140 | GetWalkPath() []Module | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 141 | } | 
|  | 142 |  | 
|  | 143 | type androidTopDownMutatorContext struct { | 
|  | 144 | blueprint.TopDownMutatorContext | 
|  | 145 | androidBaseContextImpl | 
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 146 | walkPath []Module | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 147 | } | 
|  | 148 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 149 | type AndroidBottomUpMutator func(BottomUpMutatorContext) | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 150 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 151 | type BottomUpMutatorContext interface { | 
| Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 152 | BaseModuleContext | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 153 | androidBaseContext | 
| Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 154 |  | 
|  | 155 | OtherModuleExists(name string) bool | 
|  | 156 | Rename(name string) | 
|  | 157 | Module() blueprint.Module | 
|  | 158 |  | 
|  | 159 | AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) | 
|  | 160 | AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) | 
|  | 161 | CreateVariations(...string) []blueprint.Module | 
|  | 162 | CreateLocalVariations(...string) []blueprint.Module | 
|  | 163 | SetDependencyVariation(string) | 
|  | 164 | AddVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) | 
|  | 165 | AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) | 
|  | 166 | AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) | 
|  | 167 | ReplaceDependencies(string) | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 168 | } | 
|  | 169 |  | 
|  | 170 | type androidBottomUpMutatorContext struct { | 
|  | 171 | blueprint.BottomUpMutatorContext | 
|  | 172 | androidBaseContextImpl | 
|  | 173 | } | 
|  | 174 |  | 
| Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 175 | func (x *registerMutatorsContext) BottomUp(name string, m AndroidBottomUpMutator) MutatorHandle { | 
| Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 176 | f := func(ctx blueprint.BottomUpMutatorContext) { | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 177 | if a, ok := ctx.Module().(Module); ok { | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 178 | actx := &androidBottomUpMutatorContext{ | 
|  | 179 | BottomUpMutatorContext: ctx, | 
|  | 180 | androidBaseContextImpl: a.base().androidBaseContextFactory(ctx), | 
|  | 181 | } | 
| Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 182 | m(actx) | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 183 | } | 
| Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 184 | } | 
|  | 185 | mutator := &mutator{name: name, bottomUpMutator: f} | 
| Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 186 | x.mutators = append(x.mutators, mutator) | 
| Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 187 | return mutator | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 188 | } | 
|  | 189 |  | 
| Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 190 | func (x *registerMutatorsContext) TopDown(name string, m AndroidTopDownMutator) MutatorHandle { | 
| Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 191 | f := func(ctx blueprint.TopDownMutatorContext) { | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 192 | if a, ok := ctx.Module().(Module); ok { | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 193 | actx := &androidTopDownMutatorContext{ | 
|  | 194 | TopDownMutatorContext:  ctx, | 
|  | 195 | androidBaseContextImpl: a.base().androidBaseContextFactory(ctx), | 
|  | 196 | } | 
| Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 197 | m(actx) | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 198 | } | 
| Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 199 | } | 
|  | 200 | mutator := &mutator{name: name, topDownMutator: f} | 
| Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 201 | x.mutators = append(x.mutators, mutator) | 
| Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 202 | return mutator | 
|  | 203 | } | 
|  | 204 |  | 
|  | 205 | type MutatorHandle interface { | 
|  | 206 | Parallel() MutatorHandle | 
|  | 207 | } | 
|  | 208 |  | 
|  | 209 | func (mutator *mutator) Parallel() MutatorHandle { | 
|  | 210 | mutator.parallel = true | 
|  | 211 | return mutator | 
| Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 212 | } | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 213 |  | 
|  | 214 | func depsMutator(ctx BottomUpMutatorContext) { | 
| Colin Cross | 6db4a6a | 2018-08-30 12:52:41 -0700 | [diff] [blame] | 215 | if m, ok := ctx.Module().(Module); ok && m.Enabled() { | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 216 | m.DepsMutator(ctx) | 
|  | 217 | } | 
|  | 218 | } | 
| Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 219 |  | 
| Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 220 | func (a *androidTopDownMutatorContext) Config() Config { | 
|  | 221 | return a.config | 
|  | 222 | } | 
|  | 223 |  | 
|  | 224 | func (a *androidBottomUpMutatorContext) Config() Config { | 
|  | 225 | return a.config | 
|  | 226 | } | 
|  | 227 |  | 
| Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 228 | func (a *androidTopDownMutatorContext) Module() Module { | 
|  | 229 | module, _ := a.TopDownMutatorContext.Module().(Module) | 
|  | 230 | return module | 
|  | 231 | } | 
|  | 232 |  | 
| Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 233 | func (a *androidTopDownMutatorContext) VisitDirectDeps(visit func(Module)) { | 
|  | 234 | a.TopDownMutatorContext.VisitDirectDeps(func(module blueprint.Module) { | 
|  | 235 | if aModule, _ := module.(Module); aModule != nil { | 
|  | 236 | visit(aModule) | 
|  | 237 | } | 
|  | 238 | }) | 
|  | 239 | } | 
|  | 240 |  | 
| Colin Cross | ee6143c | 2017-12-30 17:54:27 -0800 | [diff] [blame] | 241 | func (a *androidTopDownMutatorContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) { | 
|  | 242 | a.TopDownMutatorContext.VisitDirectDeps(func(module blueprint.Module) { | 
|  | 243 | if aModule, _ := module.(Module); aModule != nil { | 
|  | 244 | if a.TopDownMutatorContext.OtherModuleDependencyTag(aModule) == tag { | 
|  | 245 | visit(aModule) | 
|  | 246 | } | 
|  | 247 | } | 
|  | 248 | }) | 
|  | 249 | } | 
|  | 250 |  | 
| Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 251 | func (a *androidTopDownMutatorContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) { | 
|  | 252 | a.TopDownMutatorContext.VisitDirectDepsIf( | 
|  | 253 | // pred | 
|  | 254 | func(module blueprint.Module) bool { | 
|  | 255 | if aModule, _ := module.(Module); aModule != nil { | 
|  | 256 | return pred(aModule) | 
|  | 257 | } else { | 
|  | 258 | return false | 
|  | 259 | } | 
|  | 260 | }, | 
|  | 261 | // visit | 
|  | 262 | func(module blueprint.Module) { | 
|  | 263 | visit(module.(Module)) | 
|  | 264 | }) | 
|  | 265 | } | 
|  | 266 |  | 
|  | 267 | func (a *androidTopDownMutatorContext) VisitDepsDepthFirst(visit func(Module)) { | 
|  | 268 | a.TopDownMutatorContext.VisitDepsDepthFirst(func(module blueprint.Module) { | 
|  | 269 | if aModule, _ := module.(Module); aModule != nil { | 
|  | 270 | visit(aModule) | 
|  | 271 | } | 
|  | 272 | }) | 
|  | 273 | } | 
|  | 274 |  | 
|  | 275 | func (a *androidTopDownMutatorContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) { | 
|  | 276 | a.TopDownMutatorContext.VisitDepsDepthFirstIf( | 
|  | 277 | // pred | 
|  | 278 | func(module blueprint.Module) bool { | 
|  | 279 | if aModule, _ := module.(Module); aModule != nil { | 
|  | 280 | return pred(aModule) | 
|  | 281 | } else { | 
|  | 282 | return false | 
|  | 283 | } | 
|  | 284 | }, | 
|  | 285 | // visit | 
|  | 286 | func(module blueprint.Module) { | 
|  | 287 | visit(module.(Module)) | 
|  | 288 | }) | 
|  | 289 | } | 
|  | 290 |  | 
|  | 291 | func (a *androidTopDownMutatorContext) WalkDeps(visit func(Module, Module) bool) { | 
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 292 | a.walkPath = []Module{a.Module()} | 
| Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 293 | a.TopDownMutatorContext.WalkDeps(func(child, parent blueprint.Module) bool { | 
|  | 294 | childAndroidModule, _ := child.(Module) | 
|  | 295 | parentAndroidModule, _ := parent.(Module) | 
|  | 296 | if childAndroidModule != nil && parentAndroidModule != nil { | 
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 297 | // record walkPath before visit | 
|  | 298 | for a.walkPath[len(a.walkPath)-1] != parentAndroidModule { | 
|  | 299 | a.walkPath = a.walkPath[0 : len(a.walkPath)-1] | 
|  | 300 | } | 
|  | 301 | a.walkPath = append(a.walkPath, childAndroidModule) | 
| Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 302 | return visit(childAndroidModule, parentAndroidModule) | 
|  | 303 | } else { | 
|  | 304 | return false | 
|  | 305 | } | 
|  | 306 | }) | 
|  | 307 | } | 
| Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 308 |  | 
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 309 | func (a *androidTopDownMutatorContext) GetWalkPath() []Module { | 
|  | 310 | return a.walkPath | 
|  | 311 | } | 
|  | 312 |  | 
| Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 313 | func (a *androidTopDownMutatorContext) AppendProperties(props ...interface{}) { | 
|  | 314 | for _, p := range props { | 
|  | 315 | err := proptools.AppendMatchingProperties(a.Module().base().customizableProperties, | 
|  | 316 | p, nil) | 
|  | 317 | if err != nil { | 
|  | 318 | if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { | 
|  | 319 | a.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) | 
|  | 320 | } else { | 
|  | 321 | panic(err) | 
|  | 322 | } | 
|  | 323 | } | 
|  | 324 | } | 
|  | 325 | } | 
|  | 326 |  | 
|  | 327 | func (a *androidTopDownMutatorContext) PrependProperties(props ...interface{}) { | 
|  | 328 | for _, p := range props { | 
|  | 329 | err := proptools.PrependMatchingProperties(a.Module().base().customizableProperties, | 
|  | 330 | p, nil) | 
|  | 331 | if err != nil { | 
|  | 332 | if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { | 
|  | 333 | a.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) | 
|  | 334 | } else { | 
|  | 335 | panic(err) | 
|  | 336 | } | 
|  | 337 | } | 
|  | 338 | } | 
|  | 339 | } |