jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 1 | // Copyright 2020 The Bazel Authors. 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 | package com.google.devtools.build.lib.skyframe; |
| 15 | |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 16 | import com.google.common.base.Objects; |
| 17 | import com.google.common.collect.ImmutableList; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 18 | import com.google.common.collect.Interner; |
jhorvitz | 3daedc3 | 2020-07-22 18:33:55 -0700 | [diff] [blame] | 19 | import com.google.devtools.build.lib.actions.ActionLookupKey; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 20 | import com.google.devtools.build.lib.analysis.config.BuildConfiguration; |
| 21 | import com.google.devtools.build.lib.cmdline.Label; |
| 22 | import com.google.devtools.build.lib.concurrent.BlazeInterners; |
| 23 | import com.google.devtools.build.lib.packages.AspectClass; |
| 24 | import com.google.devtools.build.lib.packages.AspectDescriptor; |
| 25 | import com.google.devtools.build.lib.packages.AspectParameters; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 26 | import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; |
| 27 | import com.google.devtools.build.skyframe.SkyFunctionName; |
| 28 | import javax.annotation.Nullable; |
| 29 | |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 30 | /** A wrapper class for sky keys needed to compute sky values for aspects. */ |
| 31 | public final class AspectValueKey { |
| 32 | |
| 33 | private AspectValueKey() {} |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 34 | |
| 35 | private static final Interner<AspectKey> aspectKeyInterner = BlazeInterners.newWeakInterner(); |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 36 | private static final Interner<TopLevelAspectsKey> topLevelAspectsKeyInterner = |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 37 | BlazeInterners.newWeakInterner(); |
| 38 | |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 39 | public static AspectKey createAspectKey( |
| 40 | Label label, |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 41 | @Nullable BuildConfiguration baseConfiguration, |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 42 | ImmutableList<AspectKey> baseKeys, |
| 43 | AspectDescriptor aspectDescriptor, |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 44 | @Nullable BuildConfiguration aspectConfiguration) { |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 45 | return AspectKey.createAspectKey( |
jcater | 83221e3 | 2020-05-28 11:37:39 -0700 | [diff] [blame] | 46 | ConfiguredTargetKey.builder().setLabel(label).setConfiguration(baseConfiguration).build(), |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 47 | baseKeys, |
| 48 | aspectDescriptor, |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 49 | aspectConfiguration == null ? null : BuildConfigurationValue.key(aspectConfiguration)); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | public static AspectKey createAspectKey( |
messa | 943c83a | 2021-06-28 07:54:28 -0700 | [diff] [blame] | 53 | AspectDescriptor aspectDescriptor, |
| 54 | ImmutableList<AspectKey> baseKeys, |
| 55 | BuildConfigurationValue.Key aspectConfigurationKey, |
| 56 | ConfiguredTargetKey baseConfiguredTargetKey) { |
| 57 | return AspectKey.createAspectKey( |
| 58 | baseConfiguredTargetKey, baseKeys, aspectDescriptor, aspectConfigurationKey); |
| 59 | } |
| 60 | |
| 61 | public static AspectKey createAspectKey( |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 62 | Label label, |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 63 | @Nullable BuildConfiguration baseConfiguration, |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 64 | AspectDescriptor aspectDescriptor, |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 65 | @Nullable BuildConfiguration aspectConfiguration) { |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 66 | return AspectKey.createAspectKey( |
jcater | 83221e3 | 2020-05-28 11:37:39 -0700 | [diff] [blame] | 67 | ConfiguredTargetKey.builder().setLabel(label).setConfiguration(baseConfiguration).build(), |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 68 | ImmutableList.of(), |
| 69 | aspectDescriptor, |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 70 | aspectConfiguration == null ? null : BuildConfigurationValue.key(aspectConfiguration)); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 71 | } |
| 72 | |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 73 | public static TopLevelAspectsKey createTopLevelAspectsKey( |
| 74 | ImmutableList<AspectClass> topLevelAspectsClasses, |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 75 | Label targetLabel, |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 76 | @Nullable BuildConfiguration configuration) { |
| 77 | return TopLevelAspectsKey.createInternal( |
| 78 | topLevelAspectsClasses, |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 79 | targetLabel, |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 80 | ConfiguredTargetKey.builder() |
| 81 | .setLabel(targetLabel) |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 82 | .setConfiguration(configuration) |
| 83 | .build()); |
| 84 | } |
| 85 | |
| 86 | /** Common superclass for {@link AspectKey} and {@link TopLevelAspectsKey}. */ |
| 87 | public abstract static class AspectBaseKey implements ActionLookupKey { |
| 88 | private final ConfiguredTargetKey baseConfiguredTargetKey; |
| 89 | private final int hashCode; |
| 90 | |
| 91 | private AspectBaseKey(ConfiguredTargetKey baseConfiguredTargetKey, int hashCode) { |
| 92 | this.baseConfiguredTargetKey = baseConfiguredTargetKey; |
| 93 | this.hashCode = hashCode; |
| 94 | } |
| 95 | |
| 96 | /** Returns the key for the base configured target for this aspect. */ |
| 97 | public final ConfiguredTargetKey getBaseConfiguredTargetKey() { |
| 98 | return baseConfiguredTargetKey; |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public final int hashCode() { |
| 103 | return hashCode; |
| 104 | } |
janakr | 13b737a | 2021-07-02 14:24:25 -0700 | [diff] [blame] | 105 | } |
| 106 | |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 107 | // Specific subtypes of aspect keys. |
| 108 | |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 109 | /** Represents an aspect applied to a particular target. */ |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 110 | @AutoCodec |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 111 | public static final class AspectKey extends AspectBaseKey { |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 112 | private final ImmutableList<AspectKey> baseKeys; |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 113 | @Nullable private final BuildConfigurationValue.Key aspectConfigurationKey; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 114 | private final AspectDescriptor aspectDescriptor; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 115 | |
| 116 | private AspectKey( |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 117 | ConfiguredTargetKey baseConfiguredTargetKey, |
| 118 | ImmutableList<AspectKey> baseKeys, |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 119 | AspectDescriptor aspectDescriptor, |
| 120 | @Nullable BuildConfigurationValue.Key aspectConfigurationKey, |
| 121 | int hashCode) { |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 122 | super(baseConfiguredTargetKey, hashCode); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 123 | this.baseKeys = baseKeys; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 124 | this.aspectConfigurationKey = aspectConfigurationKey; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 125 | this.aspectDescriptor = aspectDescriptor; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | @AutoCodec.VisibleForSerialization |
| 129 | @AutoCodec.Instantiator |
| 130 | static AspectKey createAspectKey( |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 131 | ConfiguredTargetKey baseConfiguredTargetKey, |
| 132 | ImmutableList<AspectKey> baseKeys, |
| 133 | AspectDescriptor aspectDescriptor, |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 134 | @Nullable BuildConfigurationValue.Key aspectConfigurationKey) { |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 135 | return aspectKeyInterner.intern( |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 136 | new AspectKey( |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 137 | baseConfiguredTargetKey, |
| 138 | baseKeys, |
| 139 | aspectDescriptor, |
| 140 | aspectConfigurationKey, |
| 141 | Objects.hashCode( |
| 142 | baseConfiguredTargetKey, baseKeys, aspectDescriptor, aspectConfigurationKey))); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | @Override |
| 146 | public SkyFunctionName functionName() { |
| 147 | return SkyFunctions.ASPECT; |
| 148 | } |
| 149 | |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 150 | /** |
| 151 | * Gets the name of the aspect that would be returned by the corresponding value's {@code |
| 152 | * aspectValue.getAspect().getAspectClass().getName()}, if the value could be produced. |
| 153 | * |
| 154 | * <p>Only needed for reporting errors in BEP when the key's AspectValue fails evaluation. |
| 155 | */ |
adgar | 2487920 | 2021-04-12 09:21:20 -0700 | [diff] [blame] | 156 | public String getAspectName() { |
| 157 | return aspectDescriptor.getDescription(); |
| 158 | } |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 159 | |
| 160 | @Override |
| 161 | public Label getLabel() { |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 162 | return getBaseConfiguredTargetKey().getLabel(); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | public AspectClass getAspectClass() { |
| 166 | return aspectDescriptor.getAspectClass(); |
| 167 | } |
| 168 | |
| 169 | @Nullable |
| 170 | public AspectParameters getParameters() { |
| 171 | return aspectDescriptor.getParameters(); |
| 172 | } |
| 173 | |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 174 | public AspectDescriptor getAspectDescriptor() { |
| 175 | return aspectDescriptor; |
| 176 | } |
| 177 | |
| 178 | @Nullable |
jhorvitz | 5d34957 | 2021-09-21 09:34:12 -0700 | [diff] [blame^] | 179 | public ImmutableList<AspectKey> getBaseKeys() { |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 180 | return baseKeys; |
| 181 | } |
| 182 | |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 183 | public String getDescription() { |
| 184 | if (baseKeys.isEmpty()) { |
messa | 7649f61 | 2021-07-27 01:19:27 -0700 | [diff] [blame] | 185 | return String.format("%s of %s", aspectDescriptor.getAspectClass().getName(), getLabel()); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 186 | } else { |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 187 | return String.format( |
| 188 | "%s on top of %s", aspectDescriptor.getAspectClass().getName(), baseKeys); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 192 | /** |
| 193 | * Returns the key of the configured target of the aspect; that is, the configuration in which |
| 194 | * the aspect will be evaluated. |
| 195 | * |
| 196 | * <p>In trimmed configuration mode, the aspect may require more fragments than the target on |
| 197 | * which it is being evaluated; in addition to configuration fragments required by the target |
| 198 | * and its dependencies, an aspect has configuration fragment requirements of its own, as well |
| 199 | * as dependencies of its own with their own configuration fragment requirements. |
| 200 | * |
| 201 | * <p>The aspect configuration contains all of these fragments, and is used to create the |
| 202 | * aspect's RuleContext and to retrieve the dependencies. Note that dependencies will have their |
| 203 | * configurations trimmed from this one as normal. |
| 204 | * |
| 205 | * <p>Because of these properties, this configuration is always a superset of the base target's |
| 206 | * configuration. In untrimmed configuration mode, this configuration will be equivalent to the |
| 207 | * base target's configuration. |
| 208 | */ |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 209 | @Nullable |
jhorvitz | c650978 | 2021-08-23 15:43:24 -0700 | [diff] [blame] | 210 | public BuildConfigurationValue.Key getAspectConfigurationKey() { |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 211 | return aspectConfigurationKey; |
| 212 | } |
| 213 | |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 214 | @Override |
| 215 | public boolean equals(Object other) { |
| 216 | if (this == other) { |
| 217 | return true; |
| 218 | } |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 219 | if (!(other instanceof AspectKey)) { |
| 220 | return false; |
| 221 | } |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 222 | AspectKey that = (AspectKey) other; |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 223 | return hashCode() == that.hashCode() |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 224 | && Objects.equal(baseKeys, that.baseKeys) |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 225 | && Objects.equal(aspectConfigurationKey, that.aspectConfigurationKey) |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 226 | && Objects.equal(getBaseConfiguredTargetKey(), that.getBaseConfiguredTargetKey()) |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 227 | && Objects.equal(aspectDescriptor, that.aspectDescriptor); |
| 228 | } |
| 229 | |
| 230 | public String prettyPrint() { |
janakr | f15d08d | 2020-04-22 12:53:03 -0700 | [diff] [blame] | 231 | if (getLabel() == null) { |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 232 | return "null"; |
| 233 | } |
| 234 | |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 235 | String baseKeysString = baseKeys.isEmpty() ? "" : String.format(" (over %s)", baseKeys); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 236 | return String.format( |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 237 | "%s with aspect %s%s", |
| 238 | getLabel(), aspectDescriptor.getAspectClass().getName(), baseKeysString); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | @Override |
| 242 | public String toString() { |
janakr | f15d08d | 2020-04-22 12:53:03 -0700 | [diff] [blame] | 243 | return (baseKeys == null ? getLabel() : baseKeys.toString()) |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 244 | + "#" |
| 245 | + aspectDescriptor |
| 246 | + " " |
| 247 | + aspectConfigurationKey |
| 248 | + " " |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 249 | + getBaseConfiguredTargetKey() |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 250 | + " " |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 251 | + aspectDescriptor.getParameters(); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | AspectKey withLabel(Label label) { |
| 255 | ImmutableList.Builder<AspectKey> newBaseKeys = ImmutableList.builder(); |
| 256 | for (AspectKey baseKey : baseKeys) { |
| 257 | newBaseKeys.add(baseKey.withLabel(label)); |
| 258 | } |
| 259 | |
| 260 | return createAspectKey( |
jcater | 3eb2d25 | 2020-05-28 10:39:12 -0700 | [diff] [blame] | 261 | ConfiguredTargetKey.builder() |
| 262 | .setLabel(label) |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 263 | .setConfigurationKey(getBaseConfiguredTargetKey().getConfigurationKey()) |
jcater | 3eb2d25 | 2020-05-28 10:39:12 -0700 | [diff] [blame] | 264 | .build(), |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 265 | newBaseKeys.build(), |
| 266 | aspectDescriptor, |
jcater | 02054bb | 2020-05-28 09:49:38 -0700 | [diff] [blame] | 267 | aspectConfigurationKey); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 271 | /** The key for top level aspects specified by --aspects option on a top level target. */ |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 272 | @AutoCodec |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 273 | public static final class TopLevelAspectsKey extends AspectBaseKey { |
| 274 | private final ImmutableList<AspectClass> topLevelAspectsClasses; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 275 | private final Label targetLabel; |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 276 | |
| 277 | @AutoCodec.Instantiator |
| 278 | @AutoCodec.VisibleForSerialization |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 279 | static TopLevelAspectsKey createInternal( |
| 280 | ImmutableList<AspectClass> topLevelAspectsClasses, |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 281 | Label targetLabel, |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 282 | ConfiguredTargetKey baseConfiguredTargetKey) { |
| 283 | return topLevelAspectsKeyInterner.intern( |
| 284 | new TopLevelAspectsKey( |
| 285 | topLevelAspectsClasses, |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 286 | targetLabel, |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 287 | baseConfiguredTargetKey, |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 288 | Objects.hashCode(topLevelAspectsClasses, targetLabel, baseConfiguredTargetKey))); |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 289 | } |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 290 | |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 291 | private TopLevelAspectsKey( |
| 292 | ImmutableList<AspectClass> topLevelAspectsClasses, |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 293 | Label targetLabel, |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 294 | ConfiguredTargetKey baseConfiguredTargetKey, |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 295 | int hashCode) { |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 296 | super(baseConfiguredTargetKey, hashCode); |
| 297 | this.topLevelAspectsClasses = topLevelAspectsClasses; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 298 | this.targetLabel = targetLabel; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | @Override |
| 302 | public SkyFunctionName functionName() { |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 303 | return SkyFunctions.TOP_LEVEL_ASPECTS; |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 304 | } |
| 305 | |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 306 | ImmutableList<AspectClass> getTopLevelAspectsClasses() { |
| 307 | return topLevelAspectsClasses; |
adgar | 2487920 | 2021-04-12 09:21:20 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | @Override |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 311 | public Label getLabel() { |
| 312 | return targetLabel; |
| 313 | } |
| 314 | |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 315 | String getDescription() { |
| 316 | return topLevelAspectsClasses + " on " + getLabel(); |
messa | 943c83a | 2021-06-28 07:54:28 -0700 | [diff] [blame] | 317 | } |
| 318 | |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 319 | @Override |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 320 | public boolean equals(Object o) { |
| 321 | if (o == this) { |
| 322 | return true; |
| 323 | } |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 324 | if (!(o instanceof TopLevelAspectsKey)) { |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 325 | return false; |
| 326 | } |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 327 | TopLevelAspectsKey that = (TopLevelAspectsKey) o; |
| 328 | return hashCode() == that.hashCode() |
jhorvitz | 24b7366 | 2021-04-30 15:06:19 -0700 | [diff] [blame] | 329 | && Objects.equal(targetLabel, that.targetLabel) |
messa | c4157da | 2021-08-06 11:17:19 -0700 | [diff] [blame] | 330 | && Objects.equal(getBaseConfiguredTargetKey(), that.getBaseConfiguredTargetKey()) |
| 331 | && Objects.equal(topLevelAspectsClasses, that.topLevelAspectsClasses); |
jcater | 40549e7 | 2020-04-16 10:52:40 -0700 | [diff] [blame] | 332 | } |
| 333 | } |
| 334 | } |