Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [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 | |
| 15 | package android |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 19 | "regexp" |
Colin Cross | b614cd4 | 2024-10-11 12:52:21 -0700 | [diff] [blame] | 20 | "slices" |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 21 | "strings" |
Cole Faust | bdd8aee | 2024-03-14 14:33:02 -0700 | [diff] [blame] | 22 | |
| 23 | "github.com/google/blueprint" |
Cole Faust | fdbf5d4 | 2024-04-10 15:01:23 -0700 | [diff] [blame] | 24 | "github.com/google/blueprint/proptools" |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 25 | ) |
| 26 | |
| 27 | // BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns |
| 28 | // a Config instead of an interface{}, and some methods have been wrapped to use an android.Module |
| 29 | // instead of a blueprint.Module, plus some extra methods that return Android-specific information |
| 30 | // about the current module. |
| 31 | type BaseModuleContext interface { |
Colin Cross | 1d3d9f1 | 2024-01-18 14:30:22 -0800 | [diff] [blame] | 32 | ArchModuleContext |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 33 | EarlyModuleContext |
| 34 | |
| 35 | blueprintBaseModuleContext() blueprint.BaseModuleContext |
| 36 | |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 37 | EqualModules(m1, m2 Module) bool |
| 38 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 39 | // OtherModuleName returns the name of another Module. See BaseModuleContext.ModuleName for more information. |
| 40 | // It is intended for use inside the visit functions of Visit* and WalkDeps. |
| 41 | OtherModuleName(m blueprint.Module) string |
| 42 | |
| 43 | // OtherModuleDir returns the directory of another Module. See BaseModuleContext.ModuleDir for more information. |
| 44 | // It is intended for use inside the visit functions of Visit* and WalkDeps. |
| 45 | OtherModuleDir(m blueprint.Module) string |
| 46 | |
| 47 | // OtherModuleErrorf reports an error on another Module. See BaseModuleContext.ModuleErrorf for more information. |
| 48 | // It is intended for use inside the visit functions of Visit* and WalkDeps. |
| 49 | OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) |
| 50 | |
| 51 | // OtherModuleDependencyTag returns the dependency tag used to depend on a module, or nil if there is no dependency |
| 52 | // on the module. When called inside a Visit* method with current module being visited, and there are multiple |
| 53 | // dependencies on the module being visited, it returns the dependency tag used for the current dependency. |
| 54 | OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag |
| 55 | |
| 56 | // OtherModuleExists returns true if a module with the specified name exists, as determined by the NameInterface |
| 57 | // passed to Context.SetNameInterface, or SimpleNameInterface if it was not called. |
| 58 | OtherModuleExists(name string) bool |
| 59 | |
| 60 | // OtherModuleDependencyVariantExists returns true if a module with the |
| 61 | // specified name and variant exists. The variant must match the given |
| 62 | // variations. It must also match all the non-local variations of the current |
| 63 | // module. In other words, it checks for the module that AddVariationDependencies |
| 64 | // would add a dependency on with the same arguments. |
| 65 | OtherModuleDependencyVariantExists(variations []blueprint.Variation, name string) bool |
| 66 | |
| 67 | // OtherModuleFarDependencyVariantExists returns true if a module with the |
| 68 | // specified name and variant exists. The variant must match the given |
| 69 | // variations, but not the non-local variations of the current module. In |
| 70 | // other words, it checks for the module that AddFarVariationDependencies |
| 71 | // would add a dependency on with the same arguments. |
| 72 | OtherModuleFarDependencyVariantExists(variations []blueprint.Variation, name string) bool |
| 73 | |
| 74 | // OtherModuleReverseDependencyVariantExists returns true if a module with the |
| 75 | // specified name exists with the same variations as the current module. In |
| 76 | // other words, it checks for the module that AddReverseDependency would add a |
| 77 | // dependency on with the same argument. |
| 78 | OtherModuleReverseDependencyVariantExists(name string) bool |
| 79 | |
| 80 | // OtherModuleType returns the type of another Module. See BaseModuleContext.ModuleType for more information. |
| 81 | // It is intended for use inside the visit functions of Visit* and WalkDeps. |
| 82 | OtherModuleType(m blueprint.Module) string |
| 83 | |
Colin Cross | 24c1cbe | 2023-12-21 23:42:56 +0000 | [diff] [blame] | 84 | // otherModuleProvider returns the value for a provider for the given module. If the value is |
| 85 | // not set it returns nil and false. The value returned may be a deep copy of the value originally |
| 86 | // passed to SetProvider. |
| 87 | // |
| 88 | // This method shouldn't be used directly, prefer the type-safe android.OtherModuleProvider instead. |
Colin Cross | 3c0a83d | 2023-12-12 14:13:26 -0800 | [diff] [blame] | 89 | otherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 90 | |
Jihoon Kang | 2a7bf75 | 2024-11-01 21:21:25 +0000 | [diff] [blame] | 91 | // OtherModuleIsAutoGenerated returns true if the module is auto generated by another module |
| 92 | // instead of being defined in Android.bp file. |
| 93 | OtherModuleIsAutoGenerated(m blueprint.Module) bool |
| 94 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 95 | // Provider returns the value for a provider for the current module. If the value is |
Colin Cross | 24c1cbe | 2023-12-21 23:42:56 +0000 | [diff] [blame] | 96 | // not set it returns nil and false. It panics if called before the appropriate |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 97 | // mutator or GenerateBuildActions pass for the provider. The value returned may be a deep |
| 98 | // copy of the value originally passed to SetProvider. |
Colin Cross | 24c1cbe | 2023-12-21 23:42:56 +0000 | [diff] [blame] | 99 | // |
| 100 | // This method shouldn't be used directly, prefer the type-safe android.ModuleProvider instead. |
Colin Cross | 3c0a83d | 2023-12-12 14:13:26 -0800 | [diff] [blame] | 101 | provider(provider blueprint.AnyProviderKey) (any, bool) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 102 | |
Colin Cross | 24c1cbe | 2023-12-21 23:42:56 +0000 | [diff] [blame] | 103 | // setProvider sets the value for a provider for the current module. It panics if not called |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 104 | // during the appropriate mutator or GenerateBuildActions pass for the provider, if the value |
| 105 | // is not of the appropriate type, or if the value has already been set. The value should not |
| 106 | // be modified after being passed to SetProvider. |
Colin Cross | 24c1cbe | 2023-12-21 23:42:56 +0000 | [diff] [blame] | 107 | // |
| 108 | // This method shouldn't be used directly, prefer the type-safe android.SetProvider instead. |
| 109 | setProvider(provider blueprint.AnyProviderKey, value any) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 110 | |
| 111 | GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module |
| 112 | |
Yu Liu | f432c2e | 2024-12-17 00:09:15 +0000 | [diff] [blame] | 113 | GetDirectDepsProxyWithTag(tag blueprint.DependencyTag) []ModuleProxy |
| 114 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 115 | // GetDirectDepWithTag returns the Module the direct dependency with the specified name, or nil if |
| 116 | // none exists. It panics if the dependency does not have the specified tag. It skips any |
| 117 | // dependencies that are not an android.Module. |
Yu Liu | d3228ac | 2024-11-08 23:11:47 +0000 | [diff] [blame] | 118 | GetDirectDepWithTag(name string, tag blueprint.DependencyTag) Module |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 119 | |
Yu Liu | 3ae9665 | 2024-12-17 22:27:38 +0000 | [diff] [blame] | 120 | GetDirectDepProxyWithTag(name string, tag blueprint.DependencyTag) *ModuleProxy |
| 121 | |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 122 | // VisitDirectDeps calls visit for each direct dependency. If there are multiple |
| 123 | // direct dependencies on the same module visit will be called multiple times on that module |
| 124 | // and OtherModuleDependencyTag will return a different tag for each. It raises an error if any of the |
| 125 | // dependencies are disabled. |
| 126 | // |
| 127 | // The Module passed to the visit function should not be retained outside of the visit |
| 128 | // function, it may be invalidated by future mutators. |
| 129 | VisitDirectDeps(visit func(Module)) |
| 130 | |
Yu Liu | d3228ac | 2024-11-08 23:11:47 +0000 | [diff] [blame] | 131 | // VisitDirectDepsProxy calls visit for each direct dependency. If there are multiple |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 132 | // direct dependencies on the same module visit will be called multiple times on that module |
Yu Liu | d3228ac | 2024-11-08 23:11:47 +0000 | [diff] [blame] | 133 | // and OtherModuleDependencyTag will return a different tag for each. It raises an error if any of the |
| 134 | // dependencies are disabled. |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 135 | // |
Yu Liu | d3228ac | 2024-11-08 23:11:47 +0000 | [diff] [blame] | 136 | // The ModuleProxy passed to the visit function should not be retained outside of the visit |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 137 | // function, it may be invalidated by future mutators. |
Yu Liu | d3228ac | 2024-11-08 23:11:47 +0000 | [diff] [blame] | 138 | VisitDirectDepsProxy(visit func(proxy ModuleProxy)) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 139 | |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 140 | // VisitDirectDepsProxyAllowDisabled calls visit for each direct dependency. If there are |
| 141 | // multiple direct dependencies on the same module visit will be called multiple times on |
| 142 | // that module and OtherModuleDependencyTag will return a different tag for each. |
| 143 | // |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 144 | // The ModuleProxy passed to the visit function should not be retained outside of the visit function, it may be |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 145 | // invalidated by future mutators. |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 146 | VisitDirectDepsProxyAllowDisabled(visit func(proxy ModuleProxy)) |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 147 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 148 | VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) |
| 149 | |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 150 | VisitDirectDepsProxyWithTag(tag blueprint.DependencyTag, visit func(proxy ModuleProxy)) |
| 151 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 152 | // VisitDirectDepsIf calls pred for each direct dependency, and if pred returns true calls visit. If there are |
| 153 | // multiple direct dependencies on the same module pred and visit will be called multiple times on that module and |
| 154 | // OtherModuleDependencyTag will return a different tag for each. It skips any |
| 155 | // dependencies that are not an android.Module. |
| 156 | // |
| 157 | // The Module passed to the visit function should not be retained outside of the visit function, it may be |
| 158 | // invalidated by future mutators. |
| 159 | VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) |
| 160 | // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module |
| 161 | VisitDepsDepthFirst(visit func(Module)) |
| 162 | // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module |
| 163 | VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) |
| 164 | |
| 165 | // WalkDeps calls visit for each transitive dependency, traversing the dependency tree in top down order. visit may |
| 166 | // be called multiple times for the same (child, parent) pair if there are multiple direct dependencies between the |
| 167 | // child and parent with different tags. OtherModuleDependencyTag will return the tag for the currently visited |
| 168 | // (child, parent) pair. If visit returns false WalkDeps will not continue recursing down to child. It skips |
| 169 | // any dependencies that are not an android.Module. |
| 170 | // |
| 171 | // The Modules passed to the visit function should not be retained outside of the visit function, they may be |
| 172 | // invalidated by future mutators. |
| 173 | WalkDeps(visit func(child, parent Module) bool) |
| 174 | |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 175 | // WalkDeps calls visit for each transitive dependency, traversing the dependency tree in top down order. visit may |
| 176 | // be called multiple times for the same (child, parent) pair if there are multiple direct dependencies between the |
| 177 | // child and parent with different tags. OtherModuleDependencyTag will return the tag for the currently visited |
| 178 | // (child, parent) pair. If visit returns false WalkDeps will not continue recursing down to child. It skips |
| 179 | // any dependencies that are not an android.Module. |
| 180 | // |
| 181 | // The Modules passed to the visit function should not be retained outside of the visit function, they may be |
| 182 | // invalidated by future mutators. |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 183 | WalkDepsProxy(visit func(child, parent ModuleProxy) bool) |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 184 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 185 | // GetWalkPath is supposed to be called in visit function passed in WalkDeps() |
| 186 | // and returns a top-down dependency path from a start module to current child module. |
| 187 | GetWalkPath() []Module |
| 188 | |
| 189 | // PrimaryModule returns the first variant of the current module. Variants of a module are always visited in |
| 190 | // order by mutators and GenerateBuildActions, so the data created by the current mutator can be read from the |
| 191 | // Module returned by PrimaryModule without data races. This can be used to perform singleton actions that are |
| 192 | // only done once for all variants of a module. |
| 193 | PrimaryModule() Module |
| 194 | |
| 195 | // FinalModule returns the last variant of the current module. Variants of a module are always visited in |
| 196 | // order by mutators and GenerateBuildActions, so the data created by the current mutator can be read from all |
| 197 | // variants using VisitAllModuleVariants if the current module == FinalModule(). This can be used to perform |
| 198 | // singleton actions that are only done once for all variants of a module. |
| 199 | FinalModule() Module |
| 200 | |
Yu Liu | 88ea9ff | 2024-11-07 19:19:42 +0000 | [diff] [blame] | 201 | // IsFinalModule returns if the current module is the last variant. Variants of a module are always visited in |
| 202 | // order by mutators and GenerateBuildActions, so the data created by the current mutator can be read from all |
| 203 | // variants using VisitAllModuleVariants if the current module is the last one. This can be used to perform |
| 204 | // singleton actions that are only done once for all variants of a module. |
| 205 | IsFinalModule(module Module) bool |
| 206 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 207 | // VisitAllModuleVariants calls visit for each variant of the current module. Variants of a module are always |
| 208 | // visited in order by mutators and GenerateBuildActions, so the data created by the current mutator can be read |
Yu Liu | 88ea9ff | 2024-11-07 19:19:42 +0000 | [diff] [blame] | 209 | // from all variants if the current module is the last one. Otherwise, care must be taken to not access any |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 210 | // data modified by the current mutator. |
| 211 | VisitAllModuleVariants(visit func(Module)) |
| 212 | |
Yu Liu | b527532 | 2024-11-13 18:40:43 +0000 | [diff] [blame] | 213 | // VisitAllModuleVariantProxies calls visit for each variant of the current module. Variants of a module are always |
| 214 | // visited in order by mutators and GenerateBuildActions, so the data created by the current mutator can be read |
| 215 | // from all variants if the current module is the last one. Otherwise, care must be taken to not access any |
| 216 | // data modified by the current mutator. |
| 217 | VisitAllModuleVariantProxies(visit func(proxy ModuleProxy)) |
| 218 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 219 | // GetTagPath is supposed to be called in visit function passed in WalkDeps() |
| 220 | // and returns a top-down dependency tags path from a start module to current child module. |
| 221 | // It has one less entry than GetWalkPath() as it contains the dependency tags that |
| 222 | // exist between each adjacent pair of modules in the GetWalkPath(). |
| 223 | // GetTagPath()[i] is the tag between GetWalkPath()[i] and GetWalkPath()[i+1] |
| 224 | GetTagPath() []blueprint.DependencyTag |
| 225 | |
| 226 | // GetPathString is supposed to be called in visit function passed in WalkDeps() |
| 227 | // and returns a multi-line string showing the modules and dependency tags |
| 228 | // among them along the top-down dependency path from a start module to current child module. |
| 229 | // skipFirst when set to true, the output doesn't include the start module, |
| 230 | // which is already printed when this function is used along with ModuleErrorf(). |
| 231 | GetPathString(skipFirst bool) string |
| 232 | |
| 233 | AddMissingDependencies(missingDeps []string) |
| 234 | |
| 235 | // getMissingDependencies returns the list of missing dependencies. |
| 236 | // Calling this function prevents adding new dependencies. |
| 237 | getMissingDependencies() []string |
Cole Faust | bdd8aee | 2024-03-14 14:33:02 -0700 | [diff] [blame] | 238 | |
| 239 | // EvaluateConfiguration makes ModuleContext a valid proptools.ConfigurableEvaluator, so this context |
| 240 | // can be used to evaluate the final value of Configurable properties. |
Cole Faust | fdbf5d4 | 2024-04-10 15:01:23 -0700 | [diff] [blame] | 241 | EvaluateConfiguration(condition proptools.ConfigurableCondition, property string) proptools.ConfigurableValue |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | type baseModuleContext struct { |
| 245 | bp blueprint.BaseModuleContext |
| 246 | earlyModuleContext |
Colin Cross | 1d3d9f1 | 2024-01-18 14:30:22 -0800 | [diff] [blame] | 247 | archModuleContext |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 248 | |
| 249 | walkPath []Module |
| 250 | tagPath []blueprint.DependencyTag |
| 251 | |
| 252 | strictVisitDeps bool // If true, enforce that all dependencies are enabled |
| 253 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 254 | } |
| 255 | |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 256 | func getWrappedModule(module blueprint.Module) blueprint.Module { |
Cole Faust | 19eb09d | 2025-01-14 13:27:00 -0800 | [diff] [blame] | 257 | if mp, isProxy := module.(*ModuleProxy); isProxy { |
| 258 | return mp.module |
| 259 | } |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 260 | if mp, isProxy := module.(ModuleProxy); isProxy { |
| 261 | return mp.module |
| 262 | } |
| 263 | return module |
| 264 | } |
| 265 | |
| 266 | func (b *baseModuleContext) EqualModules(m1, m2 Module) bool { |
| 267 | return b.bp.EqualModules(getWrappedModule(m1), getWrappedModule(m2)) |
| 268 | } |
| 269 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 270 | func (b *baseModuleContext) OtherModuleName(m blueprint.Module) string { |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 271 | return b.bp.OtherModuleName(getWrappedModule(m)) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 272 | } |
Yu Liu | d3228ac | 2024-11-08 23:11:47 +0000 | [diff] [blame] | 273 | func (b *baseModuleContext) OtherModuleDir(m blueprint.Module) string { |
| 274 | return b.bp.OtherModuleDir(getWrappedModule(m)) |
| 275 | } |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 276 | func (b *baseModuleContext) OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) { |
Yu Liu | ac483e0 | 2024-11-11 22:29:30 +0000 | [diff] [blame] | 277 | b.bp.OtherModuleErrorf(getWrappedModule(m), fmt, args...) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 278 | } |
| 279 | func (b *baseModuleContext) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag { |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 280 | return b.bp.OtherModuleDependencyTag(getWrappedModule(m)) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 281 | } |
| 282 | func (b *baseModuleContext) OtherModuleExists(name string) bool { return b.bp.OtherModuleExists(name) } |
| 283 | func (b *baseModuleContext) OtherModuleDependencyVariantExists(variations []blueprint.Variation, name string) bool { |
| 284 | return b.bp.OtherModuleDependencyVariantExists(variations, name) |
| 285 | } |
| 286 | func (b *baseModuleContext) OtherModuleFarDependencyVariantExists(variations []blueprint.Variation, name string) bool { |
| 287 | return b.bp.OtherModuleFarDependencyVariantExists(variations, name) |
| 288 | } |
| 289 | func (b *baseModuleContext) OtherModuleReverseDependencyVariantExists(name string) bool { |
| 290 | return b.bp.OtherModuleReverseDependencyVariantExists(name) |
| 291 | } |
| 292 | func (b *baseModuleContext) OtherModuleType(m blueprint.Module) string { |
Yu Liu | b1bfa9d | 2024-12-05 18:57:51 +0000 | [diff] [blame] | 293 | return b.bp.OtherModuleType(getWrappedModule(m)) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 294 | } |
Colin Cross | 3c0a83d | 2023-12-12 14:13:26 -0800 | [diff] [blame] | 295 | |
| 296 | func (b *baseModuleContext) otherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) { |
Cole Faust | 19eb09d | 2025-01-14 13:27:00 -0800 | [diff] [blame] | 297 | return b.bp.OtherModuleProvider(getWrappedModule(m), provider) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 298 | } |
Colin Cross | 3c0a83d | 2023-12-12 14:13:26 -0800 | [diff] [blame] | 299 | |
Jihoon Kang | 2a7bf75 | 2024-11-01 21:21:25 +0000 | [diff] [blame] | 300 | func (b *baseModuleContext) OtherModuleIsAutoGenerated(m blueprint.Module) bool { |
| 301 | return b.bp.OtherModuleIsAutoGenerated(m) |
| 302 | } |
| 303 | |
Colin Cross | 3c0a83d | 2023-12-12 14:13:26 -0800 | [diff] [blame] | 304 | func (b *baseModuleContext) provider(provider blueprint.AnyProviderKey) (any, bool) { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 305 | return b.bp.Provider(provider) |
| 306 | } |
Colin Cross | 3c0a83d | 2023-12-12 14:13:26 -0800 | [diff] [blame] | 307 | |
Colin Cross | 24c1cbe | 2023-12-21 23:42:56 +0000 | [diff] [blame] | 308 | func (b *baseModuleContext) setProvider(provider blueprint.AnyProviderKey, value any) { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 309 | b.bp.SetProvider(provider, value) |
| 310 | } |
| 311 | |
Yu Liu | d3228ac | 2024-11-08 23:11:47 +0000 | [diff] [blame] | 312 | func (b *baseModuleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) Module { |
| 313 | if module := b.bp.GetDirectDepWithTag(name, tag); module != nil { |
| 314 | return module.(Module) |
| 315 | } |
| 316 | return nil |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 317 | } |
| 318 | |
Yu Liu | 3ae9665 | 2024-12-17 22:27:38 +0000 | [diff] [blame] | 319 | func (b *baseModuleContext) GetDirectDepProxyWithTag(name string, tag blueprint.DependencyTag) *ModuleProxy { |
| 320 | if module := b.bp.GetDirectDepProxyWithTag(name, tag); module != nil { |
| 321 | return &ModuleProxy{*module} |
| 322 | } |
| 323 | return nil |
| 324 | } |
| 325 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 326 | func (b *baseModuleContext) blueprintBaseModuleContext() blueprint.BaseModuleContext { |
| 327 | return b.bp |
| 328 | } |
| 329 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 330 | func (b *baseModuleContext) AddMissingDependencies(deps []string) { |
| 331 | if deps != nil { |
| 332 | missingDeps := &b.Module().base().commonProperties.MissingDeps |
| 333 | *missingDeps = append(*missingDeps, deps...) |
| 334 | *missingDeps = FirstUniqueStrings(*missingDeps) |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | func (b *baseModuleContext) checkedMissingDeps() bool { |
| 339 | return b.Module().base().commonProperties.CheckedMissingDeps |
| 340 | } |
| 341 | |
| 342 | func (b *baseModuleContext) getMissingDependencies() []string { |
| 343 | checked := &b.Module().base().commonProperties.CheckedMissingDeps |
| 344 | *checked = true |
| 345 | var missingDeps []string |
| 346 | missingDeps = append(missingDeps, b.Module().base().commonProperties.MissingDeps...) |
| 347 | missingDeps = append(missingDeps, b.bp.EarlyGetMissingDependencies()...) |
| 348 | missingDeps = FirstUniqueStrings(missingDeps) |
| 349 | return missingDeps |
| 350 | } |
| 351 | |
| 352 | type AllowDisabledModuleDependency interface { |
| 353 | blueprint.DependencyTag |
| 354 | AllowDisabledModuleDependency(target Module) bool |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 355 | AllowDisabledModuleDependencyProxy(ctx OtherModuleProviderContext, target ModuleProxy) bool |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 356 | } |
| 357 | |
Jiyong Park | 8bcf3c6 | 2024-03-18 18:37:10 +0900 | [diff] [blame] | 358 | type AlwaysAllowDisabledModuleDependencyTag struct{} |
| 359 | |
| 360 | func (t AlwaysAllowDisabledModuleDependencyTag) AllowDisabledModuleDependency(Module) bool { |
| 361 | return true |
| 362 | } |
| 363 | |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 364 | func (t AlwaysAllowDisabledModuleDependencyTag) AllowDisabledModuleDependencyProxy(OtherModuleProviderContext, ModuleProxy) bool { |
| 365 | return true |
| 366 | } |
| 367 | |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 368 | func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag blueprint.DependencyTag, strict bool) Module { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 369 | aModule, _ := module.(Module) |
| 370 | |
| 371 | if !strict { |
| 372 | return aModule |
| 373 | } |
| 374 | |
| 375 | if aModule == nil { |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 376 | panic(fmt.Errorf("module %q (%#v) not an android module", b.OtherModuleName(module), tag)) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 377 | } |
| 378 | |
Cole Faust | a963b94 | 2024-04-11 17:43:00 -0700 | [diff] [blame] | 379 | if !aModule.Enabled(b) { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 380 | if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependency(aModule) { |
| 381 | if b.Config().AllowMissingDependencies() { |
| 382 | b.AddMissingDependencies([]string{b.OtherModuleName(aModule)}) |
| 383 | } else { |
| 384 | b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule)) |
| 385 | } |
| 386 | } |
| 387 | return nil |
| 388 | } |
| 389 | return aModule |
| 390 | } |
| 391 | |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 392 | func (b *baseModuleContext) validateAndroidModuleProxy( |
| 393 | module blueprint.ModuleProxy, tag blueprint.DependencyTag, strict bool) *ModuleProxy { |
| 394 | aModule := ModuleProxy{module: module} |
| 395 | |
| 396 | if !strict { |
| 397 | return &aModule |
| 398 | } |
| 399 | |
Yu Liu | b527532 | 2024-11-13 18:40:43 +0000 | [diff] [blame] | 400 | if !OtherModuleProviderOrDefault(b, module, CommonModuleInfoKey).Enabled { |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 401 | if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependencyProxy(b, aModule) { |
| 402 | if b.Config().AllowMissingDependencies() { |
| 403 | b.AddMissingDependencies([]string{b.OtherModuleName(aModule)}) |
| 404 | } else { |
| 405 | b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule)) |
| 406 | } |
| 407 | } |
| 408 | return nil |
| 409 | } |
| 410 | |
| 411 | return &aModule |
| 412 | } |
| 413 | |
Yu Liu | 3ae9665 | 2024-12-17 22:27:38 +0000 | [diff] [blame] | 414 | func (b *baseModuleContext) getDirectDepsInternal(name string, tag blueprint.DependencyTag) []Module { |
| 415 | var deps []Module |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 416 | b.VisitDirectDeps(func(module Module) { |
| 417 | if module.base().BaseModuleName() == name { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 418 | returnedTag := b.bp.OtherModuleDependencyTag(module) |
| 419 | if tag == nil || returnedTag == tag { |
Yu Liu | 3ae9665 | 2024-12-17 22:27:38 +0000 | [diff] [blame] | 420 | deps = append(deps, module) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 421 | } |
| 422 | } |
| 423 | }) |
| 424 | return deps |
| 425 | } |
| 426 | |
Yu Liu | 3ae9665 | 2024-12-17 22:27:38 +0000 | [diff] [blame] | 427 | func (b *baseModuleContext) getDirectDepsProxyInternal(name string, tag blueprint.DependencyTag) []ModuleProxy { |
| 428 | var deps []ModuleProxy |
| 429 | b.VisitDirectDepsProxy(func(module ModuleProxy) { |
| 430 | if OtherModuleProviderOrDefault(b, module, CommonModuleInfoKey).BaseModuleName == name { |
| 431 | returnedTag := b.OtherModuleDependencyTag(module) |
| 432 | if tag == nil || returnedTag == tag { |
| 433 | deps = append(deps, module) |
| 434 | } |
| 435 | } |
| 436 | }) |
| 437 | return deps |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 438 | } |
| 439 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 440 | func (b *baseModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module { |
| 441 | var deps []Module |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 442 | b.VisitDirectDeps(func(module Module) { |
| 443 | if b.bp.OtherModuleDependencyTag(module) == tag { |
| 444 | deps = append(deps, module) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 445 | } |
| 446 | }) |
| 447 | return deps |
| 448 | } |
| 449 | |
Yu Liu | f432c2e | 2024-12-17 00:09:15 +0000 | [diff] [blame] | 450 | func (b *baseModuleContext) GetDirectDepsProxyWithTag(tag blueprint.DependencyTag) []ModuleProxy { |
| 451 | var deps []ModuleProxy |
| 452 | b.VisitDirectDepsProxy(func(module ModuleProxy) { |
| 453 | if b.OtherModuleDependencyTag(module) == tag { |
| 454 | deps = append(deps, module) |
| 455 | } |
| 456 | }) |
| 457 | return deps |
| 458 | } |
| 459 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 460 | func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) { |
| 461 | b.bp.VisitDirectDeps(func(module blueprint.Module) { |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 462 | if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 463 | visit(aModule) |
| 464 | } |
| 465 | }) |
| 466 | } |
| 467 | |
Yu Liu | d3228ac | 2024-11-08 23:11:47 +0000 | [diff] [blame] | 468 | func (b *baseModuleContext) VisitDirectDepsProxy(visit func(ModuleProxy)) { |
| 469 | b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) { |
| 470 | if aModule := b.validateAndroidModuleProxy(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil { |
| 471 | visit(*aModule) |
| 472 | } |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 473 | }) |
| 474 | } |
| 475 | |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 476 | func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy ModuleProxy)) { |
Yu Liu | d3228ac | 2024-11-08 23:11:47 +0000 | [diff] [blame] | 477 | b.bp.VisitDirectDepsProxy(visitProxyAdaptor(visit)) |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 478 | } |
| 479 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 480 | func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) { |
| 481 | b.bp.VisitDirectDeps(func(module blueprint.Module) { |
| 482 | if b.bp.OtherModuleDependencyTag(module) == tag { |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 483 | if aModule := b.validateAndroidModule(module, tag, b.strictVisitDeps); aModule != nil { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 484 | visit(aModule) |
| 485 | } |
| 486 | } |
| 487 | }) |
| 488 | } |
| 489 | |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 490 | func (b *baseModuleContext) VisitDirectDepsProxyWithTag(tag blueprint.DependencyTag, visit func(proxy ModuleProxy)) { |
| 491 | b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) { |
| 492 | if b.bp.OtherModuleDependencyTag(module) == tag { |
| 493 | if aModule := b.validateAndroidModuleProxy(module, tag, b.strictVisitDeps); aModule != nil { |
| 494 | visit(*aModule) |
| 495 | } |
| 496 | } |
| 497 | }) |
| 498 | } |
| 499 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 500 | func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) { |
| 501 | b.bp.VisitDirectDepsIf( |
| 502 | // pred |
| 503 | func(module blueprint.Module) bool { |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 504 | if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 505 | return pred(aModule) |
| 506 | } else { |
| 507 | return false |
| 508 | } |
| 509 | }, |
| 510 | // visit |
| 511 | func(module blueprint.Module) { |
| 512 | visit(module.(Module)) |
| 513 | }) |
| 514 | } |
| 515 | |
| 516 | func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) { |
| 517 | b.bp.VisitDepsDepthFirst(func(module blueprint.Module) { |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 518 | if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 519 | visit(aModule) |
| 520 | } |
| 521 | }) |
| 522 | } |
| 523 | |
| 524 | func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) { |
| 525 | b.bp.VisitDepsDepthFirstIf( |
| 526 | // pred |
| 527 | func(module blueprint.Module) bool { |
Colin Cross | 648daea | 2024-09-12 14:35:29 -0700 | [diff] [blame] | 528 | if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 529 | return pred(aModule) |
| 530 | } else { |
| 531 | return false |
| 532 | } |
| 533 | }, |
| 534 | // visit |
| 535 | func(module blueprint.Module) { |
| 536 | visit(module.(Module)) |
| 537 | }) |
| 538 | } |
| 539 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 540 | func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) { |
| 541 | b.walkPath = []Module{b.Module()} |
| 542 | b.tagPath = []blueprint.DependencyTag{} |
| 543 | b.bp.WalkDeps(func(child, parent blueprint.Module) bool { |
| 544 | childAndroidModule, _ := child.(Module) |
| 545 | parentAndroidModule, _ := parent.(Module) |
| 546 | if childAndroidModule != nil && parentAndroidModule != nil { |
| 547 | // record walkPath before visit |
| 548 | for b.walkPath[len(b.walkPath)-1] != parentAndroidModule { |
| 549 | b.walkPath = b.walkPath[0 : len(b.walkPath)-1] |
| 550 | b.tagPath = b.tagPath[0 : len(b.tagPath)-1] |
| 551 | } |
| 552 | b.walkPath = append(b.walkPath, childAndroidModule) |
| 553 | b.tagPath = append(b.tagPath, b.OtherModuleDependencyTag(childAndroidModule)) |
| 554 | return visit(childAndroidModule, parentAndroidModule) |
| 555 | } else { |
| 556 | return false |
| 557 | } |
| 558 | }) |
| 559 | } |
| 560 | |
Yu Liu | d2a9595 | 2024-10-10 00:15:26 +0000 | [diff] [blame] | 561 | func (b *baseModuleContext) WalkDepsProxy(visit func(ModuleProxy, ModuleProxy) bool) { |
Yu Liu | dd9ccb4 | 2024-10-07 17:07:44 +0000 | [diff] [blame] | 562 | b.walkPath = []Module{ModuleProxy{blueprint.CreateModuleProxy(b.Module())}} |
| 563 | b.tagPath = []blueprint.DependencyTag{} |
| 564 | b.bp.WalkDepsProxy(func(child, parent blueprint.ModuleProxy) bool { |
| 565 | childAndroidModule := ModuleProxy{child} |
| 566 | parentAndroidModule := ModuleProxy{parent} |
| 567 | // record walkPath before visit |
| 568 | for b.walkPath[len(b.walkPath)-1] != parentAndroidModule { |
| 569 | b.walkPath = b.walkPath[0 : len(b.walkPath)-1] |
| 570 | b.tagPath = b.tagPath[0 : len(b.tagPath)-1] |
| 571 | } |
| 572 | b.walkPath = append(b.walkPath, childAndroidModule) |
| 573 | b.tagPath = append(b.tagPath, b.OtherModuleDependencyTag(childAndroidModule)) |
| 574 | return visit(childAndroidModule, parentAndroidModule) |
| 575 | }) |
| 576 | } |
| 577 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 578 | func (b *baseModuleContext) GetWalkPath() []Module { |
Colin Cross | b614cd4 | 2024-10-11 12:52:21 -0700 | [diff] [blame] | 579 | return slices.Clone(b.walkPath) |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | func (b *baseModuleContext) GetTagPath() []blueprint.DependencyTag { |
| 583 | return b.tagPath |
| 584 | } |
| 585 | |
| 586 | func (b *baseModuleContext) VisitAllModuleVariants(visit func(Module)) { |
| 587 | b.bp.VisitAllModuleVariants(func(module blueprint.Module) { |
| 588 | visit(module.(Module)) |
| 589 | }) |
| 590 | } |
| 591 | |
Yu Liu | b527532 | 2024-11-13 18:40:43 +0000 | [diff] [blame] | 592 | func (b *baseModuleContext) VisitAllModuleVariantProxies(visit func(ModuleProxy)) { |
| 593 | b.bp.VisitAllModuleVariantProxies(visitProxyAdaptor(visit)) |
| 594 | } |
| 595 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 596 | func (b *baseModuleContext) PrimaryModule() Module { |
| 597 | return b.bp.PrimaryModule().(Module) |
| 598 | } |
| 599 | |
| 600 | func (b *baseModuleContext) FinalModule() Module { |
| 601 | return b.bp.FinalModule().(Module) |
| 602 | } |
| 603 | |
Yu Liu | 88ea9ff | 2024-11-07 19:19:42 +0000 | [diff] [blame] | 604 | func (b *baseModuleContext) IsFinalModule(module Module) bool { |
| 605 | return b.bp.IsFinalModule(module) |
| 606 | } |
| 607 | |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 608 | // IsMetaDependencyTag returns true for cross-cutting metadata dependencies. |
| 609 | func IsMetaDependencyTag(tag blueprint.DependencyTag) bool { |
| 610 | if tag == licenseKindTag { |
| 611 | return true |
| 612 | } else if tag == licensesTag { |
| 613 | return true |
Jihoon Kang | a3a0546 | 2024-04-05 00:36:44 +0000 | [diff] [blame] | 614 | } else if tag == AcDepTag { |
Colin Cross | 69452e1 | 2023-11-15 11:20:53 -0800 | [diff] [blame] | 615 | return true |
| 616 | } |
| 617 | return false |
| 618 | } |
| 619 | |
| 620 | // A regexp for removing boilerplate from BaseDependencyTag from the string representation of |
| 621 | // a dependency tag. |
| 622 | var tagCleaner = regexp.MustCompile(`\QBaseDependencyTag:{}\E(, )?`) |
| 623 | |
| 624 | // PrettyPrintTag returns string representation of the tag, but prefers |
| 625 | // custom String() method if available. |
| 626 | func PrettyPrintTag(tag blueprint.DependencyTag) string { |
| 627 | // Use tag's custom String() method if available. |
| 628 | if stringer, ok := tag.(fmt.Stringer); ok { |
| 629 | return stringer.String() |
| 630 | } |
| 631 | |
| 632 | // Otherwise, get a default string representation of the tag's struct. |
| 633 | tagString := fmt.Sprintf("%T: %+v", tag, tag) |
| 634 | |
| 635 | // Remove the boilerplate from BaseDependencyTag as it adds no value. |
| 636 | tagString = tagCleaner.ReplaceAllString(tagString, "") |
| 637 | return tagString |
| 638 | } |
| 639 | |
| 640 | func (b *baseModuleContext) GetPathString(skipFirst bool) string { |
| 641 | sb := strings.Builder{} |
| 642 | tagPath := b.GetTagPath() |
| 643 | walkPath := b.GetWalkPath() |
| 644 | if !skipFirst { |
| 645 | sb.WriteString(walkPath[0].String()) |
| 646 | } |
| 647 | for i, m := range walkPath[1:] { |
| 648 | sb.WriteString("\n") |
| 649 | sb.WriteString(fmt.Sprintf(" via tag %s\n", PrettyPrintTag(tagPath[i]))) |
| 650 | sb.WriteString(fmt.Sprintf(" -> %s", m.String())) |
| 651 | } |
| 652 | return sb.String() |
| 653 | } |
Cole Faust | bdd8aee | 2024-03-14 14:33:02 -0700 | [diff] [blame] | 654 | |
Cole Faust | fdbf5d4 | 2024-04-10 15:01:23 -0700 | [diff] [blame] | 655 | func (m *baseModuleContext) EvaluateConfiguration(condition proptools.ConfigurableCondition, property string) proptools.ConfigurableValue { |
| 656 | return m.Module().ConfigurableEvaluator(m).EvaluateConfiguration(condition, property) |
Cole Faust | bdd8aee | 2024-03-14 14:33:02 -0700 | [diff] [blame] | 657 | } |