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 |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 30 | // run FinalDeps mutators (CreateVariations disallowed in this phase) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 31 | // continue on to GenerateAndroidBuildActions |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 32 | |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 33 | func registerMutatorsToContext(ctx *blueprint.Context, mutators []*mutator) { |
| 34 | for _, t := range mutators { |
| 35 | var handle blueprint.MutatorHandle |
| 36 | if t.bottomUpMutator != nil { |
| 37 | handle = ctx.RegisterBottomUpMutator(t.name, t.bottomUpMutator) |
| 38 | } else if t.topDownMutator != nil { |
| 39 | handle = ctx.RegisterTopDownMutator(t.name, t.topDownMutator) |
| 40 | } |
| 41 | if t.parallel { |
| 42 | handle.Parallel() |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 43 | } |
| 44 | } |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Jingwen Chen | 7385067 | 2020-12-14 08:25:34 -0500 | [diff] [blame] | 47 | // RegisterMutatorsForBazelConversion is a alternate registration pipeline for bp2build. Exported for testing. |
| 48 | func RegisterMutatorsForBazelConversion(ctx *blueprint.Context, bp2buildMutators []RegisterMutatorFunc) { |
| 49 | mctx := ®isterMutatorsContext{} |
| 50 | |
Jingwen Chen | 041b184 | 2021-02-01 00:23:25 -0500 | [diff] [blame^] | 51 | sharedMutators := []RegisterMutatorFunc{ |
| 52 | RegisterDefaultsPreArchMutators, |
| 53 | } |
| 54 | |
| 55 | for _, f := range sharedMutators { |
| 56 | f(mctx) |
| 57 | } |
| 58 | |
Jingwen Chen | 7385067 | 2020-12-14 08:25:34 -0500 | [diff] [blame] | 59 | // Register bp2build mutators |
| 60 | for _, f := range bp2buildMutators { |
| 61 | f(mctx) |
| 62 | } |
| 63 | |
| 64 | registerMutatorsToContext(ctx, mctx.mutators) |
Jingwen Chen | 4133ce6 | 2020-12-02 04:34:15 -0500 | [diff] [blame] | 65 | } |
| 66 | |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 67 | func registerMutators(ctx *blueprint.Context, preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc) { |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 68 | mctx := ®isterMutatorsContext{} |
Nan Zhang | db0b9a3 | 2017-02-27 10:12:13 -0800 | [diff] [blame] | 69 | |
| 70 | register := func(funcs []RegisterMutatorFunc) { |
| 71 | for _, f := range funcs { |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 72 | f(mctx) |
Nan Zhang | db0b9a3 | 2017-02-27 10:12:13 -0800 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 76 | register(preArch) |
Nan Zhang | db0b9a3 | 2017-02-27 10:12:13 -0800 | [diff] [blame] | 77 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 78 | register(preDeps) |
| 79 | |
| 80 | mctx.BottomUp("deps", depsMutator).Parallel() |
| 81 | |
| 82 | register(postDeps) |
| 83 | |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 84 | mctx.finalPhase = true |
| 85 | register(finalDeps) |
| 86 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 87 | registerMutatorsToContext(ctx, mctx.mutators) |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | type registerMutatorsContext struct { |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 91 | mutators []*mutator |
| 92 | finalPhase bool |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 93 | } |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 94 | |
| 95 | type RegisterMutatorsContext interface { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 96 | TopDown(name string, m TopDownMutator) MutatorHandle |
| 97 | BottomUp(name string, m BottomUpMutator) MutatorHandle |
Colin Cross | 617b88a | 2020-08-24 18:04:09 -0700 | [diff] [blame] | 98 | BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | type RegisterMutatorFunc func(RegisterMutatorsContext) |
| 102 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 103 | var preArch = []RegisterMutatorFunc{ |
Dan Willemsen | 6e72ef7 | 2018-01-26 18:27:02 -0800 | [diff] [blame] | 104 | RegisterNamespaceMutator, |
Paul Duffin | aa4162e | 2020-05-05 11:35:43 +0100 | [diff] [blame] | 105 | |
Paul Duffin | aa4162e | 2020-05-05 11:35:43 +0100 | [diff] [blame] | 106 | // Check the visibility rules are valid. |
| 107 | // |
| 108 | // This must run after the package renamer mutators so that any issues found during |
| 109 | // validation of the package's default_visibility property are reported using the |
| 110 | // correct package name and not the synthetic name. |
| 111 | // |
| 112 | // This must also be run before defaults mutators as the rules for validation are |
| 113 | // different before checking the rules than they are afterwards. e.g. |
| 114 | // visibility: ["//visibility:private", "//visibility:public"] |
| 115 | // would be invalid if specified in a module definition but is valid if it results |
| 116 | // from something like this: |
| 117 | // |
| 118 | // defaults { |
| 119 | // name: "defaults", |
| 120 | // // Be inaccessible outside a package by default. |
| 121 | // visibility: ["//visibility:private"] |
| 122 | // } |
| 123 | // |
| 124 | // defaultable_module { |
| 125 | // name: "defaultable_module", |
| 126 | // defaults: ["defaults"], |
| 127 | // // Override the default. |
| 128 | // visibility: ["//visibility:public"] |
| 129 | // } |
| 130 | // |
Paul Duffin | 593b3c9 | 2019-12-05 14:31:48 +0000 | [diff] [blame] | 131 | RegisterVisibilityRuleChecker, |
Paul Duffin | aa4162e | 2020-05-05 11:35:43 +0100 | [diff] [blame] | 132 | |
Bob Badour | 37af046 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 133 | // Record the default_applicable_licenses for each package. |
| 134 | // |
| 135 | // This must run before the defaults so that defaults modules can pick up the package default. |
| 136 | RegisterLicensesPackageMapper, |
| 137 | |
Paul Duffin | aa4162e | 2020-05-05 11:35:43 +0100 | [diff] [blame] | 138 | // Apply properties from defaults modules to the referencing modules. |
Paul Duffin | afa9fa1 | 2020-04-29 16:47:28 +0100 | [diff] [blame] | 139 | // |
| 140 | // Any mutators that are added before this will not see any modules created by |
| 141 | // a DefaultableHook. |
Colin Cross | 89536d4 | 2017-07-07 14:35:50 -0700 | [diff] [blame] | 142 | RegisterDefaultsPreArchMutators, |
Paul Duffin | aa4162e | 2020-05-05 11:35:43 +0100 | [diff] [blame] | 143 | |
Paul Duffin | 44f1d84 | 2020-06-26 20:17:02 +0100 | [diff] [blame] | 144 | // Add dependencies on any components so that any component references can be |
| 145 | // resolved within the deps mutator. |
| 146 | // |
| 147 | // Must be run after defaults so it can be used to create dependencies on the |
| 148 | // component modules that are creating in a DefaultableHook. |
| 149 | // |
| 150 | // Must be run before RegisterPrebuiltsPreArchMutators, i.e. before prebuilts are |
| 151 | // renamed. That is so that if a module creates components using a prebuilt module |
| 152 | // type that any dependencies (which must use prebuilt_ prefixes) are resolved to |
| 153 | // the prebuilt module and not the source module. |
| 154 | RegisterComponentsMutator, |
| 155 | |
Paul Duffin | c988c8e | 2020-04-29 18:27:14 +0100 | [diff] [blame] | 156 | // Create an association between prebuilt modules and their corresponding source |
| 157 | // modules (if any). |
Paul Duffin | afa9fa1 | 2020-04-29 16:47:28 +0100 | [diff] [blame] | 158 | // |
| 159 | // Must be run after defaults mutators to ensure that any modules created by |
| 160 | // a DefaultableHook can be either a prebuilt or a source module with a matching |
| 161 | // prebuilt. |
Paul Duffin | c988c8e | 2020-04-29 18:27:14 +0100 | [diff] [blame] | 162 | RegisterPrebuiltsPreArchMutators, |
| 163 | |
Bob Badour | 37af046 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 164 | // Gather the licenses properties for all modules for use during expansion and enforcement. |
| 165 | // |
| 166 | // This must come after the defaults mutators to ensure that any licenses supplied |
| 167 | // in a defaults module has been successfully applied before the rules are gathered. |
| 168 | RegisterLicensesPropertyGatherer, |
| 169 | |
Paul Duffin | aa4162e | 2020-05-05 11:35:43 +0100 | [diff] [blame] | 170 | // Gather the visibility rules for all modules for us during visibility enforcement. |
| 171 | // |
| 172 | // This must come after the defaults mutators to ensure that any visibility supplied |
| 173 | // in a defaults module has been successfully applied before the rules are gathered. |
Paul Duffin | 593b3c9 | 2019-12-05 14:31:48 +0000 | [diff] [blame] | 174 | RegisterVisibilityRuleGatherer, |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 177 | func registerArchMutator(ctx RegisterMutatorsContext) { |
Colin Cross | 617b88a | 2020-08-24 18:04:09 -0700 | [diff] [blame] | 178 | ctx.BottomUpBlueprint("os", osMutator).Parallel() |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 179 | ctx.BottomUp("image", imageMutator).Parallel() |
Colin Cross | 617b88a | 2020-08-24 18:04:09 -0700 | [diff] [blame] | 180 | ctx.BottomUpBlueprint("arch", archMutator).Parallel() |
Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 183 | var preDeps = []RegisterMutatorFunc{ |
Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 184 | registerArchMutator, |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | var postDeps = []RegisterMutatorFunc{ |
Colin Cross | 1b48842 | 2019-03-04 22:33:56 -0800 | [diff] [blame] | 188 | registerPathDepsMutator, |
Colin Cross | 5ea9bcc | 2017-07-27 15:41:32 -0700 | [diff] [blame] | 189 | RegisterPrebuiltsPostDepsMutators, |
Paul Duffin | 593b3c9 | 2019-12-05 14:31:48 +0000 | [diff] [blame] | 190 | RegisterVisibilityRuleEnforcer, |
Bob Badour | 37af046 | 2021-01-07 03:34:31 +0000 | [diff] [blame] | 191 | RegisterLicensesDependencyChecker, |
Artur Satayev | c5570ac | 2020-04-09 16:06:36 +0100 | [diff] [blame] | 192 | RegisterNeverallowMutator, |
Jaewoong Jung | b639a6a | 2019-05-10 15:16:29 -0700 | [diff] [blame] | 193 | RegisterOverridePostDepsMutators, |
Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 194 | } |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 195 | |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 196 | var finalDeps = []RegisterMutatorFunc{} |
| 197 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 198 | func PreArchMutators(f RegisterMutatorFunc) { |
| 199 | preArch = append(preArch, f) |
| 200 | } |
| 201 | |
| 202 | func PreDepsMutators(f RegisterMutatorFunc) { |
| 203 | preDeps = append(preDeps, f) |
| 204 | } |
| 205 | |
| 206 | func PostDepsMutators(f RegisterMutatorFunc) { |
| 207 | postDeps = append(postDeps, f) |
| 208 | } |
| 209 | |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 210 | func FinalDepsMutators(f RegisterMutatorFunc) { |
| 211 | finalDeps = append(finalDeps, f) |
| 212 | } |
| 213 | |
Jingwen Chen | 7385067 | 2020-12-14 08:25:34 -0500 | [diff] [blame] | 214 | var bp2buildMutators = []RegisterMutatorFunc{} |
| 215 | |
| 216 | // RegisterBp2BuildMutator registers specially crafted mutators for |
| 217 | // converting Blueprint/Android modules into special modules that can |
| 218 | // be code-generated into Bazel BUILD targets. |
| 219 | // |
| 220 | // TODO(b/178068862): bring this into TestContext. |
| 221 | func RegisterBp2BuildMutator(moduleType string, m func(TopDownMutatorContext)) { |
| 222 | mutatorName := moduleType + "_bp2build" |
| 223 | f := func(ctx RegisterMutatorsContext) { |
| 224 | ctx.TopDown(mutatorName, m) |
| 225 | } |
| 226 | bp2buildMutators = append(bp2buildMutators, f) |
| 227 | } |
| 228 | |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 229 | type BaseMutatorContext interface { |
| 230 | BaseModuleContext |
| 231 | |
| 232 | // MutatorName returns the name that this mutator was registered with. |
| 233 | MutatorName() string |
| 234 | |
| 235 | // Rename all variants of a module. The new name is not visible to calls to ModuleName, |
| 236 | // AddDependency or OtherModuleName until after this mutator pass is complete. |
| 237 | Rename(name string) |
| 238 | } |
| 239 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 240 | type TopDownMutator func(TopDownMutatorContext) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 241 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 242 | type TopDownMutatorContext interface { |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 243 | BaseMutatorContext |
Colin Cross | 3f68a13 | 2017-10-23 17:10:29 -0700 | [diff] [blame] | 244 | |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 245 | // CreateModule creates a new module by calling the factory method for the specified moduleType, and applies |
| 246 | // the specified property structs to it as if the properties were set in a blueprint file. |
Colin Cross | e003c4a | 2019-09-25 12:58:36 -0700 | [diff] [blame] | 247 | CreateModule(ModuleFactory, ...interface{}) Module |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 250 | type topDownMutatorContext struct { |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 251 | bp blueprint.TopDownMutatorContext |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 252 | baseModuleContext |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 255 | type BottomUpMutator func(BottomUpMutatorContext) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 256 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 257 | type BottomUpMutatorContext interface { |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 258 | BaseMutatorContext |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 259 | |
Colin Cross | 4f1dcb0 | 2020-09-16 18:45:04 -0700 | [diff] [blame] | 260 | // AddDependency adds a dependency to the given module. It returns a slice of modules for each |
| 261 | // dependency (some entries may be nil). |
| 262 | // |
| 263 | // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the |
| 264 | // new dependencies have had the current mutator called on them. If the mutator is not |
| 265 | // parallel this method does not affect the ordering of the current mutator pass, but will |
| 266 | // be ordered correctly for all future mutator passes. |
| 267 | AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 268 | |
| 269 | // AddReverseDependency adds a dependency from the destination to the given module. |
| 270 | // Does not affect the ordering of the current mutator pass, but will be ordered |
| 271 | // correctly for all future mutator passes. All reverse dependencies for a destination module are |
| 272 | // collected until the end of the mutator pass, sorted by name, and then appended to the destination |
| 273 | // module's dependency list. |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 274 | AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 275 | |
| 276 | // CreateVariations splits a module into multiple variants, one for each name in the variationNames |
| 277 | // parameter. It returns a list of new modules in the same order as the variationNames |
| 278 | // list. |
| 279 | // |
| 280 | // If any of the dependencies of the module being operated on were already split |
| 281 | // by calling CreateVariations with the same name, the dependency will automatically |
| 282 | // be updated to point the matching variant. |
| 283 | // |
| 284 | // If a module is split, and then a module depending on the first module is not split |
| 285 | // when the Mutator is later called on it, the dependency of the depending module will |
| 286 | // automatically be updated to point to the first variant. |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 287 | CreateVariations(...string) []Module |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 288 | |
| 289 | // CreateLocationVariations splits a module into multiple variants, one for each name in the variantNames |
| 290 | // parameter. It returns a list of new modules in the same order as the variantNames |
| 291 | // list. |
| 292 | // |
| 293 | // Local variations do not affect automatic dependency resolution - dependencies added |
| 294 | // to the split module via deps or DynamicDependerModule must exactly match a variant |
| 295 | // that contains all the non-local variations. |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 296 | CreateLocalVariations(...string) []Module |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 297 | |
| 298 | // SetDependencyVariation sets all dangling dependencies on the current module to point to the variation |
| 299 | // with given name. This function ignores the default variation set by SetDefaultDependencyVariation. |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 300 | SetDependencyVariation(string) |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 301 | |
| 302 | // SetDefaultDependencyVariation sets the default variation when a dangling reference is detected |
| 303 | // during the subsequent calls on Create*Variations* functions. To reset, set it to nil. |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 304 | SetDefaultDependencyVariation(*string) |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 305 | |
| 306 | // AddVariationDependencies adds deps as dependencies of the current module, but uses the variations |
Colin Cross | 4f1dcb0 | 2020-09-16 18:45:04 -0700 | [diff] [blame] | 307 | // argument to select which variant of the dependency to use. It returns a slice of modules for |
| 308 | // each dependency (some entries may be nil). A variant of the dependency must exist that matches |
| 309 | // the all of the non-local variations of the current module, plus the variations argument. |
| 310 | // |
| 311 | // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the |
| 312 | // new dependencies have had the current mutator called on them. If the mutator is not |
| 313 | // parallel this method does not affect the ordering of the current mutator pass, but will |
| 314 | // be ordered correctly for all future mutator passes. |
| 315 | AddVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) []blueprint.Module |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 316 | |
| 317 | // AddFarVariationDependencies adds deps as dependencies of the current module, but uses the |
Colin Cross | 4f1dcb0 | 2020-09-16 18:45:04 -0700 | [diff] [blame] | 318 | // variations argument to select which variant of the dependency to use. It returns a slice of |
| 319 | // modules for each dependency (some entries may be nil). A variant of the dependency must |
| 320 | // exist that matches the variations argument, but may also have other variations. |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 321 | // For any unspecified variation the first variant will be used. |
| 322 | // |
| 323 | // Unlike AddVariationDependencies, the variations of the current module are ignored - the |
| 324 | // dependency only needs to match the supplied variations. |
Colin Cross | 4f1dcb0 | 2020-09-16 18:45:04 -0700 | [diff] [blame] | 325 | // |
| 326 | // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the |
| 327 | // new dependencies have had the current mutator called on them. If the mutator is not |
| 328 | // parallel this method does not affect the ordering of the current mutator pass, but will |
| 329 | // be ordered correctly for all future mutator passes. |
| 330 | AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) []blueprint.Module |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 331 | |
| 332 | // AddInterVariantDependency adds a dependency between two variants of the same module. Variants are always |
| 333 | // ordered in the same orderas they were listed in CreateVariations, and AddInterVariantDependency does not change |
| 334 | // that ordering, but it associates a DependencyTag with the dependency and makes it visible to VisitDirectDeps, |
| 335 | // WalkDeps, etc. |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 336 | AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 337 | |
| 338 | // ReplaceDependencies replaces all dependencies on the identical variant of the module with the |
| 339 | // specified name with the current variant of this module. Replacements don't take effect until |
| 340 | // after the mutator pass is finished. |
Colin Cross | aabf679 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 341 | ReplaceDependencies(string) |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 342 | |
| 343 | // ReplaceDependencies replaces all dependencies on the identical variant of the module with the |
| 344 | // specified name with the current variant of this module as long as the supplied predicate returns |
| 345 | // true. |
| 346 | // |
| 347 | // Replacements don't take effect until after the mutator pass is finished. |
Paul Duffin | 80342d7 | 2020-06-26 22:08:43 +0100 | [diff] [blame] | 348 | ReplaceDependenciesIf(string, blueprint.ReplaceDependencyPredicate) |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 349 | |
| 350 | // AliasVariation takes a variationName that was passed to CreateVariations for this module, |
| 351 | // and creates an alias from the current variant (before the mutator has run) to the new |
| 352 | // variant. The alias will be valid until the next time a mutator calls CreateVariations or |
| 353 | // CreateLocalVariations on this module without also calling AliasVariation. The alias can |
| 354 | // be used to add dependencies on the newly created variant using the variant map from |
| 355 | // before CreateVariations was run. |
Jaewoong Jung | 9f88ce2 | 2019-11-15 10:57:34 -0800 | [diff] [blame] | 356 | AliasVariation(variationName string) |
Colin Cross | 9f35c3d | 2020-09-16 19:04:41 -0700 | [diff] [blame] | 357 | |
| 358 | // CreateAliasVariation takes a toVariationName that was passed to CreateVariations for this |
| 359 | // module, and creates an alias from a new fromVariationName variant the toVariationName |
| 360 | // variant. The alias will be valid until the next time a mutator calls CreateVariations or |
| 361 | // CreateLocalVariations on this module without also calling AliasVariation. The alias can |
| 362 | // be used to add dependencies on the toVariationName variant using the fromVariationName |
| 363 | // variant. |
Colin Cross | 1b9604b | 2020-08-11 12:03:56 -0700 | [diff] [blame] | 364 | CreateAliasVariation(fromVariationName, toVariationName string) |
Colin Cross | d27e7b8 | 2020-07-02 11:38:17 -0700 | [diff] [blame] | 365 | |
| 366 | // SetVariationProvider sets the value for a provider for the given newly created variant of |
| 367 | // the current module, i.e. one of the Modules returned by CreateVariations.. It panics if |
| 368 | // not called during the appropriate mutator or GenerateBuildActions pass for the provider, |
| 369 | // if the value is not of the appropriate type, or if the module is not a newly created |
| 370 | // variant of the current module. The value should not be modified after being passed to |
| 371 | // SetVariationProvider. |
| 372 | SetVariationProvider(module blueprint.Module, provider blueprint.ProviderKey, value interface{}) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 373 | } |
| 374 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 375 | type bottomUpMutatorContext struct { |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 376 | bp blueprint.BottomUpMutatorContext |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 377 | baseModuleContext |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 378 | finalPhase bool |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 379 | } |
| 380 | |
Colin Cross | 617b88a | 2020-08-24 18:04:09 -0700 | [diff] [blame] | 381 | func bottomUpMutatorContextFactory(ctx blueprint.BottomUpMutatorContext, a Module, |
| 382 | finalPhase bool) BottomUpMutatorContext { |
| 383 | |
| 384 | return &bottomUpMutatorContext{ |
| 385 | bp: ctx, |
| 386 | baseModuleContext: a.base().baseModuleContextFactory(ctx), |
| 387 | finalPhase: finalPhase, |
| 388 | } |
| 389 | } |
| 390 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 391 | func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle { |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 392 | finalPhase := x.finalPhase |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 393 | f := func(ctx blueprint.BottomUpMutatorContext) { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 394 | if a, ok := ctx.Module().(Module); ok { |
Colin Cross | 617b88a | 2020-08-24 18:04:09 -0700 | [diff] [blame] | 395 | m(bottomUpMutatorContextFactory(ctx, a, finalPhase)) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 396 | } |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 397 | } |
| 398 | mutator := &mutator{name: name, bottomUpMutator: f} |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 399 | x.mutators = append(x.mutators, mutator) |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 400 | return mutator |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 401 | } |
| 402 | |
Colin Cross | 617b88a | 2020-08-24 18:04:09 -0700 | [diff] [blame] | 403 | func (x *registerMutatorsContext) BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle { |
| 404 | mutator := &mutator{name: name, bottomUpMutator: m} |
| 405 | x.mutators = append(x.mutators, mutator) |
| 406 | return mutator |
| 407 | } |
| 408 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 409 | func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) MutatorHandle { |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 410 | f := func(ctx blueprint.TopDownMutatorContext) { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 411 | if a, ok := ctx.Module().(Module); ok { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 412 | actx := &topDownMutatorContext{ |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 413 | bp: ctx, |
| 414 | baseModuleContext: a.base().baseModuleContextFactory(ctx), |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 415 | } |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 416 | m(actx) |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 417 | } |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 418 | } |
| 419 | mutator := &mutator{name: name, topDownMutator: f} |
Colin Cross | 795c377 | 2017-03-16 16:50:10 -0700 | [diff] [blame] | 420 | x.mutators = append(x.mutators, mutator) |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 421 | return mutator |
| 422 | } |
| 423 | |
| 424 | type MutatorHandle interface { |
| 425 | Parallel() MutatorHandle |
| 426 | } |
| 427 | |
| 428 | func (mutator *mutator) Parallel() MutatorHandle { |
| 429 | mutator.parallel = true |
| 430 | return mutator |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 431 | } |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 432 | |
Paul Duffin | 44f1d84 | 2020-06-26 20:17:02 +0100 | [diff] [blame] | 433 | func RegisterComponentsMutator(ctx RegisterMutatorsContext) { |
| 434 | ctx.BottomUp("component-deps", componentDepsMutator).Parallel() |
| 435 | } |
| 436 | |
| 437 | // A special mutator that runs just prior to the deps mutator to allow the dependencies |
| 438 | // on component modules to be added so that they can depend directly on a prebuilt |
| 439 | // module. |
| 440 | func componentDepsMutator(ctx BottomUpMutatorContext) { |
| 441 | if m := ctx.Module(); m.Enabled() { |
| 442 | m.ComponentDepsMutator(ctx) |
| 443 | } |
| 444 | } |
| 445 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 446 | func depsMutator(ctx BottomUpMutatorContext) { |
Paul Duffin | 44f1d84 | 2020-06-26 20:17:02 +0100 | [diff] [blame] | 447 | if m := ctx.Module(); m.Enabled() { |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 448 | m.DepsMutator(ctx) |
| 449 | } |
| 450 | } |
Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 451 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 452 | func (t *topDownMutatorContext) AppendProperties(props ...interface{}) { |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 453 | for _, p := range props { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 454 | err := proptools.AppendMatchingProperties(t.Module().base().customizableProperties, |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 455 | p, nil) |
| 456 | if err != nil { |
| 457 | if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 458 | t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 459 | } else { |
| 460 | panic(err) |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 466 | func (t *topDownMutatorContext) PrependProperties(props ...interface{}) { |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 467 | for _, p := range props { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 468 | err := proptools.PrependMatchingProperties(t.Module().base().customizableProperties, |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 469 | p, nil) |
| 470 | if err != nil { |
| 471 | if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { |
Colin Cross | 25de6c3 | 2019-06-06 14:29:25 -0700 | [diff] [blame] | 472 | t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) |
Colin Cross | 519917d | 2017-11-02 16:35:56 -0700 | [diff] [blame] | 473 | } else { |
| 474 | panic(err) |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | } |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 479 | |
| 480 | // android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that |
| 481 | // has an overridden version in android.BaseModuleContext has to be manually forwarded to BaseModuleContext to avoid |
| 482 | // ambiguous method errors, or it has to store a blueprint.TopDownMutatorContext non-embedded, in which case every |
| 483 | // non-overridden method has to be forwarded. There are fewer non-overridden methods, so use the latter. The following |
| 484 | // methods forward to the identical blueprint versions for topDownMutatorContext and bottomUpMutatorContext. |
| 485 | |
Colin Cross | cb55e08 | 2019-07-01 15:32:31 -0700 | [diff] [blame] | 486 | func (t *topDownMutatorContext) MutatorName() string { |
| 487 | return t.bp.MutatorName() |
| 488 | } |
| 489 | |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 490 | func (t *topDownMutatorContext) Rename(name string) { |
| 491 | t.bp.Rename(name) |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 492 | t.Module().base().commonProperties.DebugName = name |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Colin Cross | e003c4a | 2019-09-25 12:58:36 -0700 | [diff] [blame] | 495 | func (t *topDownMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) Module { |
Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 496 | inherited := []interface{}{&t.Module().base().commonProperties} |
Colin Cross | e003c4a | 2019-09-25 12:58:36 -0700 | [diff] [blame] | 497 | module := t.bp.CreateModule(ModuleFactoryAdaptor(factory), append(inherited, props...)...).(Module) |
Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 498 | |
| 499 | if t.Module().base().variableProperties != nil && module.base().variableProperties != nil { |
| 500 | src := t.Module().base().variableProperties |
| 501 | dst := []interface{}{ |
| 502 | module.base().variableProperties, |
| 503 | // Put an empty copy of the src properties into dst so that properties in src that are not in dst |
| 504 | // don't cause a "failed to find property to extend" error. |
Colin Cross | 43e789d | 2020-01-28 09:46:50 -0800 | [diff] [blame] | 505 | proptools.CloneEmptyProperties(reflect.ValueOf(src)).Interface(), |
Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 506 | } |
| 507 | err := proptools.AppendMatchingProperties(dst, src, nil) |
| 508 | if err != nil { |
| 509 | panic(err) |
| 510 | } |
| 511 | } |
| 512 | |
Colin Cross | e003c4a | 2019-09-25 12:58:36 -0700 | [diff] [blame] | 513 | return module |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 514 | } |
| 515 | |
Colin Cross | cb55e08 | 2019-07-01 15:32:31 -0700 | [diff] [blame] | 516 | func (b *bottomUpMutatorContext) MutatorName() string { |
| 517 | return b.bp.MutatorName() |
| 518 | } |
| 519 | |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 520 | func (b *bottomUpMutatorContext) Rename(name string) { |
| 521 | b.bp.Rename(name) |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 522 | b.Module().base().commonProperties.DebugName = name |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Colin Cross | 4f1dcb0 | 2020-09-16 18:45:04 -0700 | [diff] [blame] | 525 | func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module { |
| 526 | return b.bp.AddDependency(module, tag, name...) |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | func (b *bottomUpMutatorContext) AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) { |
| 530 | b.bp.AddReverseDependency(module, tag, name) |
| 531 | } |
| 532 | |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 533 | func (b *bottomUpMutatorContext) CreateVariations(variations ...string) []Module { |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 534 | if b.finalPhase { |
| 535 | panic("CreateVariations not allowed in FinalDepsMutators") |
| 536 | } |
| 537 | |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 538 | modules := b.bp.CreateVariations(variations...) |
| 539 | |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 540 | aModules := make([]Module, len(modules)) |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 541 | for i := range variations { |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 542 | aModules[i] = modules[i].(Module) |
| 543 | base := aModules[i].base() |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 544 | base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, b.MutatorName()) |
| 545 | base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variations[i]) |
| 546 | } |
| 547 | |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 548 | return aModules |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 549 | } |
| 550 | |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 551 | func (b *bottomUpMutatorContext) CreateLocalVariations(variations ...string) []Module { |
Martin Stjernholm | 710ec3a | 2020-01-16 15:12:04 +0000 | [diff] [blame] | 552 | if b.finalPhase { |
| 553 | panic("CreateLocalVariations not allowed in FinalDepsMutators") |
| 554 | } |
| 555 | |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 556 | modules := b.bp.CreateLocalVariations(variations...) |
| 557 | |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 558 | aModules := make([]Module, len(modules)) |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 559 | for i := range variations { |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 560 | aModules[i] = modules[i].(Module) |
| 561 | base := aModules[i].base() |
Colin Cross | 9a36223 | 2019-07-01 15:32:45 -0700 | [diff] [blame] | 562 | base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, b.MutatorName()) |
| 563 | base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variations[i]) |
| 564 | } |
| 565 | |
Colin Cross | 43b92e0 | 2019-11-18 15:28:57 -0800 | [diff] [blame] | 566 | return aModules |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | func (b *bottomUpMutatorContext) SetDependencyVariation(variation string) { |
| 570 | b.bp.SetDependencyVariation(variation) |
| 571 | } |
| 572 | |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 573 | func (b *bottomUpMutatorContext) SetDefaultDependencyVariation(variation *string) { |
| 574 | b.bp.SetDefaultDependencyVariation(variation) |
| 575 | } |
| 576 | |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 577 | func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, |
Colin Cross | 4f1dcb0 | 2020-09-16 18:45:04 -0700 | [diff] [blame] | 578 | names ...string) []blueprint.Module { |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 579 | |
Colin Cross | 4f1dcb0 | 2020-09-16 18:45:04 -0700 | [diff] [blame] | 580 | return b.bp.AddVariationDependencies(variations, tag, names...) |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation, |
Colin Cross | 4f1dcb0 | 2020-09-16 18:45:04 -0700 | [diff] [blame] | 584 | tag blueprint.DependencyTag, names ...string) []blueprint.Module { |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 585 | |
Colin Cross | 4f1dcb0 | 2020-09-16 18:45:04 -0700 | [diff] [blame] | 586 | return b.bp.AddFarVariationDependencies(variations, tag, names...) |
Colin Cross | dc35e21 | 2019-06-06 16:13:11 -0700 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | func (b *bottomUpMutatorContext) AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) { |
| 590 | b.bp.AddInterVariantDependency(tag, from, to) |
| 591 | } |
| 592 | |
| 593 | func (b *bottomUpMutatorContext) ReplaceDependencies(name string) { |
| 594 | b.bp.ReplaceDependencies(name) |
| 595 | } |
Jaewoong Jung | 9f88ce2 | 2019-11-15 10:57:34 -0800 | [diff] [blame] | 596 | |
Paul Duffin | 80342d7 | 2020-06-26 22:08:43 +0100 | [diff] [blame] | 597 | func (b *bottomUpMutatorContext) ReplaceDependenciesIf(name string, predicate blueprint.ReplaceDependencyPredicate) { |
| 598 | b.bp.ReplaceDependenciesIf(name, predicate) |
| 599 | } |
| 600 | |
Jaewoong Jung | 9f88ce2 | 2019-11-15 10:57:34 -0800 | [diff] [blame] | 601 | func (b *bottomUpMutatorContext) AliasVariation(variationName string) { |
| 602 | b.bp.AliasVariation(variationName) |
| 603 | } |
Colin Cross | 1b9604b | 2020-08-11 12:03:56 -0700 | [diff] [blame] | 604 | |
| 605 | func (b *bottomUpMutatorContext) CreateAliasVariation(fromVariationName, toVariationName string) { |
| 606 | b.bp.CreateAliasVariation(fromVariationName, toVariationName) |
| 607 | } |
Colin Cross | d27e7b8 | 2020-07-02 11:38:17 -0700 | [diff] [blame] | 608 | |
| 609 | func (b *bottomUpMutatorContext) SetVariationProvider(module blueprint.Module, provider blueprint.ProviderKey, value interface{}) { |
| 610 | b.bp.SetVariationProvider(module, provider, value) |
| 611 | } |