blob: 9e4aa59ad982af0a4df1e54c7ccc7b39d3b94846 [file] [log] [blame]
Colin Cross6362e272015-10-29 15:25:03 -07001// 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 Cross635c3b02016-05-18 15:37:25 -070015package android
Colin Cross6362e272015-10-29 15:25:03 -070016
Colin Cross795c3772017-03-16 16:50:10 -070017import (
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux447f6c92021-08-31 20:30:36 +000018 "android/soong/bazel"
19
Colin Cross795c3772017-03-16 16:50:10 -070020 "github.com/google/blueprint"
21)
Colin Cross6362e272015-10-29 15:25:03 -070022
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070023// Phases:
24// run Pre-arch mutators
25// run archMutator
26// run Pre-deps mutators
27// run depsMutator
28// run PostDeps mutators
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000029// run FinalDeps mutators (CreateVariations disallowed in this phase)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070030// continue on to GenerateAndroidBuildActions
Colin Cross1e676be2016-10-12 14:38:15 -070031
Jingwen Chen73850672020-12-14 08:25:34 -050032// RegisterMutatorsForBazelConversion is a alternate registration pipeline for bp2build. Exported for testing.
Liz Kammerbe46fcc2021-11-01 15:32:43 -040033func RegisterMutatorsForBazelConversion(ctx *Context, preArchMutators []RegisterMutatorFunc) {
Liz Kammer356f7d42021-01-26 09:18:53 -050034 mctx := &registerMutatorsContext{
35 bazelConversionMode: true,
Jingwen Chen041b1842021-02-01 00:23:25 -050036 }
37
Liz Kammerbe46fcc2021-11-01 15:32:43 -040038 bp2buildMutators := append([]RegisterMutatorFunc{
Liz Kammer356f7d42021-01-26 09:18:53 -050039 RegisterNamespaceMutator,
40 RegisterDefaultsPreArchMutators,
41 // TODO(b/165114590): this is required to resolve deps that are only prebuilts, but we should
42 // evaluate the impact on conversion.
43 RegisterPrebuiltsPreArchMutators,
44 },
45 preArchMutators...)
Liz Kammerbe46fcc2021-11-01 15:32:43 -040046 bp2buildMutators = append(bp2buildMutators, registerBp2buildConversionMutator)
Liz Kammer356f7d42021-01-26 09:18:53 -050047
Jingwen Chen73850672020-12-14 08:25:34 -050048 // Register bp2build mutators
49 for _, f := range bp2buildMutators {
50 f(mctx)
51 }
52
Paul Duffin1d2d42f2021-03-06 20:08:12 +000053 mctx.mutators.registerAll(ctx)
Jingwen Chen4133ce62020-12-02 04:34:15 -050054}
55
Paul Duffinc05b0342021-03-06 13:28:13 +000056// collateGloballyRegisteredMutators constructs the list of mutators that have been registered
57// with the InitRegistrationContext and will be used at runtime.
58func collateGloballyRegisteredMutators() sortableComponents {
59 return collateRegisteredMutators(preArch, preDeps, postDeps, finalDeps)
60}
61
62// collateRegisteredMutators constructs a single list of mutators from the separate lists.
63func collateRegisteredMutators(preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc) sortableComponents {
Colin Crosscec81712017-07-13 14:43:27 -070064 mctx := &registerMutatorsContext{}
Nan Zhangdb0b9a32017-02-27 10:12:13 -080065
66 register := func(funcs []RegisterMutatorFunc) {
67 for _, f := range funcs {
Colin Crosscec81712017-07-13 14:43:27 -070068 f(mctx)
Nan Zhangdb0b9a32017-02-27 10:12:13 -080069 }
70 }
71
Colin Crosscec81712017-07-13 14:43:27 -070072 register(preArch)
Nan Zhangdb0b9a32017-02-27 10:12:13 -080073
Colin Crosscec81712017-07-13 14:43:27 -070074 register(preDeps)
75
Liz Kammer356f7d42021-01-26 09:18:53 -050076 register([]RegisterMutatorFunc{registerDepsMutator})
Colin Crosscec81712017-07-13 14:43:27 -070077
78 register(postDeps)
79
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000080 mctx.finalPhase = true
81 register(finalDeps)
82
Paul Duffinc05b0342021-03-06 13:28:13 +000083 return mctx.mutators
Colin Cross795c3772017-03-16 16:50:10 -070084}
85
86type registerMutatorsContext struct {
Paul Duffin1d2d42f2021-03-06 20:08:12 +000087 mutators sortableComponents
Liz Kammer356f7d42021-01-26 09:18:53 -050088 finalPhase bool
89 bazelConversionMode bool
Colin Cross795c3772017-03-16 16:50:10 -070090}
Colin Cross1e676be2016-10-12 14:38:15 -070091
92type RegisterMutatorsContext interface {
Colin Cross25de6c32019-06-06 14:29:25 -070093 TopDown(name string, m TopDownMutator) MutatorHandle
94 BottomUp(name string, m BottomUpMutator) MutatorHandle
Colin Cross617b88a2020-08-24 18:04:09 -070095 BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle
Lukacs T. Berki6c716762022-06-13 20:50:39 +020096 Transition(name string, m TransitionMutator)
Colin Cross1e676be2016-10-12 14:38:15 -070097}
98
99type RegisterMutatorFunc func(RegisterMutatorsContext)
100
Colin Crosscec81712017-07-13 14:43:27 -0700101var preArch = []RegisterMutatorFunc{
Dan Willemsen6e72ef72018-01-26 18:27:02 -0800102 RegisterNamespaceMutator,
Paul Duffinaa4162e2020-05-05 11:35:43 +0100103
Paul Duffinaa4162e2020-05-05 11:35:43 +0100104 // Check the visibility rules are valid.
105 //
106 // This must run after the package renamer mutators so that any issues found during
107 // validation of the package's default_visibility property are reported using the
108 // correct package name and not the synthetic name.
109 //
110 // This must also be run before defaults mutators as the rules for validation are
111 // different before checking the rules than they are afterwards. e.g.
112 // visibility: ["//visibility:private", "//visibility:public"]
113 // would be invalid if specified in a module definition but is valid if it results
114 // from something like this:
115 //
116 // defaults {
117 // name: "defaults",
118 // // Be inaccessible outside a package by default.
119 // visibility: ["//visibility:private"]
120 // }
121 //
122 // defaultable_module {
123 // name: "defaultable_module",
124 // defaults: ["defaults"],
125 // // Override the default.
126 // visibility: ["//visibility:public"]
127 // }
128 //
Paul Duffin593b3c92019-12-05 14:31:48 +0000129 RegisterVisibilityRuleChecker,
Paul Duffinaa4162e2020-05-05 11:35:43 +0100130
Bob Badour37af0462021-01-07 03:34:31 +0000131 // Record the default_applicable_licenses for each package.
132 //
133 // This must run before the defaults so that defaults modules can pick up the package default.
134 RegisterLicensesPackageMapper,
135
Paul Duffinaa4162e2020-05-05 11:35:43 +0100136 // Apply properties from defaults modules to the referencing modules.
Paul Duffinafa9fa12020-04-29 16:47:28 +0100137 //
138 // Any mutators that are added before this will not see any modules created by
139 // a DefaultableHook.
Colin Cross89536d42017-07-07 14:35:50 -0700140 RegisterDefaultsPreArchMutators,
Paul Duffinaa4162e2020-05-05 11:35:43 +0100141
Paul Duffin44f1d842020-06-26 20:17:02 +0100142 // Add dependencies on any components so that any component references can be
143 // resolved within the deps mutator.
144 //
145 // Must be run after defaults so it can be used to create dependencies on the
146 // component modules that are creating in a DefaultableHook.
147 //
148 // Must be run before RegisterPrebuiltsPreArchMutators, i.e. before prebuilts are
149 // renamed. That is so that if a module creates components using a prebuilt module
150 // type that any dependencies (which must use prebuilt_ prefixes) are resolved to
151 // the prebuilt module and not the source module.
152 RegisterComponentsMutator,
153
Paul Duffinc988c8e2020-04-29 18:27:14 +0100154 // Create an association between prebuilt modules and their corresponding source
155 // modules (if any).
Paul Duffinafa9fa12020-04-29 16:47:28 +0100156 //
157 // Must be run after defaults mutators to ensure that any modules created by
158 // a DefaultableHook can be either a prebuilt or a source module with a matching
159 // prebuilt.
Paul Duffinc988c8e2020-04-29 18:27:14 +0100160 RegisterPrebuiltsPreArchMutators,
161
Bob Badour37af0462021-01-07 03:34:31 +0000162 // Gather the licenses properties for all modules for use during expansion and enforcement.
163 //
164 // This must come after the defaults mutators to ensure that any licenses supplied
165 // in a defaults module has been successfully applied before the rules are gathered.
166 RegisterLicensesPropertyGatherer,
167
Paul Duffinaa4162e2020-05-05 11:35:43 +0100168 // Gather the visibility rules for all modules for us during visibility enforcement.
169 //
170 // This must come after the defaults mutators to ensure that any visibility supplied
171 // in a defaults module has been successfully applied before the rules are gathered.
Paul Duffin593b3c92019-12-05 14:31:48 +0000172 RegisterVisibilityRuleGatherer,
Colin Crosscec81712017-07-13 14:43:27 -0700173}
174
Colin Crossae4c6182017-09-15 17:33:55 -0700175func registerArchMutator(ctx RegisterMutatorsContext) {
Colin Cross617b88a2020-08-24 18:04:09 -0700176 ctx.BottomUpBlueprint("os", osMutator).Parallel()
Colin Crossfb0c16e2019-11-20 17:12:35 -0800177 ctx.BottomUp("image", imageMutator).Parallel()
Colin Cross617b88a2020-08-24 18:04:09 -0700178 ctx.BottomUpBlueprint("arch", archMutator).Parallel()
Colin Crossae4c6182017-09-15 17:33:55 -0700179}
180
Colin Crosscec81712017-07-13 14:43:27 -0700181var preDeps = []RegisterMutatorFunc{
Colin Crossae4c6182017-09-15 17:33:55 -0700182 registerArchMutator,
Colin Crosscec81712017-07-13 14:43:27 -0700183}
184
185var postDeps = []RegisterMutatorFunc{
Colin Cross1b488422019-03-04 22:33:56 -0800186 registerPathDepsMutator,
Colin Cross5ea9bcc2017-07-27 15:41:32 -0700187 RegisterPrebuiltsPostDepsMutators,
Paul Duffin593b3c92019-12-05 14:31:48 +0000188 RegisterVisibilityRuleEnforcer,
Bob Badour37af0462021-01-07 03:34:31 +0000189 RegisterLicensesDependencyChecker,
Paul Duffin45338f02021-03-30 23:07:52 +0100190 registerNeverallowMutator,
Jaewoong Jungb639a6a2019-05-10 15:16:29 -0700191 RegisterOverridePostDepsMutators,
Colin Crosscec81712017-07-13 14:43:27 -0700192}
Colin Cross1e676be2016-10-12 14:38:15 -0700193
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000194var finalDeps = []RegisterMutatorFunc{}
195
Colin Cross1e676be2016-10-12 14:38:15 -0700196func PreArchMutators(f RegisterMutatorFunc) {
197 preArch = append(preArch, f)
198}
199
200func PreDepsMutators(f RegisterMutatorFunc) {
201 preDeps = append(preDeps, f)
202}
203
204func PostDepsMutators(f RegisterMutatorFunc) {
205 postDeps = append(postDeps, f)
206}
207
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000208func FinalDepsMutators(f RegisterMutatorFunc) {
209 finalDeps = append(finalDeps, f)
210}
211
Liz Kammer356f7d42021-01-26 09:18:53 -0500212var bp2buildPreArchMutators = []RegisterMutatorFunc{}
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -0400213
Liz Kammer12615db2021-09-28 09:19:17 -0400214// A minimal context for Bp2build conversion
215type Bp2buildMutatorContext interface {
216 BazelConversionPathContext
217
218 CreateBazelTargetModule(bazel.BazelTargetModuleProperties, CommonAttributes, interface{})
219}
220
Liz Kammer356f7d42021-01-26 09:18:53 -0500221// PreArchBp2BuildMutators adds mutators to be register for converting Android Blueprint modules
222// into Bazel BUILD targets that should run prior to deps and conversion.
223func PreArchBp2BuildMutators(f RegisterMutatorFunc) {
224 bp2buildPreArchMutators = append(bp2buildPreArchMutators, f)
225}
226
Colin Cross9f35c3d2020-09-16 19:04:41 -0700227type BaseMutatorContext interface {
228 BaseModuleContext
229
230 // MutatorName returns the name that this mutator was registered with.
231 MutatorName() string
232
233 // Rename all variants of a module. The new name is not visible to calls to ModuleName,
234 // AddDependency or OtherModuleName until after this mutator pass is complete.
235 Rename(name string)
236}
237
Colin Cross25de6c32019-06-06 14:29:25 -0700238type TopDownMutator func(TopDownMutatorContext)
Colin Cross6362e272015-10-29 15:25:03 -0700239
Colin Cross635c3b02016-05-18 15:37:25 -0700240type TopDownMutatorContext interface {
Colin Cross9f35c3d2020-09-16 19:04:41 -0700241 BaseMutatorContext
Colin Cross3f68a132017-10-23 17:10:29 -0700242
Colin Cross9f35c3d2020-09-16 19:04:41 -0700243 // CreateModule creates a new module by calling the factory method for the specified moduleType, and applies
244 // the specified property structs to it as if the properties were set in a blueprint file.
Colin Crosse003c4a2019-09-25 12:58:36 -0700245 CreateModule(ModuleFactory, ...interface{}) Module
Jingwen Chen1fd14692021-02-05 03:01:50 -0500246
247 // CreateBazelTargetModule creates a BazelTargetModule by calling the
248 // factory method, just like in CreateModule, but also requires
249 // BazelTargetModuleProperties containing additional metadata for the
250 // bp2build codegenerator.
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux447f6c92021-08-31 20:30:36 +0000251 CreateBazelTargetModule(bazel.BazelTargetModuleProperties, CommonAttributes, interface{})
Chris Parsons58852a02021-12-09 18:10:18 -0500252
253 // CreateBazelTargetModuleWithRestrictions creates a BazelTargetModule by calling the
254 // factory method, just like in CreateModule, but also requires
255 // BazelTargetModuleProperties containing additional metadata for the
256 // bp2build codegenerator. The generated target is restricted to only be buildable for certain
257 // platforms, as dictated by a given bool attribute: the target will not be buildable in
258 // any platform for which this bool attribute is false.
259 CreateBazelTargetModuleWithRestrictions(bazel.BazelTargetModuleProperties, CommonAttributes, interface{}, bazel.BoolAttribute)
Colin Cross6362e272015-10-29 15:25:03 -0700260}
261
Colin Cross25de6c32019-06-06 14:29:25 -0700262type topDownMutatorContext struct {
Colin Crossdc35e212019-06-06 16:13:11 -0700263 bp blueprint.TopDownMutatorContext
Colin Cross0ea8ba82019-06-06 14:33:29 -0700264 baseModuleContext
Colin Cross6362e272015-10-29 15:25:03 -0700265}
266
Colin Cross25de6c32019-06-06 14:29:25 -0700267type BottomUpMutator func(BottomUpMutatorContext)
Colin Cross6362e272015-10-29 15:25:03 -0700268
Colin Cross635c3b02016-05-18 15:37:25 -0700269type BottomUpMutatorContext interface {
Colin Cross9f35c3d2020-09-16 19:04:41 -0700270 BaseMutatorContext
Colin Crossaabf6792017-11-29 00:27:14 -0800271
Colin Cross4f1dcb02020-09-16 18:45:04 -0700272 // AddDependency adds a dependency to the given module. It returns a slice of modules for each
273 // dependency (some entries may be nil).
274 //
275 // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the
276 // new dependencies have had the current mutator called on them. If the mutator is not
277 // parallel this method does not affect the ordering of the current mutator pass, but will
278 // be ordered correctly for all future mutator passes.
279 AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module
Colin Cross9f35c3d2020-09-16 19:04:41 -0700280
281 // AddReverseDependency adds a dependency from the destination to the given module.
282 // Does not affect the ordering of the current mutator pass, but will be ordered
283 // correctly for all future mutator passes. All reverse dependencies for a destination module are
284 // collected until the end of the mutator pass, sorted by name, and then appended to the destination
285 // module's dependency list.
Colin Crossaabf6792017-11-29 00:27:14 -0800286 AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string)
Colin Cross9f35c3d2020-09-16 19:04:41 -0700287
288 // CreateVariations splits a module into multiple variants, one for each name in the variationNames
289 // parameter. It returns a list of new modules in the same order as the variationNames
290 // list.
291 //
292 // If any of the dependencies of the module being operated on were already split
293 // by calling CreateVariations with the same name, the dependency will automatically
294 // be updated to point the matching variant.
295 //
296 // If a module is split, and then a module depending on the first module is not split
297 // when the Mutator is later called on it, the dependency of the depending module will
298 // automatically be updated to point to the first variant.
Colin Cross43b92e02019-11-18 15:28:57 -0800299 CreateVariations(...string) []Module
Colin Cross9f35c3d2020-09-16 19:04:41 -0700300
301 // CreateLocationVariations splits a module into multiple variants, one for each name in the variantNames
302 // parameter. It returns a list of new modules in the same order as the variantNames
303 // list.
304 //
305 // Local variations do not affect automatic dependency resolution - dependencies added
306 // to the split module via deps or DynamicDependerModule must exactly match a variant
307 // that contains all the non-local variations.
Colin Cross43b92e02019-11-18 15:28:57 -0800308 CreateLocalVariations(...string) []Module
Colin Cross9f35c3d2020-09-16 19:04:41 -0700309
310 // SetDependencyVariation sets all dangling dependencies on the current module to point to the variation
311 // with given name. This function ignores the default variation set by SetDefaultDependencyVariation.
Colin Crossaabf6792017-11-29 00:27:14 -0800312 SetDependencyVariation(string)
Colin Cross9f35c3d2020-09-16 19:04:41 -0700313
314 // SetDefaultDependencyVariation sets the default variation when a dangling reference is detected
315 // during the subsequent calls on Create*Variations* functions. To reset, set it to nil.
Jiyong Park1d1119f2019-07-29 21:27:18 +0900316 SetDefaultDependencyVariation(*string)
Colin Cross9f35c3d2020-09-16 19:04:41 -0700317
318 // AddVariationDependencies adds deps as dependencies of the current module, but uses the variations
Colin Cross4f1dcb02020-09-16 18:45:04 -0700319 // argument to select which variant of the dependency to use. It returns a slice of modules for
320 // each dependency (some entries may be nil). A variant of the dependency must exist that matches
Usta Shresthac725f472022-01-11 02:44:21 -0500321 // all the non-local variations of the current module, plus the variations argument.
Colin Cross4f1dcb02020-09-16 18:45:04 -0700322 //
323 // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the
324 // new dependencies have had the current mutator called on them. If the mutator is not
325 // parallel this method does not affect the ordering of the current mutator pass, but will
326 // be ordered correctly for all future mutator passes.
Usta Shresthac725f472022-01-11 02:44:21 -0500327 AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, names ...string) []blueprint.Module
Colin Cross9f35c3d2020-09-16 19:04:41 -0700328
329 // AddFarVariationDependencies adds deps as dependencies of the current module, but uses the
Colin Cross4f1dcb02020-09-16 18:45:04 -0700330 // variations argument to select which variant of the dependency to use. It returns a slice of
331 // modules for each dependency (some entries may be nil). A variant of the dependency must
332 // exist that matches the variations argument, but may also have other variations.
Colin Cross9f35c3d2020-09-16 19:04:41 -0700333 // For any unspecified variation the first variant will be used.
334 //
335 // Unlike AddVariationDependencies, the variations of the current module are ignored - the
336 // dependency only needs to match the supplied variations.
Colin Cross4f1dcb02020-09-16 18:45:04 -0700337 //
338 // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the
339 // new dependencies have had the current mutator called on them. If the mutator is not
340 // parallel this method does not affect the ordering of the current mutator pass, but will
341 // be ordered correctly for all future mutator passes.
342 AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) []blueprint.Module
Colin Cross9f35c3d2020-09-16 19:04:41 -0700343
344 // AddInterVariantDependency adds a dependency between two variants of the same module. Variants are always
345 // ordered in the same orderas they were listed in CreateVariations, and AddInterVariantDependency does not change
346 // that ordering, but it associates a DependencyTag with the dependency and makes it visible to VisitDirectDeps,
347 // WalkDeps, etc.
Colin Crossaabf6792017-11-29 00:27:14 -0800348 AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module)
Colin Cross9f35c3d2020-09-16 19:04:41 -0700349
350 // ReplaceDependencies replaces all dependencies on the identical variant of the module with the
351 // specified name with the current variant of this module. Replacements don't take effect until
352 // after the mutator pass is finished.
Colin Crossaabf6792017-11-29 00:27:14 -0800353 ReplaceDependencies(string)
Colin Cross9f35c3d2020-09-16 19:04:41 -0700354
355 // ReplaceDependencies replaces all dependencies on the identical variant of the module with the
356 // specified name with the current variant of this module as long as the supplied predicate returns
357 // true.
358 //
359 // Replacements don't take effect until after the mutator pass is finished.
Paul Duffin80342d72020-06-26 22:08:43 +0100360 ReplaceDependenciesIf(string, blueprint.ReplaceDependencyPredicate)
Colin Cross9f35c3d2020-09-16 19:04:41 -0700361
362 // AliasVariation takes a variationName that was passed to CreateVariations for this module,
363 // and creates an alias from the current variant (before the mutator has run) to the new
364 // variant. The alias will be valid until the next time a mutator calls CreateVariations or
365 // CreateLocalVariations on this module without also calling AliasVariation. The alias can
366 // be used to add dependencies on the newly created variant using the variant map from
367 // before CreateVariations was run.
Jaewoong Jung9f88ce22019-11-15 10:57:34 -0800368 AliasVariation(variationName string)
Colin Cross9f35c3d2020-09-16 19:04:41 -0700369
370 // CreateAliasVariation takes a toVariationName that was passed to CreateVariations for this
371 // module, and creates an alias from a new fromVariationName variant the toVariationName
372 // variant. The alias will be valid until the next time a mutator calls CreateVariations or
373 // CreateLocalVariations on this module without also calling AliasVariation. The alias can
374 // be used to add dependencies on the toVariationName variant using the fromVariationName
375 // variant.
Colin Cross1b9604b2020-08-11 12:03:56 -0700376 CreateAliasVariation(fromVariationName, toVariationName string)
Colin Crossd27e7b82020-07-02 11:38:17 -0700377
378 // SetVariationProvider sets the value for a provider for the given newly created variant of
379 // the current module, i.e. one of the Modules returned by CreateVariations.. It panics if
380 // not called during the appropriate mutator or GenerateBuildActions pass for the provider,
381 // if the value is not of the appropriate type, or if the module is not a newly created
382 // variant of the current module. The value should not be modified after being passed to
383 // SetVariationProvider.
384 SetVariationProvider(module blueprint.Module, provider blueprint.ProviderKey, value interface{})
Colin Cross6362e272015-10-29 15:25:03 -0700385}
386
Colin Cross25de6c32019-06-06 14:29:25 -0700387type bottomUpMutatorContext struct {
Colin Crossdc35e212019-06-06 16:13:11 -0700388 bp blueprint.BottomUpMutatorContext
Colin Cross0ea8ba82019-06-06 14:33:29 -0700389 baseModuleContext
Chris Parsons5a34ffb2021-07-21 14:34:58 -0400390 finalPhase bool
Colin Cross6362e272015-10-29 15:25:03 -0700391}
392
Colin Cross617b88a2020-08-24 18:04:09 -0700393func bottomUpMutatorContextFactory(ctx blueprint.BottomUpMutatorContext, a Module,
Liz Kammer356f7d42021-01-26 09:18:53 -0500394 finalPhase, bazelConversionMode bool) BottomUpMutatorContext {
Colin Cross617b88a2020-08-24 18:04:09 -0700395
Chris Parsons5a34ffb2021-07-21 14:34:58 -0400396 moduleContext := a.base().baseModuleContextFactory(ctx)
397 moduleContext.bazelConversionMode = bazelConversionMode
398
Colin Cross617b88a2020-08-24 18:04:09 -0700399 return &bottomUpMutatorContext{
Chris Parsons5a34ffb2021-07-21 14:34:58 -0400400 bp: ctx,
401 baseModuleContext: a.base().baseModuleContextFactory(ctx),
402 finalPhase: finalPhase,
Colin Cross617b88a2020-08-24 18:04:09 -0700403 }
404}
405
Colin Cross25de6c32019-06-06 14:29:25 -0700406func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle {
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000407 finalPhase := x.finalPhase
Liz Kammer356f7d42021-01-26 09:18:53 -0500408 bazelConversionMode := x.bazelConversionMode
Colin Cross798bfce2016-10-12 14:28:16 -0700409 f := func(ctx blueprint.BottomUpMutatorContext) {
Colin Cross635c3b02016-05-18 15:37:25 -0700410 if a, ok := ctx.Module().(Module); ok {
Liz Kammer356f7d42021-01-26 09:18:53 -0500411 m(bottomUpMutatorContextFactory(ctx, a, finalPhase, bazelConversionMode))
Colin Cross6362e272015-10-29 15:25:03 -0700412 }
Colin Cross798bfce2016-10-12 14:28:16 -0700413 }
Liz Kammer356f7d42021-01-26 09:18:53 -0500414 mutator := &mutator{name: x.mutatorName(name), bottomUpMutator: f}
Colin Cross795c3772017-03-16 16:50:10 -0700415 x.mutators = append(x.mutators, mutator)
Colin Cross798bfce2016-10-12 14:28:16 -0700416 return mutator
Colin Cross6362e272015-10-29 15:25:03 -0700417}
418
Colin Cross617b88a2020-08-24 18:04:09 -0700419func (x *registerMutatorsContext) BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle {
420 mutator := &mutator{name: name, bottomUpMutator: m}
421 x.mutators = append(x.mutators, mutator)
422 return mutator
423}
424
Lukacs T. Berki6c716762022-06-13 20:50:39 +0200425type IncomingTransitionContext interface {
426 // Module returns the target of the dependency edge for which the transition
427 // is being computed
428 Module() Module
429
430 // Config returns the configuration for the build.
431 Config() Config
432}
433
434type OutgoingTransitionContext interface {
435 // Module returns the target of the dependency edge for which the transition
436 // is being computed
437 Module() Module
438
439 // DepTag() Returns the dependency tag through which this dependency is
440 // reached
441 DepTag() blueprint.DependencyTag
442}
Lukacs T. Berki0e691c12022-06-24 10:15:55 +0200443
444// Transition mutators implement a top-down mechanism where a module tells its
445// direct dependencies what variation they should be built in but the dependency
446// has the final say.
447//
448// When implementing a transition mutator, one needs to implement four methods:
449// - Split() that tells what variations a module has by itself
450// - OutgoingTransition() where a module tells what it wants from its
451// dependency
452// - IncomingTransition() where a module has the final say about its own
453// variation
454// - Mutate() that changes the state of a module depending on its variation
455//
456// That the effective variation of module B when depended on by module A is the
457// composition the outgoing transition of module A and the incoming transition
458// of module B.
459//
460// the outgoing transition should not take the properties of the dependency into
461// account, only those of the module that depends on it. For this reason, the
462// dependency is not even passed into it as an argument. Likewise, the incoming
463// transition should not take the properties of the depending module into
464// account and is thus not informed about it. This makes for a nice
465// decomposition of the decision logic.
466//
467// A given transition mutator only affects its own variation; other variations
468// stay unchanged along the dependency edges.
469//
470// Soong makes sure that all modules are created in the desired variations and
471// that dependency edges are set up correctly. This ensures that "missing
472// variation" errors do not happen and allows for more flexible changes in the
473// value of the variation among dependency edges (as oppposed to bottom-up
474// mutators where if module A in variation X depends on module B and module B
475// has that variation X, A must depend on variation X of B)
476//
477// The limited power of the context objects passed to individual mutators
478// methods also makes it more difficult to shoot oneself in the foot. Complete
479// safety is not guaranteed because no one prevents individual transition
480// mutators from mutating modules in illegal ways and for e.g. Split() or
481// Mutate() to run their own visitations of the transitive dependency of the
482// module and both of these are bad ideas, but it's better than no guardrails at
483// all.
484//
485// This model is pretty close to Bazel's configuration transitions. The mapping
486// between concepts in Soong and Bazel is as follows:
487// - Module == configured target
488// - Variant == configuration
489// - Variation name == configuration flag
490// - Variation == configuration flag value
491// - Outgoing transition == attribute transition
492// - Incoming transition == rule transition
493//
494// The Split() method does not have a Bazel equivalent and Bazel split
495// transitions do not have a Soong equivalent.
496//
497// Mutate() does not make sense in Bazel due to the different models of the
498// two systems: when creating new variations, Soong clones the old module and
499// thus some way is needed to change it state whereas Bazel creates each
500// configuration of a given configured target anew.
Lukacs T. Berki6c716762022-06-13 20:50:39 +0200501type TransitionMutator interface {
502 // Split returns the set of variations that should be created for a module no
503 // matter who depends on it. Used when Make depends on a particular variation
504 // or when the module knows its variations just based on information given to
505 // it in the Blueprint file. This method should not mutate the module it is
506 // called on.
507 Split(ctx BaseModuleContext) []string
508
Lukacs T. Berki0e691c12022-06-24 10:15:55 +0200509 // Called on a module to determine which variation it wants from its direct
Lukacs T. Berki6c716762022-06-13 20:50:39 +0200510 // dependencies. The dependency itself can override this decision. This method
511 // should not mutate the module itself.
512 OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string
513
514 // Called on a module to determine which variation it should be in based on
515 // the variation modules that depend on it want. This gives the module a final
516 // say about its own variations. This method should not mutate the module
517 // itself.
518 IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string
519
520 // Called after a module was split into multiple variations on each variation.
521 // It should not split the module any further but adding new dependencies is
522 // fine. Unlike all the other methods on TransitionMutator, this method is
523 // allowed to mutate the module.
524 Mutate(ctx BottomUpMutatorContext, variation string)
525}
526
527type androidTransitionMutator struct {
528 finalPhase bool
529 bazelConversionMode bool
530 mutator TransitionMutator
531}
532
533func (a *androidTransitionMutator) Split(ctx blueprint.BaseModuleContext) []string {
534 if m, ok := ctx.Module().(Module); ok {
535 moduleContext := m.base().baseModuleContextFactory(ctx)
536 moduleContext.bazelConversionMode = a.bazelConversionMode
537 return a.mutator.Split(&moduleContext)
538 } else {
539 return []string{""}
540 }
541}
542
543type outgoingTransitionContextImpl struct {
544 bp blueprint.OutgoingTransitionContext
545}
546
547func (c *outgoingTransitionContextImpl) Module() Module {
548 return c.bp.Module().(Module)
549}
550
551func (c *outgoingTransitionContextImpl) DepTag() blueprint.DependencyTag {
552 return c.bp.DepTag()
553}
554
555func (a *androidTransitionMutator) OutgoingTransition(ctx blueprint.OutgoingTransitionContext, sourceVariation string) string {
556 if _, ok := ctx.Module().(Module); ok {
557 return a.mutator.OutgoingTransition(&outgoingTransitionContextImpl{bp: ctx}, sourceVariation)
558 } else {
559 return ""
560 }
561}
562
563type incomingTransitionContextImpl struct {
564 bp blueprint.IncomingTransitionContext
565}
566
567func (c *incomingTransitionContextImpl) Module() Module {
568 return c.bp.Module().(Module)
569}
570
571func (c *incomingTransitionContextImpl) Config() Config {
572 return c.bp.Config().(Config)
573}
574
575func (a *androidTransitionMutator) IncomingTransition(ctx blueprint.IncomingTransitionContext, incomingVariation string) string {
576 if _, ok := ctx.Module().(Module); ok {
577 return a.mutator.IncomingTransition(&incomingTransitionContextImpl{bp: ctx}, incomingVariation)
578 } else {
579 return ""
580 }
581}
582
583func (a *androidTransitionMutator) Mutate(ctx blueprint.BottomUpMutatorContext, variation string) {
584 if am, ok := ctx.Module().(Module); ok {
585 a.mutator.Mutate(bottomUpMutatorContextFactory(ctx, am, a.finalPhase, a.bazelConversionMode), variation)
586 }
587}
588
589func (x *registerMutatorsContext) Transition(name string, m TransitionMutator) {
590 atm := &androidTransitionMutator{
591 finalPhase: x.finalPhase,
592 bazelConversionMode: x.bazelConversionMode,
593 mutator: m,
594 }
595 mutator := &mutator{
596 name: name,
597 transitionMutator: atm}
598 x.mutators = append(x.mutators, mutator)
599}
600
Liz Kammer356f7d42021-01-26 09:18:53 -0500601func (x *registerMutatorsContext) mutatorName(name string) string {
602 if x.bazelConversionMode {
603 return name + "_bp2build"
604 }
605 return name
606}
607
Colin Cross25de6c32019-06-06 14:29:25 -0700608func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) MutatorHandle {
Colin Cross798bfce2016-10-12 14:28:16 -0700609 f := func(ctx blueprint.TopDownMutatorContext) {
Colin Cross635c3b02016-05-18 15:37:25 -0700610 if a, ok := ctx.Module().(Module); ok {
Chris Parsons5a34ffb2021-07-21 14:34:58 -0400611 moduleContext := a.base().baseModuleContextFactory(ctx)
612 moduleContext.bazelConversionMode = x.bazelConversionMode
Colin Cross25de6c32019-06-06 14:29:25 -0700613 actx := &topDownMutatorContext{
Colin Crossdc35e212019-06-06 16:13:11 -0700614 bp: ctx,
Chris Parsons5a34ffb2021-07-21 14:34:58 -0400615 baseModuleContext: moduleContext,
Colin Cross6362e272015-10-29 15:25:03 -0700616 }
Colin Cross798bfce2016-10-12 14:28:16 -0700617 m(actx)
Colin Cross6362e272015-10-29 15:25:03 -0700618 }
Colin Cross798bfce2016-10-12 14:28:16 -0700619 }
Liz Kammer356f7d42021-01-26 09:18:53 -0500620 mutator := &mutator{name: x.mutatorName(name), topDownMutator: f}
Colin Cross795c3772017-03-16 16:50:10 -0700621 x.mutators = append(x.mutators, mutator)
Colin Cross798bfce2016-10-12 14:28:16 -0700622 return mutator
623}
624
Paul Duffin1d2d42f2021-03-06 20:08:12 +0000625func (mutator *mutator) componentName() string {
626 return mutator.name
627}
628
629func (mutator *mutator) register(ctx *Context) {
630 blueprintCtx := ctx.Context
631 var handle blueprint.MutatorHandle
632 if mutator.bottomUpMutator != nil {
633 handle = blueprintCtx.RegisterBottomUpMutator(mutator.name, mutator.bottomUpMutator)
634 } else if mutator.topDownMutator != nil {
635 handle = blueprintCtx.RegisterTopDownMutator(mutator.name, mutator.topDownMutator)
Lukacs T. Berki6c716762022-06-13 20:50:39 +0200636 } else if mutator.transitionMutator != nil {
637 blueprintCtx.RegisterTransitionMutator(mutator.name, mutator.transitionMutator)
Paul Duffin1d2d42f2021-03-06 20:08:12 +0000638 }
639 if mutator.parallel {
640 handle.Parallel()
641 }
642}
643
Colin Cross798bfce2016-10-12 14:28:16 -0700644type MutatorHandle interface {
645 Parallel() MutatorHandle
646}
647
648func (mutator *mutator) Parallel() MutatorHandle {
649 mutator.parallel = true
650 return mutator
Colin Cross6362e272015-10-29 15:25:03 -0700651}
Colin Cross1e676be2016-10-12 14:38:15 -0700652
Paul Duffin44f1d842020-06-26 20:17:02 +0100653func RegisterComponentsMutator(ctx RegisterMutatorsContext) {
654 ctx.BottomUp("component-deps", componentDepsMutator).Parallel()
655}
656
657// A special mutator that runs just prior to the deps mutator to allow the dependencies
658// on component modules to be added so that they can depend directly on a prebuilt
659// module.
660func componentDepsMutator(ctx BottomUpMutatorContext) {
661 if m := ctx.Module(); m.Enabled() {
662 m.ComponentDepsMutator(ctx)
663 }
664}
665
Colin Cross1e676be2016-10-12 14:38:15 -0700666func depsMutator(ctx BottomUpMutatorContext) {
Paul Duffin44f1d842020-06-26 20:17:02 +0100667 if m := ctx.Module(); m.Enabled() {
Colin Cross1e676be2016-10-12 14:38:15 -0700668 m.DepsMutator(ctx)
669 }
670}
Colin Crossd11fcda2017-10-23 17:59:01 -0700671
Liz Kammer356f7d42021-01-26 09:18:53 -0500672func registerDepsMutator(ctx RegisterMutatorsContext) {
673 ctx.BottomUp("deps", depsMutator).Parallel()
674}
675
676func registerDepsMutatorBp2Build(ctx RegisterMutatorsContext) {
677 // TODO(b/179313531): Consider a separate mutator that only runs depsMutator for modules that are
678 // being converted to build targets.
679 ctx.BottomUp("deps", depsMutator).Parallel()
680}
681
Jingwen Chen1fd14692021-02-05 03:01:50 -0500682func (t *topDownMutatorContext) CreateBazelTargetModule(
Jingwen Chen1fd14692021-02-05 03:01:50 -0500683 bazelProps bazel.BazelTargetModuleProperties,
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux447f6c92021-08-31 20:30:36 +0000684 commonAttrs CommonAttributes,
Liz Kammer2ada09a2021-08-11 00:17:36 -0400685 attrs interface{}) {
Chris Parsons58852a02021-12-09 18:10:18 -0500686 t.createBazelTargetModule(bazelProps, commonAttrs, attrs, bazel.BoolAttribute{})
687}
688
689func (t *topDownMutatorContext) CreateBazelTargetModuleWithRestrictions(
690 bazelProps bazel.BazelTargetModuleProperties,
691 commonAttrs CommonAttributes,
692 attrs interface{},
693 enabledProperty bazel.BoolAttribute) {
694 t.createBazelTargetModule(bazelProps, commonAttrs, attrs, enabledProperty)
695}
696
697func (t *topDownMutatorContext) createBazelTargetModule(
698 bazelProps bazel.BazelTargetModuleProperties,
699 commonAttrs CommonAttributes,
700 attrs interface{},
701 enabledProperty bazel.BoolAttribute) {
702 constraintAttributes := commonAttrs.fillCommonBp2BuildModuleAttrs(t, enabledProperty)
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux447f6c92021-08-31 20:30:36 +0000703 mod := t.Module()
Liz Kammer2ada09a2021-08-11 00:17:36 -0400704 info := bp2buildInfo{
Chris Parsons58852a02021-12-09 18:10:18 -0500705 Dir: t.OtherModuleDir(mod),
706 BazelProps: bazelProps,
707 CommonAttrs: commonAttrs,
708 ConstraintAttrs: constraintAttributes,
709 Attrs: attrs,
Jingwen Chenfb4692a2021-02-07 10:05:16 -0500710 }
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux447f6c92021-08-31 20:30:36 +0000711 mod.base().addBp2buildInfo(info)
Jingwen Chen1fd14692021-02-05 03:01:50 -0500712}
713
Colin Crossdc35e212019-06-06 16:13:11 -0700714// android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that
715// has an overridden version in android.BaseModuleContext has to be manually forwarded to BaseModuleContext to avoid
716// ambiguous method errors, or it has to store a blueprint.TopDownMutatorContext non-embedded, in which case every
717// non-overridden method has to be forwarded. There are fewer non-overridden methods, so use the latter. The following
718// methods forward to the identical blueprint versions for topDownMutatorContext and bottomUpMutatorContext.
719
Colin Crosscb55e082019-07-01 15:32:31 -0700720func (t *topDownMutatorContext) MutatorName() string {
721 return t.bp.MutatorName()
722}
723
Colin Crossdc35e212019-06-06 16:13:11 -0700724func (t *topDownMutatorContext) Rename(name string) {
725 t.bp.Rename(name)
Colin Cross9a362232019-07-01 15:32:45 -0700726 t.Module().base().commonProperties.DebugName = name
Colin Crossdc35e212019-06-06 16:13:11 -0700727}
728
Liz Kammerf31c9002022-04-26 09:08:55 -0400729func (t *topDownMutatorContext) createModule(factory blueprint.ModuleFactory, name string, props ...interface{}) blueprint.Module {
730 return t.bp.CreateModule(factory, name, props...)
731}
732
Colin Crosse003c4a2019-09-25 12:58:36 -0700733func (t *topDownMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) Module {
Liz Kammerf31c9002022-04-26 09:08:55 -0400734 return createModule(t, factory, "_topDownMutatorModule", props...)
Colin Crossdc35e212019-06-06 16:13:11 -0700735}
736
Liz Kammera060c452021-03-24 10:14:47 -0400737func (t *topDownMutatorContext) createModuleWithoutInheritance(factory ModuleFactory, props ...interface{}) Module {
Liz Kammerf31c9002022-04-26 09:08:55 -0400738 module := t.bp.CreateModule(ModuleFactoryAdaptor(factory), "", props...).(Module)
Liz Kammera060c452021-03-24 10:14:47 -0400739 return module
740}
741
Colin Crosscb55e082019-07-01 15:32:31 -0700742func (b *bottomUpMutatorContext) MutatorName() string {
743 return b.bp.MutatorName()
744}
745
Colin Crossdc35e212019-06-06 16:13:11 -0700746func (b *bottomUpMutatorContext) Rename(name string) {
747 b.bp.Rename(name)
Colin Cross9a362232019-07-01 15:32:45 -0700748 b.Module().base().commonProperties.DebugName = name
Colin Crossdc35e212019-06-06 16:13:11 -0700749}
750
Colin Cross4f1dcb02020-09-16 18:45:04 -0700751func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module {
752 return b.bp.AddDependency(module, tag, name...)
Colin Crossdc35e212019-06-06 16:13:11 -0700753}
754
755func (b *bottomUpMutatorContext) AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) {
756 b.bp.AddReverseDependency(module, tag, name)
757}
758
Colin Cross43b92e02019-11-18 15:28:57 -0800759func (b *bottomUpMutatorContext) CreateVariations(variations ...string) []Module {
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000760 if b.finalPhase {
761 panic("CreateVariations not allowed in FinalDepsMutators")
762 }
763
Colin Cross9a362232019-07-01 15:32:45 -0700764 modules := b.bp.CreateVariations(variations...)
765
Colin Cross43b92e02019-11-18 15:28:57 -0800766 aModules := make([]Module, len(modules))
Colin Cross9a362232019-07-01 15:32:45 -0700767 for i := range variations {
Colin Cross43b92e02019-11-18 15:28:57 -0800768 aModules[i] = modules[i].(Module)
769 base := aModules[i].base()
Colin Cross9a362232019-07-01 15:32:45 -0700770 base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, b.MutatorName())
771 base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variations[i])
772 }
773
Colin Cross43b92e02019-11-18 15:28:57 -0800774 return aModules
Colin Crossdc35e212019-06-06 16:13:11 -0700775}
776
Colin Cross43b92e02019-11-18 15:28:57 -0800777func (b *bottomUpMutatorContext) CreateLocalVariations(variations ...string) []Module {
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000778 if b.finalPhase {
779 panic("CreateLocalVariations not allowed in FinalDepsMutators")
780 }
781
Colin Cross9a362232019-07-01 15:32:45 -0700782 modules := b.bp.CreateLocalVariations(variations...)
783
Colin Cross43b92e02019-11-18 15:28:57 -0800784 aModules := make([]Module, len(modules))
Colin Cross9a362232019-07-01 15:32:45 -0700785 for i := range variations {
Colin Cross43b92e02019-11-18 15:28:57 -0800786 aModules[i] = modules[i].(Module)
787 base := aModules[i].base()
Colin Cross9a362232019-07-01 15:32:45 -0700788 base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, b.MutatorName())
789 base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variations[i])
790 }
791
Colin Cross43b92e02019-11-18 15:28:57 -0800792 return aModules
Colin Crossdc35e212019-06-06 16:13:11 -0700793}
794
795func (b *bottomUpMutatorContext) SetDependencyVariation(variation string) {
796 b.bp.SetDependencyVariation(variation)
797}
798
Jiyong Park1d1119f2019-07-29 21:27:18 +0900799func (b *bottomUpMutatorContext) SetDefaultDependencyVariation(variation *string) {
800 b.bp.SetDefaultDependencyVariation(variation)
801}
802
Colin Crossdc35e212019-06-06 16:13:11 -0700803func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag,
Colin Cross4f1dcb02020-09-16 18:45:04 -0700804 names ...string) []blueprint.Module {
Colin Cross4f1dcb02020-09-16 18:45:04 -0700805 return b.bp.AddVariationDependencies(variations, tag, names...)
Colin Crossdc35e212019-06-06 16:13:11 -0700806}
807
808func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation,
Colin Cross4f1dcb02020-09-16 18:45:04 -0700809 tag blueprint.DependencyTag, names ...string) []blueprint.Module {
Colin Crossdc35e212019-06-06 16:13:11 -0700810
Colin Cross4f1dcb02020-09-16 18:45:04 -0700811 return b.bp.AddFarVariationDependencies(variations, tag, names...)
Colin Crossdc35e212019-06-06 16:13:11 -0700812}
813
814func (b *bottomUpMutatorContext) AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) {
815 b.bp.AddInterVariantDependency(tag, from, to)
816}
817
818func (b *bottomUpMutatorContext) ReplaceDependencies(name string) {
819 b.bp.ReplaceDependencies(name)
820}
Jaewoong Jung9f88ce22019-11-15 10:57:34 -0800821
Paul Duffin80342d72020-06-26 22:08:43 +0100822func (b *bottomUpMutatorContext) ReplaceDependenciesIf(name string, predicate blueprint.ReplaceDependencyPredicate) {
823 b.bp.ReplaceDependenciesIf(name, predicate)
824}
825
Jaewoong Jung9f88ce22019-11-15 10:57:34 -0800826func (b *bottomUpMutatorContext) AliasVariation(variationName string) {
827 b.bp.AliasVariation(variationName)
828}
Colin Cross1b9604b2020-08-11 12:03:56 -0700829
830func (b *bottomUpMutatorContext) CreateAliasVariation(fromVariationName, toVariationName string) {
831 b.bp.CreateAliasVariation(fromVariationName, toVariationName)
832}
Colin Crossd27e7b82020-07-02 11:38:17 -0700833
834func (b *bottomUpMutatorContext) SetVariationProvider(module blueprint.Module, provider blueprint.ProviderKey, value interface{}) {
835 b.bp.SetVariationProvider(module, provider, value)
836}