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 | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 18 | "reflect" |
| 19 | |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 20 | "github.com/google/blueprint" |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 21 | "github.com/google/blueprint/proptools" |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 22 | ) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 23 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 24 | // Phases: |
| 25 | // run Pre-arch mutators |
| 26 | // run archMutator |
| 27 | // run Pre-deps mutators |
| 28 | // run depsMutator |
| 29 | // run PostDeps mutators |
| 30 | // continue on to GenerateAndroidBuildActions |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 31 | |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 32 | func registerMutatorsToContext(ctx *blueprint.Context, mutators []*mutator) { |
| 33 | for _, t := range mutators { |
| 34 | var handle blueprint.MutatorHandle |
| 35 | if t.bottomUpMutator != nil { |
| 36 | handle = ctx.RegisterBottomUpMutator(t.name, t.bottomUpMutator) |
| 37 | } else if t.topDownMutator != nil { |
| 38 | handle = ctx.RegisterTopDownMutator(t.name, t.topDownMutator) |
| 39 | } |
| 40 | if t.parallel { |
| 41 | handle.Parallel() |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 42 | } |
| 43 | } |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 46 | func registerMutators(ctx *blueprint.Context, preArch, preDeps, postDeps []RegisterMutatorFunc) { |
| 47 | mctx := ®isterMutatorsContext{} |
Nan Zhang | db0b9a3 | 2017-02-27 10:12:13 -0800 | [diff] [blame] | 48 | |
| 49 | register := func(funcs []RegisterMutatorFunc) { |
| 50 | for _, f := range funcs { |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 51 | f(mctx) |
Nan Zhang | db0b9a3 | 2017-02-27 10:12:13 -0800 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 55 | register(preArch) |
Nan Zhang | db0b9a3 | 2017-02-27 10:12:13 -0800 | [diff] [blame] | 56 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 57 | register(preDeps) |
| 58 | |
| 59 | mctx.BottomUp("deps", depsMutator).Parallel() |
| 60 | |
| 61 | register(postDeps) |
| 62 | |
| 63 | registerMutatorsToContext(ctx, mctx.mutators) |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | type registerMutatorsContext struct { |
| 67 | mutators []*mutator |
| 68 | } |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 69 | |
| 70 | type RegisterMutatorsContext interface { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 71 | TopDown(name string, m TopDownMutator) MutatorHandle |
| 72 | BottomUp(name string, m BottomUpMutator) MutatorHandle |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | type RegisterMutatorFunc func(RegisterMutatorsContext) |
| 76 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 77 | var preArch = []RegisterMutatorFunc{ |
Colin Cross | f8b860a | 2019-04-16 14:43:28 -0700 | [diff] [blame] | 78 | registerLoadHookMutator, |
Dan Willemsen | 6e72ef7 | 2018-01-26 18:27:02 -0800 | [diff] [blame] | 79 | RegisterNamespaceMutator, |
Paul Duffin | e2453c7 | 2019-05-31 14:00:04 +0100 | [diff] [blame] | 80 | // Rename package module types. |
| 81 | registerPackageRenamer, |
Colin Cross | 5ea9bcc | 2017-07-27 15:41:32 -0700 | [diff] [blame] | 82 | RegisterPrebuiltsPreArchMutators, |
Martin Stjernholm | 226b20d | 2019-05-17 22:42:02 +0100 | [diff] [blame] | 83 | registerVisibilityRuleChecker, |
Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 84 | RegisterDefaultsPreArchMutators, |
Paul Duffin | 2e61fa6 | 2019-03-28 14:10:57 +0000 | [diff] [blame] | 85 | registerVisibilityRuleGatherer, |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 88 | func registerArchMutator(ctx RegisterMutatorsContext) { |
| 89 | ctx.BottomUp("arch", archMutator).Parallel() |
| 90 | ctx.TopDown("arch_hooks", archHookMutator).Parallel() |
| 91 | } |
| 92 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 93 | var preDeps = []RegisterMutatorFunc{ |
Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 94 | registerArchMutator, |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | var postDeps = []RegisterMutatorFunc{ |
Colin Cross | 1b48842 | 2019-03-04 22:33:56 -0800 | [diff] [blame] | 98 | registerPathDepsMutator, |
Colin Cross | 5ea9bcc | 2017-07-27 15:41:32 -0700 | [diff] [blame] | 99 | RegisterPrebuiltsPostDepsMutators, |
Paul Duffin | 2e61fa6 | 2019-03-28 14:10:57 +0000 | [diff] [blame] | 100 | registerVisibilityRuleEnforcer, |
Steven Moreland | 65b3fd9 | 2017-12-06 14:18:35 -0800 | [diff] [blame] | 101 | registerNeverallowMutator, |
Jaewoong Jung | b639a6a | 2019-05-10 15:16:29 -0700 | [diff] [blame] | 102 | RegisterOverridePostDepsMutators, |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 103 | } |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 104 | |
| 105 | func PreArchMutators(f RegisterMutatorFunc) { |
| 106 | preArch = append(preArch, f) |
| 107 | } |
| 108 | |
| 109 | func PreDepsMutators(f RegisterMutatorFunc) { |
| 110 | preDeps = append(preDeps, f) |
| 111 | } |
| 112 | |
| 113 | func PostDepsMutators(f RegisterMutatorFunc) { |
| 114 | postDeps = append(postDeps, f) |
| 115 | } |
| 116 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 117 | type TopDownMutator func(TopDownMutatorContext) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 118 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 119 | type TopDownMutatorContext interface { |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 120 | BaseModuleContext |
Colin Cross | 3f68a13 | 2017-10-23 17:10:29 -0700 | [diff] [blame] | 121 | |
Colin Cross | cb55e08 | 2019-07-01 15:32:31 -0700 | [diff] [blame] | 122 | MutatorName() string |
| 123 | |
Colin Cross | 3f68a13 | 2017-10-23 17:10:29 -0700 | [diff] [blame] | 124 | Rename(name string) |
Colin Cross | 3f68a13 | 2017-10-23 17:10:29 -0700 | [diff] [blame] | 125 | |
Colin Cross | e003c4a | 2019-09-25 12:58:36 -0700 | [diff] [blame] | 126 | CreateModule(ModuleFactory, ...interface{}) Module |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 129 | type topDownMutatorContext struct { |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 130 | bp blueprint.TopDownMutatorContext |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 131 | baseModuleContext |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 134 | type BottomUpMutator func(BottomUpMutatorContext) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 135 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 136 | type BottomUpMutatorContext interface { |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 137 | BaseModuleContext |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 138 | |
Colin Cross | cb55e08 | 2019-07-01 15:32:31 -0700 | [diff] [blame] | 139 | MutatorName() string |
| 140 | |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 141 | Rename(name string) |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 142 | |
| 143 | AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) |
| 144 | AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) |
| 145 | CreateVariations(...string) []blueprint.Module |
| 146 | CreateLocalVariations(...string) []blueprint.Module |
| 147 | SetDependencyVariation(string) |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 148 | SetDefaultDependencyVariation(*string) |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 149 | AddVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) |
| 150 | AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) |
| 151 | AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) |
| 152 | ReplaceDependencies(string) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 153 | } |
| 154 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 155 | type bottomUpMutatorContext struct { |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 156 | bp blueprint.BottomUpMutatorContext |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 157 | baseModuleContext |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 160 | func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle { |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 161 | f := func(ctx blueprint.BottomUpMutatorContext) { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 162 | if a, ok := ctx.Module().(Module); ok { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 163 | actx := &bottomUpMutatorContext{ |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 164 | bp: ctx, |
| 165 | baseModuleContext: a.base().baseModuleContextFactory(ctx), |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 166 | } |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 167 | m(actx) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 168 | } |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 169 | } |
| 170 | mutator := &mutator{name: name, bottomUpMutator: f} |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 171 | x.mutators = append(x.mutators, mutator) |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 172 | return mutator |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 175 | func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) MutatorHandle { |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 176 | f := func(ctx blueprint.TopDownMutatorContext) { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 177 | if a, ok := ctx.Module().(Module); ok { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 178 | actx := &topDownMutatorContext{ |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 179 | bp: ctx, |
| 180 | baseModuleContext: a.base().baseModuleContextFactory(ctx), |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 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, topDownMutator: 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 |
| 188 | } |
| 189 | |
| 190 | type MutatorHandle interface { |
| 191 | Parallel() MutatorHandle |
| 192 | } |
| 193 | |
| 194 | func (mutator *mutator) Parallel() MutatorHandle { |
| 195 | mutator.parallel = true |
| 196 | return mutator |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 197 | } |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 198 | |
| 199 | func depsMutator(ctx BottomUpMutatorContext) { |
Colin Cross | 6db4a6a | 2018-08-30 12:52:41 -0700 | [diff] [blame] | 200 | if m, ok := ctx.Module().(Module); ok && m.Enabled() { |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 201 | m.DepsMutator(ctx) |
| 202 | } |
| 203 | } |
Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 204 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 205 | func (t *topDownMutatorContext) AppendProperties(props ...interface{}) { |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 206 | for _, p := range props { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 207 | err := proptools.AppendMatchingProperties(t.Module().base().customizableProperties, |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 208 | p, nil) |
| 209 | if err != nil { |
| 210 | if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 211 | t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 212 | } else { |
| 213 | panic(err) |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 219 | func (t *topDownMutatorContext) PrependProperties(props ...interface{}) { |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 220 | for _, p := range props { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 221 | err := proptools.PrependMatchingProperties(t.Module().base().customizableProperties, |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 222 | p, nil) |
| 223 | if err != nil { |
| 224 | if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 225 | t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 226 | } else { |
| 227 | panic(err) |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | } |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 232 | |
| 233 | // android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that |
| 234 | // has an overridden version in android.BaseModuleContext has to be manually forwarded to BaseModuleContext to avoid |
| 235 | // ambiguous method errors, or it has to store a blueprint.TopDownMutatorContext non-embedded, in which case every |
| 236 | // non-overridden method has to be forwarded. There are fewer non-overridden methods, so use the latter. The following |
| 237 | // methods forward to the identical blueprint versions for topDownMutatorContext and bottomUpMutatorContext. |
| 238 | |
Colin Cross | cb55e08 | 2019-07-01 15:32:31 -0700 | [diff] [blame] | 239 | func (t *topDownMutatorContext) MutatorName() string { |
| 240 | return t.bp.MutatorName() |
| 241 | } |
| 242 | |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 243 | func (t *topDownMutatorContext) Rename(name string) { |
| 244 | t.bp.Rename(name) |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 245 | t.Module().base().commonProperties.DebugName = name |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 246 | } |
| 247 | |
Colin Cross | e003c4a | 2019-09-25 12:58:36 -0700 | [diff] [blame] | 248 | func (t *topDownMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) Module { |
Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 249 | inherited := []interface{}{&t.Module().base().commonProperties} |
Colin Cross | e003c4a | 2019-09-25 12:58:36 -0700 | [diff] [blame] | 250 | module := t.bp.CreateModule(ModuleFactoryAdaptor(factory), append(inherited, props...)...).(Module) |
Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 251 | |
| 252 | if t.Module().base().variableProperties != nil && module.base().variableProperties != nil { |
| 253 | src := t.Module().base().variableProperties |
| 254 | dst := []interface{}{ |
| 255 | module.base().variableProperties, |
| 256 | // Put an empty copy of the src properties into dst so that properties in src that are not in dst |
| 257 | // don't cause a "failed to find property to extend" error. |
| 258 | proptools.CloneEmptyProperties(reflect.ValueOf(src).Elem()).Interface(), |
| 259 | } |
| 260 | err := proptools.AppendMatchingProperties(dst, src, nil) |
| 261 | if err != nil { |
| 262 | panic(err) |
| 263 | } |
| 264 | } |
| 265 | |
Colin Cross | e003c4a | 2019-09-25 12:58:36 -0700 | [diff] [blame] | 266 | return module |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Colin Cross | cb55e08 | 2019-07-01 15:32:31 -0700 | [diff] [blame] | 269 | func (b *bottomUpMutatorContext) MutatorName() string { |
| 270 | return b.bp.MutatorName() |
| 271 | } |
| 272 | |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 273 | func (b *bottomUpMutatorContext) Rename(name string) { |
| 274 | b.bp.Rename(name) |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 275 | b.Module().base().commonProperties.DebugName = name |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) { |
| 279 | b.bp.AddDependency(module, tag, name...) |
| 280 | } |
| 281 | |
| 282 | func (b *bottomUpMutatorContext) AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) { |
| 283 | b.bp.AddReverseDependency(module, tag, name) |
| 284 | } |
| 285 | |
| 286 | func (b *bottomUpMutatorContext) CreateVariations(variations ...string) []blueprint.Module { |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 287 | modules := b.bp.CreateVariations(variations...) |
| 288 | |
| 289 | for i := range variations { |
| 290 | base := modules[i].(Module).base() |
| 291 | base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, b.MutatorName()) |
| 292 | base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variations[i]) |
| 293 | } |
| 294 | |
| 295 | return modules |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | func (b *bottomUpMutatorContext) CreateLocalVariations(variations ...string) []blueprint.Module { |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 299 | modules := b.bp.CreateLocalVariations(variations...) |
| 300 | |
| 301 | for i := range variations { |
| 302 | base := modules[i].(Module).base() |
| 303 | base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, b.MutatorName()) |
| 304 | base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variations[i]) |
| 305 | } |
| 306 | |
| 307 | return modules |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | func (b *bottomUpMutatorContext) SetDependencyVariation(variation string) { |
| 311 | b.bp.SetDependencyVariation(variation) |
| 312 | } |
| 313 | |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 314 | func (b *bottomUpMutatorContext) SetDefaultDependencyVariation(variation *string) { |
| 315 | b.bp.SetDefaultDependencyVariation(variation) |
| 316 | } |
| 317 | |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 318 | func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, |
| 319 | names ...string) { |
| 320 | |
| 321 | b.bp.AddVariationDependencies(variations, tag, names...) |
| 322 | } |
| 323 | |
| 324 | func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation, |
| 325 | tag blueprint.DependencyTag, names ...string) { |
| 326 | |
| 327 | b.bp.AddFarVariationDependencies(variations, tag, names...) |
| 328 | } |
| 329 | |
| 330 | func (b *bottomUpMutatorContext) AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) { |
| 331 | b.bp.AddInterVariantDependency(tag, from, to) |
| 332 | } |
| 333 | |
| 334 | func (b *bottomUpMutatorContext) ReplaceDependencies(name string) { |
| 335 | b.bp.ReplaceDependencies(name) |
| 336 | } |