blob: 40e61deb2595fa9ad728f619f2a45b90397804de [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 (
Colin Cross18c46802019-09-24 22:19:02 -070018 "reflect"
19
Colin Cross795c3772017-03-16 16:50:10 -070020 "github.com/google/blueprint"
Colin Cross519917d2017-11-02 16:35:56 -070021 "github.com/google/blueprint/proptools"
Colin Cross795c3772017-03-16 16:50:10 -070022)
Colin Cross6362e272015-10-29 15:25:03 -070023
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070024// Phases:
25// run Pre-arch mutators
26// run archMutator
27// run Pre-deps mutators
28// run depsMutator
29// run PostDeps mutators
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000030// run FinalDeps mutators (CreateVariations disallowed in this phase)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -070031// continue on to GenerateAndroidBuildActions
Colin Cross1e676be2016-10-12 14:38:15 -070032
Colin Cross795c3772017-03-16 16:50:10 -070033func 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 Cross1e676be2016-10-12 14:38:15 -070043 }
44 }
Colin Cross1e676be2016-10-12 14:38:15 -070045}
46
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000047func registerMutators(ctx *blueprint.Context, preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc) {
Colin Crosscec81712017-07-13 14:43:27 -070048 mctx := &registerMutatorsContext{}
Nan Zhangdb0b9a32017-02-27 10:12:13 -080049
50 register := func(funcs []RegisterMutatorFunc) {
51 for _, f := range funcs {
Colin Crosscec81712017-07-13 14:43:27 -070052 f(mctx)
Nan Zhangdb0b9a32017-02-27 10:12:13 -080053 }
54 }
55
Colin Crosscec81712017-07-13 14:43:27 -070056 register(preArch)
Nan Zhangdb0b9a32017-02-27 10:12:13 -080057
Colin Crosscec81712017-07-13 14:43:27 -070058 register(preDeps)
59
60 mctx.BottomUp("deps", depsMutator).Parallel()
61
62 register(postDeps)
63
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000064 mctx.finalPhase = true
65 register(finalDeps)
66
Colin Crosscec81712017-07-13 14:43:27 -070067 registerMutatorsToContext(ctx, mctx.mutators)
Colin Cross795c3772017-03-16 16:50:10 -070068}
69
70type registerMutatorsContext struct {
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000071 mutators []*mutator
72 finalPhase bool
Colin Cross795c3772017-03-16 16:50:10 -070073}
Colin Cross1e676be2016-10-12 14:38:15 -070074
75type RegisterMutatorsContext interface {
Colin Cross25de6c32019-06-06 14:29:25 -070076 TopDown(name string, m TopDownMutator) MutatorHandle
77 BottomUp(name string, m BottomUpMutator) MutatorHandle
Colin Cross1e676be2016-10-12 14:38:15 -070078}
79
80type RegisterMutatorFunc func(RegisterMutatorsContext)
81
Colin Crosscec81712017-07-13 14:43:27 -070082var preArch = []RegisterMutatorFunc{
Dan Willemsen6e72ef72018-01-26 18:27:02 -080083 RegisterNamespaceMutator,
Paul Duffinaa4162e2020-05-05 11:35:43 +010084
Paul Duffinaa4162e2020-05-05 11:35:43 +010085 // Check the visibility rules are valid.
86 //
87 // This must run after the package renamer mutators so that any issues found during
88 // validation of the package's default_visibility property are reported using the
89 // correct package name and not the synthetic name.
90 //
91 // This must also be run before defaults mutators as the rules for validation are
92 // different before checking the rules than they are afterwards. e.g.
93 // visibility: ["//visibility:private", "//visibility:public"]
94 // would be invalid if specified in a module definition but is valid if it results
95 // from something like this:
96 //
97 // defaults {
98 // name: "defaults",
99 // // Be inaccessible outside a package by default.
100 // visibility: ["//visibility:private"]
101 // }
102 //
103 // defaultable_module {
104 // name: "defaultable_module",
105 // defaults: ["defaults"],
106 // // Override the default.
107 // visibility: ["//visibility:public"]
108 // }
109 //
Paul Duffin593b3c92019-12-05 14:31:48 +0000110 RegisterVisibilityRuleChecker,
Paul Duffinaa4162e2020-05-05 11:35:43 +0100111
112 // Apply properties from defaults modules to the referencing modules.
Paul Duffinafa9fa12020-04-29 16:47:28 +0100113 //
114 // Any mutators that are added before this will not see any modules created by
115 // a DefaultableHook.
Colin Cross89536d42017-07-07 14:35:50 -0700116 RegisterDefaultsPreArchMutators,
Paul Duffinaa4162e2020-05-05 11:35:43 +0100117
Paul Duffin44f1d842020-06-26 20:17:02 +0100118 // Add dependencies on any components so that any component references can be
119 // resolved within the deps mutator.
120 //
121 // Must be run after defaults so it can be used to create dependencies on the
122 // component modules that are creating in a DefaultableHook.
123 //
124 // Must be run before RegisterPrebuiltsPreArchMutators, i.e. before prebuilts are
125 // renamed. That is so that if a module creates components using a prebuilt module
126 // type that any dependencies (which must use prebuilt_ prefixes) are resolved to
127 // the prebuilt module and not the source module.
128 RegisterComponentsMutator,
129
Paul Duffinc988c8e2020-04-29 18:27:14 +0100130 // Create an association between prebuilt modules and their corresponding source
131 // modules (if any).
Paul Duffinafa9fa12020-04-29 16:47:28 +0100132 //
133 // Must be run after defaults mutators to ensure that any modules created by
134 // a DefaultableHook can be either a prebuilt or a source module with a matching
135 // prebuilt.
Paul Duffinc988c8e2020-04-29 18:27:14 +0100136 RegisterPrebuiltsPreArchMutators,
137
Paul Duffinaa4162e2020-05-05 11:35:43 +0100138 // Gather the visibility rules for all modules for us during visibility enforcement.
139 //
140 // This must come after the defaults mutators to ensure that any visibility supplied
141 // in a defaults module has been successfully applied before the rules are gathered.
Paul Duffin593b3c92019-12-05 14:31:48 +0000142 RegisterVisibilityRuleGatherer,
Colin Crosscec81712017-07-13 14:43:27 -0700143}
144
Colin Crossae4c6182017-09-15 17:33:55 -0700145func registerArchMutator(ctx RegisterMutatorsContext) {
Colin Crossa195f912019-10-16 11:07:20 -0700146 ctx.BottomUp("os", osMutator).Parallel()
Colin Crossfb0c16e2019-11-20 17:12:35 -0800147 ctx.BottomUp("image", imageMutator).Parallel()
Colin Crossae4c6182017-09-15 17:33:55 -0700148 ctx.BottomUp("arch", archMutator).Parallel()
Colin Crossae4c6182017-09-15 17:33:55 -0700149}
150
Colin Crosscec81712017-07-13 14:43:27 -0700151var preDeps = []RegisterMutatorFunc{
Colin Crossae4c6182017-09-15 17:33:55 -0700152 registerArchMutator,
Colin Crosscec81712017-07-13 14:43:27 -0700153}
154
155var postDeps = []RegisterMutatorFunc{
Colin Cross1b488422019-03-04 22:33:56 -0800156 registerPathDepsMutator,
Colin Cross5ea9bcc2017-07-27 15:41:32 -0700157 RegisterPrebuiltsPostDepsMutators,
Paul Duffin593b3c92019-12-05 14:31:48 +0000158 RegisterVisibilityRuleEnforcer,
Artur Satayevc5570ac2020-04-09 16:06:36 +0100159 RegisterNeverallowMutator,
Jaewoong Jungb639a6a2019-05-10 15:16:29 -0700160 RegisterOverridePostDepsMutators,
Colin Crosscec81712017-07-13 14:43:27 -0700161}
Colin Cross1e676be2016-10-12 14:38:15 -0700162
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000163var finalDeps = []RegisterMutatorFunc{}
164
Colin Cross1e676be2016-10-12 14:38:15 -0700165func PreArchMutators(f RegisterMutatorFunc) {
166 preArch = append(preArch, f)
167}
168
169func PreDepsMutators(f RegisterMutatorFunc) {
170 preDeps = append(preDeps, f)
171}
172
173func PostDepsMutators(f RegisterMutatorFunc) {
174 postDeps = append(postDeps, f)
175}
176
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000177func FinalDepsMutators(f RegisterMutatorFunc) {
178 finalDeps = append(finalDeps, f)
179}
180
Colin Cross25de6c32019-06-06 14:29:25 -0700181type TopDownMutator func(TopDownMutatorContext)
Colin Cross6362e272015-10-29 15:25:03 -0700182
Colin Cross635c3b02016-05-18 15:37:25 -0700183type TopDownMutatorContext interface {
Colin Crossaabf6792017-11-29 00:27:14 -0800184 BaseModuleContext
Colin Cross3f68a132017-10-23 17:10:29 -0700185
Colin Crosscb55e082019-07-01 15:32:31 -0700186 MutatorName() string
187
Colin Cross3f68a132017-10-23 17:10:29 -0700188 Rename(name string)
Colin Cross3f68a132017-10-23 17:10:29 -0700189
Colin Crosse003c4a2019-09-25 12:58:36 -0700190 CreateModule(ModuleFactory, ...interface{}) Module
Colin Cross6362e272015-10-29 15:25:03 -0700191}
192
Colin Cross25de6c32019-06-06 14:29:25 -0700193type topDownMutatorContext struct {
Colin Crossdc35e212019-06-06 16:13:11 -0700194 bp blueprint.TopDownMutatorContext
Colin Cross0ea8ba82019-06-06 14:33:29 -0700195 baseModuleContext
Colin Cross6362e272015-10-29 15:25:03 -0700196}
197
Colin Cross25de6c32019-06-06 14:29:25 -0700198type BottomUpMutator func(BottomUpMutatorContext)
Colin Cross6362e272015-10-29 15:25:03 -0700199
Colin Cross635c3b02016-05-18 15:37:25 -0700200type BottomUpMutatorContext interface {
Colin Crossaabf6792017-11-29 00:27:14 -0800201 BaseModuleContext
Colin Crossaabf6792017-11-29 00:27:14 -0800202
Colin Crosscb55e082019-07-01 15:32:31 -0700203 MutatorName() string
204
Colin Crossaabf6792017-11-29 00:27:14 -0800205 Rename(name string)
Colin Crossaabf6792017-11-29 00:27:14 -0800206
207 AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string)
208 AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string)
Colin Cross43b92e02019-11-18 15:28:57 -0800209 CreateVariations(...string) []Module
210 CreateLocalVariations(...string) []Module
Colin Crossaabf6792017-11-29 00:27:14 -0800211 SetDependencyVariation(string)
Jiyong Park1d1119f2019-07-29 21:27:18 +0900212 SetDefaultDependencyVariation(*string)
Colin Crossaabf6792017-11-29 00:27:14 -0800213 AddVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string)
214 AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string)
215 AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module)
216 ReplaceDependencies(string)
Paul Duffin80342d72020-06-26 22:08:43 +0100217 ReplaceDependenciesIf(string, blueprint.ReplaceDependencyPredicate)
Jaewoong Jung9f88ce22019-11-15 10:57:34 -0800218 AliasVariation(variationName string)
Colin Cross1b9604b2020-08-11 12:03:56 -0700219 CreateAliasVariation(fromVariationName, toVariationName string)
Colin Cross6362e272015-10-29 15:25:03 -0700220}
221
Colin Cross25de6c32019-06-06 14:29:25 -0700222type bottomUpMutatorContext struct {
Colin Crossdc35e212019-06-06 16:13:11 -0700223 bp blueprint.BottomUpMutatorContext
Colin Cross0ea8ba82019-06-06 14:33:29 -0700224 baseModuleContext
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000225 finalPhase bool
Colin Cross6362e272015-10-29 15:25:03 -0700226}
227
Colin Cross25de6c32019-06-06 14:29:25 -0700228func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle {
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000229 finalPhase := x.finalPhase
Colin Cross798bfce2016-10-12 14:28:16 -0700230 f := func(ctx blueprint.BottomUpMutatorContext) {
Colin Cross635c3b02016-05-18 15:37:25 -0700231 if a, ok := ctx.Module().(Module); ok {
Colin Cross25de6c32019-06-06 14:29:25 -0700232 actx := &bottomUpMutatorContext{
Colin Crossdc35e212019-06-06 16:13:11 -0700233 bp: ctx,
234 baseModuleContext: a.base().baseModuleContextFactory(ctx),
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000235 finalPhase: finalPhase,
Colin Cross6362e272015-10-29 15:25:03 -0700236 }
Colin Cross798bfce2016-10-12 14:28:16 -0700237 m(actx)
Colin Cross6362e272015-10-29 15:25:03 -0700238 }
Colin Cross798bfce2016-10-12 14:28:16 -0700239 }
240 mutator := &mutator{name: name, bottomUpMutator: f}
Colin Cross795c3772017-03-16 16:50:10 -0700241 x.mutators = append(x.mutators, mutator)
Colin Cross798bfce2016-10-12 14:28:16 -0700242 return mutator
Colin Cross6362e272015-10-29 15:25:03 -0700243}
244
Colin Cross25de6c32019-06-06 14:29:25 -0700245func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) MutatorHandle {
Colin Cross798bfce2016-10-12 14:28:16 -0700246 f := func(ctx blueprint.TopDownMutatorContext) {
Colin Cross635c3b02016-05-18 15:37:25 -0700247 if a, ok := ctx.Module().(Module); ok {
Colin Cross25de6c32019-06-06 14:29:25 -0700248 actx := &topDownMutatorContext{
Colin Crossdc35e212019-06-06 16:13:11 -0700249 bp: ctx,
250 baseModuleContext: a.base().baseModuleContextFactory(ctx),
Colin Cross6362e272015-10-29 15:25:03 -0700251 }
Colin Cross798bfce2016-10-12 14:28:16 -0700252 m(actx)
Colin Cross6362e272015-10-29 15:25:03 -0700253 }
Colin Cross798bfce2016-10-12 14:28:16 -0700254 }
255 mutator := &mutator{name: name, topDownMutator: f}
Colin Cross795c3772017-03-16 16:50:10 -0700256 x.mutators = append(x.mutators, mutator)
Colin Cross798bfce2016-10-12 14:28:16 -0700257 return mutator
258}
259
260type MutatorHandle interface {
261 Parallel() MutatorHandle
262}
263
264func (mutator *mutator) Parallel() MutatorHandle {
265 mutator.parallel = true
266 return mutator
Colin Cross6362e272015-10-29 15:25:03 -0700267}
Colin Cross1e676be2016-10-12 14:38:15 -0700268
Paul Duffin44f1d842020-06-26 20:17:02 +0100269func RegisterComponentsMutator(ctx RegisterMutatorsContext) {
270 ctx.BottomUp("component-deps", componentDepsMutator).Parallel()
271}
272
273// A special mutator that runs just prior to the deps mutator to allow the dependencies
274// on component modules to be added so that they can depend directly on a prebuilt
275// module.
276func componentDepsMutator(ctx BottomUpMutatorContext) {
277 if m := ctx.Module(); m.Enabled() {
278 m.ComponentDepsMutator(ctx)
279 }
280}
281
Colin Cross1e676be2016-10-12 14:38:15 -0700282func depsMutator(ctx BottomUpMutatorContext) {
Paul Duffin44f1d842020-06-26 20:17:02 +0100283 if m := ctx.Module(); m.Enabled() {
Colin Cross1e676be2016-10-12 14:38:15 -0700284 m.DepsMutator(ctx)
285 }
286}
Colin Crossd11fcda2017-10-23 17:59:01 -0700287
Colin Cross25de6c32019-06-06 14:29:25 -0700288func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {
Colin Cross519917d2017-11-02 16:35:56 -0700289 for _, p := range props {
Colin Cross25de6c32019-06-06 14:29:25 -0700290 err := proptools.AppendMatchingProperties(t.Module().base().customizableProperties,
Colin Cross519917d2017-11-02 16:35:56 -0700291 p, nil)
292 if err != nil {
293 if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
Colin Cross25de6c32019-06-06 14:29:25 -0700294 t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
Colin Cross519917d2017-11-02 16:35:56 -0700295 } else {
296 panic(err)
297 }
298 }
299 }
300}
301
Colin Cross25de6c32019-06-06 14:29:25 -0700302func (t *topDownMutatorContext) PrependProperties(props ...interface{}) {
Colin Cross519917d2017-11-02 16:35:56 -0700303 for _, p := range props {
Colin Cross25de6c32019-06-06 14:29:25 -0700304 err := proptools.PrependMatchingProperties(t.Module().base().customizableProperties,
Colin Cross519917d2017-11-02 16:35:56 -0700305 p, nil)
306 if err != nil {
307 if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
Colin Cross25de6c32019-06-06 14:29:25 -0700308 t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
Colin Cross519917d2017-11-02 16:35:56 -0700309 } else {
310 panic(err)
311 }
312 }
313 }
314}
Colin Crossdc35e212019-06-06 16:13:11 -0700315
316// android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that
317// has an overridden version in android.BaseModuleContext has to be manually forwarded to BaseModuleContext to avoid
318// ambiguous method errors, or it has to store a blueprint.TopDownMutatorContext non-embedded, in which case every
319// non-overridden method has to be forwarded. There are fewer non-overridden methods, so use the latter. The following
320// methods forward to the identical blueprint versions for topDownMutatorContext and bottomUpMutatorContext.
321
Colin Crosscb55e082019-07-01 15:32:31 -0700322func (t *topDownMutatorContext) MutatorName() string {
323 return t.bp.MutatorName()
324}
325
Colin Crossdc35e212019-06-06 16:13:11 -0700326func (t *topDownMutatorContext) Rename(name string) {
327 t.bp.Rename(name)
Colin Cross9a362232019-07-01 15:32:45 -0700328 t.Module().base().commonProperties.DebugName = name
Colin Crossdc35e212019-06-06 16:13:11 -0700329}
330
Colin Crosse003c4a2019-09-25 12:58:36 -0700331func (t *topDownMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) Module {
Colin Cross18c46802019-09-24 22:19:02 -0700332 inherited := []interface{}{&t.Module().base().commonProperties}
Colin Crosse003c4a2019-09-25 12:58:36 -0700333 module := t.bp.CreateModule(ModuleFactoryAdaptor(factory), append(inherited, props...)...).(Module)
Colin Cross18c46802019-09-24 22:19:02 -0700334
335 if t.Module().base().variableProperties != nil && module.base().variableProperties != nil {
336 src := t.Module().base().variableProperties
337 dst := []interface{}{
338 module.base().variableProperties,
339 // Put an empty copy of the src properties into dst so that properties in src that are not in dst
340 // don't cause a "failed to find property to extend" error.
Colin Cross43e789d2020-01-28 09:46:50 -0800341 proptools.CloneEmptyProperties(reflect.ValueOf(src)).Interface(),
Colin Cross18c46802019-09-24 22:19:02 -0700342 }
343 err := proptools.AppendMatchingProperties(dst, src, nil)
344 if err != nil {
345 panic(err)
346 }
347 }
348
Colin Crosse003c4a2019-09-25 12:58:36 -0700349 return module
Colin Crossdc35e212019-06-06 16:13:11 -0700350}
351
Colin Crosscb55e082019-07-01 15:32:31 -0700352func (b *bottomUpMutatorContext) MutatorName() string {
353 return b.bp.MutatorName()
354}
355
Colin Crossdc35e212019-06-06 16:13:11 -0700356func (b *bottomUpMutatorContext) Rename(name string) {
357 b.bp.Rename(name)
Colin Cross9a362232019-07-01 15:32:45 -0700358 b.Module().base().commonProperties.DebugName = name
Colin Crossdc35e212019-06-06 16:13:11 -0700359}
360
361func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) {
362 b.bp.AddDependency(module, tag, name...)
363}
364
365func (b *bottomUpMutatorContext) AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) {
366 b.bp.AddReverseDependency(module, tag, name)
367}
368
Colin Cross43b92e02019-11-18 15:28:57 -0800369func (b *bottomUpMutatorContext) CreateVariations(variations ...string) []Module {
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000370 if b.finalPhase {
371 panic("CreateVariations not allowed in FinalDepsMutators")
372 }
373
Colin Cross9a362232019-07-01 15:32:45 -0700374 modules := b.bp.CreateVariations(variations...)
375
Colin Cross43b92e02019-11-18 15:28:57 -0800376 aModules := make([]Module, len(modules))
Colin Cross9a362232019-07-01 15:32:45 -0700377 for i := range variations {
Colin Cross43b92e02019-11-18 15:28:57 -0800378 aModules[i] = modules[i].(Module)
379 base := aModules[i].base()
Colin Cross9a362232019-07-01 15:32:45 -0700380 base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, b.MutatorName())
381 base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variations[i])
382 }
383
Colin Cross43b92e02019-11-18 15:28:57 -0800384 return aModules
Colin Crossdc35e212019-06-06 16:13:11 -0700385}
386
Colin Cross43b92e02019-11-18 15:28:57 -0800387func (b *bottomUpMutatorContext) CreateLocalVariations(variations ...string) []Module {
Martin Stjernholm710ec3a2020-01-16 15:12:04 +0000388 if b.finalPhase {
389 panic("CreateLocalVariations not allowed in FinalDepsMutators")
390 }
391
Colin Cross9a362232019-07-01 15:32:45 -0700392 modules := b.bp.CreateLocalVariations(variations...)
393
Colin Cross43b92e02019-11-18 15:28:57 -0800394 aModules := make([]Module, len(modules))
Colin Cross9a362232019-07-01 15:32:45 -0700395 for i := range variations {
Colin Cross43b92e02019-11-18 15:28:57 -0800396 aModules[i] = modules[i].(Module)
397 base := aModules[i].base()
Colin Cross9a362232019-07-01 15:32:45 -0700398 base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, b.MutatorName())
399 base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variations[i])
400 }
401
Colin Cross43b92e02019-11-18 15:28:57 -0800402 return aModules
Colin Crossdc35e212019-06-06 16:13:11 -0700403}
404
405func (b *bottomUpMutatorContext) SetDependencyVariation(variation string) {
406 b.bp.SetDependencyVariation(variation)
407}
408
Jiyong Park1d1119f2019-07-29 21:27:18 +0900409func (b *bottomUpMutatorContext) SetDefaultDependencyVariation(variation *string) {
410 b.bp.SetDefaultDependencyVariation(variation)
411}
412
Colin Crossdc35e212019-06-06 16:13:11 -0700413func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag,
414 names ...string) {
415
416 b.bp.AddVariationDependencies(variations, tag, names...)
417}
418
419func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation,
420 tag blueprint.DependencyTag, names ...string) {
421
422 b.bp.AddFarVariationDependencies(variations, tag, names...)
423}
424
425func (b *bottomUpMutatorContext) AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) {
426 b.bp.AddInterVariantDependency(tag, from, to)
427}
428
429func (b *bottomUpMutatorContext) ReplaceDependencies(name string) {
430 b.bp.ReplaceDependencies(name)
431}
Jaewoong Jung9f88ce22019-11-15 10:57:34 -0800432
Paul Duffin80342d72020-06-26 22:08:43 +0100433func (b *bottomUpMutatorContext) ReplaceDependenciesIf(name string, predicate blueprint.ReplaceDependencyPredicate) {
434 b.bp.ReplaceDependenciesIf(name, predicate)
435}
436
Jaewoong Jung9f88ce22019-11-15 10:57:34 -0800437func (b *bottomUpMutatorContext) AliasVariation(variationName string) {
438 b.bp.AliasVariation(variationName)
439}
Colin Cross1b9604b2020-08-11 12:03:56 -0700440
441func (b *bottomUpMutatorContext) CreateAliasVariation(fromVariationName, toVariationName string) {
442 b.bp.CreateAliasVariation(fromVariationName, toVariationName)
443}