Damien Martin-Guillerez | f88f4d8 | 2015-09-25 13:56:55 +0000 | [diff] [blame] | 1 | // Copyright 2014 The Bazel Authors. All rights reserved. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 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 com.google.devtools.build.lib.skyframe; |
| 16 | |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 17 | import com.google.common.base.MoreObjects; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 18 | import com.google.common.base.Objects; |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 19 | import com.google.common.base.Preconditions; |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 20 | import com.google.common.collect.ImmutableList; |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 21 | import com.google.common.collect.Interner; |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 22 | import com.google.devtools.build.lib.actions.BasicActionLookupValue; |
Dmitry Lomov | b487ac6 | 2015-11-09 13:09:12 +0000 | [diff] [blame] | 23 | import com.google.devtools.build.lib.analysis.ConfiguredAspect; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 24 | import com.google.devtools.build.lib.analysis.config.BuildConfiguration; |
Lukacs Berki | 6e91eb9 | 2015-09-21 09:12:37 +0000 | [diff] [blame] | 25 | import com.google.devtools.build.lib.cmdline.Label; |
Marian Lobur | c62faba | 2015-09-09 10:08:06 +0000 | [diff] [blame] | 26 | import com.google.devtools.build.lib.collect.nestedset.NestedSet; |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 27 | import com.google.devtools.build.lib.concurrent.BlazeInterners; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 28 | import com.google.devtools.build.lib.events.Location; |
Dmitry Lomov | b487ac6 | 2015-11-09 13:09:12 +0000 | [diff] [blame] | 29 | import com.google.devtools.build.lib.packages.Aspect; |
Dmitry Lomov | 8ff0645 | 2015-10-21 19:16:30 +0000 | [diff] [blame] | 30 | import com.google.devtools.build.lib.packages.AspectClass; |
Dmitry Lomov | 1575652 | 2016-12-16 16:52:37 +0000 | [diff] [blame] | 31 | import com.google.devtools.build.lib.packages.AspectDescriptor; |
Marian Lobur | 702cad7 | 2015-09-02 09:53:58 +0000 | [diff] [blame] | 32 | import com.google.devtools.build.lib.packages.AspectParameters; |
Marian Lobur | c62faba | 2015-09-09 10:08:06 +0000 | [diff] [blame] | 33 | import com.google.devtools.build.lib.packages.Package; |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 34 | import com.google.devtools.build.lib.skyframe.BuildConfigurationValue.Key; |
| 35 | import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey.KeyAndHost; |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 36 | import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 37 | import com.google.devtools.build.lib.syntax.SkylarkImport; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 38 | import com.google.devtools.build.skyframe.SkyFunctionName; |
janakr | a81bb95 | 2019-01-28 17:30:06 -0800 | [diff] [blame] | 39 | import java.math.BigInteger; |
Marian Lobur | 702cad7 | 2015-09-02 09:53:58 +0000 | [diff] [blame] | 40 | import javax.annotation.Nullable; |
| 41 | |
janakr | 9bad840 | 2018-03-23 15:32:37 -0700 | [diff] [blame] | 42 | /** An aspect in the context of the Skyframe graph. */ |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 43 | public final class AspectValue extends BasicActionLookupValue { |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 44 | /** |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 45 | * A base class for keys that have AspectValue as a Sky value. |
| 46 | */ |
| 47 | public abstract static class AspectValueKey extends ActionLookupKey { |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 48 | public abstract String getDescription(); |
janakr | 2098474 | 2019-01-28 10:36:35 -0800 | [diff] [blame] | 49 | |
| 50 | @Override |
| 51 | public abstract Label getLabel(); |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 52 | } |
| 53 | |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 54 | /** A base class for a key representing an aspect applied to a particular target. */ |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 55 | @AutoCodec |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 56 | public static class AspectKey extends AspectValueKey { |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 57 | private final Label label; |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 58 | private final ImmutableList<AspectKey> baseKeys; |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 59 | private final BuildConfigurationValue.Key aspectConfigurationKey; |
| 60 | private final ConfiguredTargetKey baseConfiguredTargetKey; |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 61 | private final AspectDescriptor aspectDescriptor; |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 62 | private int hashCode; |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 63 | |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 64 | private AspectKey( |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 65 | Label label, |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 66 | BuildConfigurationValue.Key aspectConfigurationKey, |
| 67 | ConfiguredTargetKey baseConfiguredTargetKey, |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 68 | ImmutableList<AspectKey> baseKeys, |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 69 | AspectDescriptor aspectDescriptor) { |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 70 | this.baseKeys = baseKeys; |
| 71 | this.label = label; |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 72 | this.aspectConfigurationKey = aspectConfigurationKey; |
| 73 | this.baseConfiguredTargetKey = baseConfiguredTargetKey; |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 74 | this.aspectDescriptor = aspectDescriptor; |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 75 | } |
| 76 | |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 77 | @AutoCodec.VisibleForSerialization |
| 78 | @AutoCodec.Instantiator |
| 79 | static AspectKey createAspectKey( |
| 80 | Label label, |
| 81 | ConfiguredTargetKey baseConfiguredTargetKey, |
| 82 | ImmutableList<AspectKey> baseKeys, |
| 83 | AspectDescriptor aspectDescriptor, |
| 84 | BuildConfigurationValue.Key aspectConfigurationKey, |
| 85 | boolean aspectConfigurationIsHost) { |
| 86 | return aspectKeyInterner.intern( |
| 87 | aspectConfigurationIsHost |
| 88 | ? new HostAspectKey( |
| 89 | label, |
| 90 | aspectConfigurationKey, |
| 91 | baseConfiguredTargetKey, |
| 92 | baseKeys, |
| 93 | aspectDescriptor) |
| 94 | : new AspectKey( |
| 95 | label, |
| 96 | aspectConfigurationKey, |
| 97 | baseConfiguredTargetKey, |
| 98 | baseKeys, |
| 99 | aspectDescriptor)); |
| 100 | } |
| 101 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 102 | @Override |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 103 | public SkyFunctionName functionName() { |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 104 | return SkyFunctions.ASPECT; |
| 105 | } |
| 106 | |
| 107 | |
| 108 | @Override |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 109 | public Label getLabel() { |
| 110 | return label; |
| 111 | } |
| 112 | |
Dmitry Lomov | b487ac6 | 2015-11-09 13:09:12 +0000 | [diff] [blame] | 113 | public AspectClass getAspectClass() { |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 114 | return aspectDescriptor.getAspectClass(); |
Marian Lobur | 702cad7 | 2015-09-02 09:53:58 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | @Nullable |
| 118 | public AspectParameters getParameters() { |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 119 | return aspectDescriptor.getParameters(); |
| 120 | } |
| 121 | |
| 122 | public AspectDescriptor getAspectDescriptor() { |
| 123 | return aspectDescriptor; |
Dmitry Lomov | 6231d08 | 2015-11-02 17:17:20 +0000 | [diff] [blame] | 124 | } |
| 125 | |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 126 | @Nullable |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 127 | ImmutableList<AspectKey> getBaseKeys() { |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 128 | return baseKeys; |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 129 | } |
| 130 | |
John Field | a97e17f | 2015-11-13 02:19:52 +0000 | [diff] [blame] | 131 | @Override |
Dmitry Lomov | 2aa1a98 | 2015-10-20 12:18:36 +0000 | [diff] [blame] | 132 | public String getDescription() { |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 133 | if (baseKeys.isEmpty()) { |
| 134 | return String.format("%s of %s", |
| 135 | aspectDescriptor.getAspectClass().getName(), getLabel()); |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 136 | } else { |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 137 | return String.format("%s on top of %s", |
| 138 | aspectDescriptor.getAspectClass().getName(), baseKeys.toString()); |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 139 | } |
Dmitry Lomov | 2aa1a98 | 2015-10-20 12:18:36 +0000 | [diff] [blame] | 140 | } |
| 141 | |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 142 | // Note that this does not factor into equality/hash-code computations because its value is |
| 143 | // already encoded in the aspectConfigurationKey, albeit in an opaque way. |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 144 | protected boolean aspectConfigurationIsHost() { |
| 145 | return false; |
| 146 | } |
| 147 | |
Michael Staib | 04f6f24 | 2016-03-01 15:40:29 +0000 | [diff] [blame] | 148 | /** |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 149 | * Returns the key of the configured target of the aspect; that is, the configuration in which |
| 150 | * the aspect will be evaluated. |
Michael Staib | 04f6f24 | 2016-03-01 15:40:29 +0000 | [diff] [blame] | 151 | * |
gregce | e0bbe75 | 2017-09-12 23:58:34 +0200 | [diff] [blame] | 152 | * <p>In trimmed configuration mode, the aspect may require more fragments than the target on |
Michael Staib | 04f6f24 | 2016-03-01 15:40:29 +0000 | [diff] [blame] | 153 | * which it is being evaluated; in addition to configuration fragments required by the target |
| 154 | * and its dependencies, an aspect has configuration fragment requirements of its own, as well |
| 155 | * as dependencies of its own with their own configuration fragment requirements. |
| 156 | * |
| 157 | * <p>The aspect configuration contains all of these fragments, and is used to create the |
| 158 | * aspect's RuleContext and to retrieve the dependencies. Note that dependencies will have their |
| 159 | * configurations trimmed from this one as normal. |
| 160 | * |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 161 | * <p>Because of these properties, this configuration is always a superset of the base target's |
| 162 | * configuration. In untrimmed configuration mode, this configuration will be equivalent to the |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 163 | * base target's configuration. |
Michael Staib | 04f6f24 | 2016-03-01 15:40:29 +0000 | [diff] [blame] | 164 | */ |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 165 | BuildConfigurationValue.Key getAspectConfigurationKey() { |
| 166 | return aspectConfigurationKey; |
Michael Staib | 04f6f24 | 2016-03-01 15:40:29 +0000 | [diff] [blame] | 167 | } |
| 168 | |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 169 | /** Returns the key for the base configured target for this aspect. */ |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 170 | ConfiguredTargetKey getBaseConfiguredTargetKey() { |
| 171 | return baseConfiguredTargetKey; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | @Override |
| 175 | public int hashCode() { |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 176 | // We use the hash code caching strategy employed by java.lang.String. There are three subtle |
| 177 | // things going on here: |
| 178 | // |
| 179 | // (1) We use a value of 0 to indicate that the hash code hasn't been computed and cached yet. |
| 180 | // Yes, this means that if the hash code is really 0 then we will "recompute" it each time. |
| 181 | // But this isn't a problem in practice since a hash code of 0 should be rare. |
| 182 | // |
| 183 | // (2) Since we have no synchronization, multiple threads can race here thinking there are the |
| 184 | // first one to compute and cache the hash code. |
| 185 | // |
| 186 | // (3) Moreover, since 'hashCode' is non-volatile, the cached hash code value written from one |
| 187 | // thread may not be visible by another. |
| 188 | // |
| 189 | // All three of these issues are benign from a correctness perspective; in the end we have no |
| 190 | // overhead from synchronization, at the cost of potentially computing the hash code more than |
| 191 | // once. |
| 192 | int h = hashCode; |
| 193 | if (h == 0) { |
| 194 | h = computeHashCode(); |
| 195 | hashCode = h; |
| 196 | } |
| 197 | return h; |
| 198 | } |
| 199 | |
| 200 | private int computeHashCode() { |
Dmitry Lomov | f86ad5f | 2016-04-06 10:01:15 +0000 | [diff] [blame] | 201 | return Objects.hashCode( |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 202 | label, baseKeys, aspectConfigurationKey, baseConfiguredTargetKey, aspectDescriptor); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public boolean equals(Object other) { |
| 207 | if (this == other) { |
| 208 | return true; |
| 209 | } |
| 210 | |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 211 | if (!(other instanceof AspectKey)) { |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 212 | return false; |
| 213 | } |
| 214 | |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 215 | AspectKey that = (AspectKey) other; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 216 | return Objects.equal(label, that.label) |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 217 | && Objects.equal(baseKeys, that.baseKeys) |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 218 | && Objects.equal(aspectConfigurationKey, that.aspectConfigurationKey) |
| 219 | && Objects.equal(baseConfiguredTargetKey, that.baseConfiguredTargetKey) |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 220 | && Objects.equal(aspectDescriptor, that.aspectDescriptor); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 221 | } |
| 222 | |
Lukacs Berki | bba75d8 | 2016-06-14 09:08:29 +0000 | [diff] [blame] | 223 | public String prettyPrint() { |
| 224 | if (label == null) { |
| 225 | return "null"; |
| 226 | } |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 227 | |
| 228 | String baseKeysString = |
| 229 | baseKeys.isEmpty() |
| 230 | ? "" |
| 231 | : String.format(" (over %s)", baseKeys.toString()); |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 232 | return String.format( |
| 233 | "%s with aspect %s%s%s", |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 234 | label.toString(), |
| 235 | aspectDescriptor.getAspectClass().getName(), |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 236 | (aspectConfigurationKey != null && aspectConfigurationIsHost()) ? "(host) " : "", |
| 237 | baseKeysString); |
Lukacs Berki | bba75d8 | 2016-06-14 09:08:29 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 240 | @Override |
| 241 | public String toString() { |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 242 | return (baseKeys == null ? label : baseKeys.toString()) |
Dmitry Lomov | 6231d08 | 2015-11-02 17:17:20 +0000 | [diff] [blame] | 243 | + "#" |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 244 | + aspectDescriptor |
Dmitry Lomov | 6231d08 | 2015-11-02 17:17:20 +0000 | [diff] [blame] | 245 | + " " |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 246 | + aspectConfigurationKey |
Michael Staib | 04f6f24 | 2016-03-01 15:40:29 +0000 | [diff] [blame] | 247 | + " " |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 248 | + baseConfiguredTargetKey |
Dmitry Lomov | 6231d08 | 2015-11-02 17:17:20 +0000 | [diff] [blame] | 249 | + " " |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 250 | + aspectDescriptor.getParameters() |
| 251 | + (aspectConfigurationIsHost() ? " (host)" : ""); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 252 | } |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 253 | |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 254 | AspectKey withLabel(Label label) { |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 255 | ImmutableList.Builder<AspectKey> newBaseKeys = ImmutableList.builder(); |
| 256 | for (AspectKey baseKey : baseKeys) { |
| 257 | newBaseKeys.add(baseKey.withLabel(label)); |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 258 | } |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 259 | |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 260 | return createAspectKey( |
| 261 | label, |
| 262 | ConfiguredTargetKey.of( |
| 263 | label, |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 264 | baseConfiguredTargetKey.getConfigurationKey(), |
| 265 | baseConfiguredTargetKey.isHostConfiguration()), |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 266 | newBaseKeys.build(), |
| 267 | aspectDescriptor, |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 268 | aspectConfigurationKey, |
| 269 | aspectConfigurationIsHost()); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | /** An {@link AspectKey} for an aspect in the host configuration. */ |
janakr | 64d9a4d | 2018-02-02 12:38:58 -0800 | [diff] [blame] | 274 | static class HostAspectKey extends AspectKey { |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 275 | private HostAspectKey( |
| 276 | Label label, |
| 277 | Key aspectConfigurationKey, |
| 278 | ConfiguredTargetKey baseConfiguredTargetKey, |
| 279 | ImmutableList<AspectKey> baseKeys, |
| 280 | AspectDescriptor aspectDescriptor) { |
| 281 | super(label, aspectConfigurationKey, baseConfiguredTargetKey, baseKeys, aspectDescriptor); |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | protected boolean aspectConfigurationIsHost() { |
| 286 | return true; |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 287 | } |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 288 | } |
| 289 | |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 290 | /** |
Dmitry Lomov | b487ac6 | 2015-11-09 13:09:12 +0000 | [diff] [blame] | 291 | * The key for a skylark aspect. |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 292 | */ |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 293 | public static class SkylarkAspectLoadingKey extends AspectValueKey { |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 294 | |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 295 | private final Label targetLabel; |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 296 | private final BuildConfigurationValue.Key aspectConfigurationKey; |
| 297 | private final ConfiguredTargetKey baseConfiguredTargetKey; |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 298 | private final SkylarkImport skylarkImport; |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 299 | private final String skylarkValueName; |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 300 | private int hashCode; |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 301 | |
| 302 | private SkylarkAspectLoadingKey( |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 303 | Label targetLabel, |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 304 | BuildConfigurationValue.Key aspectConfigurationKey, |
| 305 | ConfiguredTargetKey baseConfiguredTargetKey, |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 306 | SkylarkImport skylarkImport, |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 307 | String skylarkFunctionName) { |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 308 | this.targetLabel = targetLabel; |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 309 | this.aspectConfigurationKey = aspectConfigurationKey; |
| 310 | this.baseConfiguredTargetKey = baseConfiguredTargetKey; |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 311 | this.skylarkImport = skylarkImport; |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 312 | this.skylarkValueName = skylarkFunctionName; |
| 313 | } |
| 314 | |
| 315 | @Override |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 316 | public SkyFunctionName functionName() { |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 317 | return SkyFunctions.LOAD_SKYLARK_ASPECT; |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 318 | } |
| 319 | |
janakr | 2098474 | 2019-01-28 10:36:35 -0800 | [diff] [blame] | 320 | String getSkylarkValueName() { |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 321 | return skylarkValueName; |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 322 | } |
| 323 | |
janakr | 2098474 | 2019-01-28 10:36:35 -0800 | [diff] [blame] | 324 | SkylarkImport getSkylarkImport() { |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 325 | return skylarkImport; |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 326 | } |
| 327 | |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 328 | protected boolean isAspectConfigurationHost() { |
| 329 | return false; |
| 330 | } |
| 331 | |
John Field | a97e17f | 2015-11-13 02:19:52 +0000 | [diff] [blame] | 332 | @Override |
janakr | 2098474 | 2019-01-28 10:36:35 -0800 | [diff] [blame] | 333 | public Label getLabel() { |
| 334 | return targetLabel; |
| 335 | } |
| 336 | |
| 337 | @Override |
Dmitry Lomov | 2aa1a98 | 2015-10-20 12:18:36 +0000 | [diff] [blame] | 338 | public String getDescription() { |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 339 | // Skylark aspects are referred to on command line with <file>%<value ame> |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 340 | return String.format("%s%%%s of %s", skylarkImport.getImportString(), |
| 341 | skylarkValueName, targetLabel); |
| 342 | } |
| 343 | |
| 344 | @Override |
| 345 | public int hashCode() { |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 346 | // We use the hash code caching strategy employed by java.lang.String. There are three subtle |
| 347 | // things going on here: |
| 348 | // |
| 349 | // (1) We use a value of 0 to indicate that the hash code hasn't been computed and cached yet. |
| 350 | // Yes, this means that if the hash code is really 0 then we will "recompute" it each time. |
| 351 | // But this isn't a problem in practice since a hash code of 0 should be rare. |
| 352 | // |
| 353 | // (2) Since we have no synchronization, multiple threads can race here thinking there are the |
| 354 | // first one to compute and cache the hash code. |
| 355 | // |
| 356 | // (3) Moreover, since 'hashCode' is non-volatile, the cached hash code value written from one |
| 357 | // thread may not be visible by another. |
| 358 | // |
| 359 | // All three of these issues are benign from a correctness perspective; in the end we have no |
| 360 | // overhead from synchronization, at the cost of potentially computing the hash code more than |
| 361 | // once. |
| 362 | int h = hashCode; |
| 363 | if (h == 0) { |
| 364 | h = computeHashCode(); |
| 365 | hashCode = h; |
| 366 | } |
| 367 | return h; |
| 368 | } |
| 369 | |
| 370 | private int computeHashCode() { |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 371 | return Objects.hashCode( |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 372 | targetLabel, |
| 373 | aspectConfigurationKey, |
| 374 | baseConfiguredTargetKey, |
| 375 | skylarkImport, |
| 376 | skylarkValueName); |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | @Override |
| 380 | public boolean equals(Object o) { |
| 381 | if (o == this) { |
| 382 | return true; |
| 383 | } |
| 384 | |
| 385 | if (!(o instanceof SkylarkAspectLoadingKey)) { |
| 386 | return false; |
| 387 | } |
| 388 | SkylarkAspectLoadingKey that = (SkylarkAspectLoadingKey) o; |
| 389 | return Objects.equal(targetLabel, that.targetLabel) |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 390 | && Objects.equal(aspectConfigurationKey, that.aspectConfigurationKey) |
| 391 | && Objects.equal(baseConfiguredTargetKey, that.baseConfiguredTargetKey) |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 392 | && Objects.equal(skylarkImport, that.skylarkImport) |
| 393 | && Objects.equal(skylarkValueName, that.skylarkValueName); |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 394 | } |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 395 | |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 396 | AspectKey toAspectKey(AspectClass aspectClass) { |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 397 | return AspectKey.createAspectKey( |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 398 | targetLabel, |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 399 | baseConfiguredTargetKey, |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 400 | ImmutableList.of(), |
| 401 | new AspectDescriptor(aspectClass, AspectParameters.EMPTY), |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 402 | aspectConfigurationKey, |
| 403 | isAspectConfigurationHost()); |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | /** A {@link SkylarkAspectLoadingKey} for an aspect in the host configuration. */ |
| 408 | private static class HostSkylarkAspectLoadingKey extends SkylarkAspectLoadingKey { |
| 409 | |
| 410 | private HostSkylarkAspectLoadingKey( |
| 411 | Label targetLabel, |
| 412 | Key aspectConfigurationKey, |
| 413 | ConfiguredTargetKey baseConfiguredTargetKey, |
| 414 | SkylarkImport skylarkImport, |
| 415 | String skylarkFunctionName) { |
| 416 | super( |
| 417 | targetLabel, |
| 418 | aspectConfigurationKey, |
| 419 | baseConfiguredTargetKey, |
| 420 | skylarkImport, |
| 421 | skylarkFunctionName); |
| 422 | } |
| 423 | |
| 424 | @Override |
| 425 | protected boolean isAspectConfigurationHost() { |
| 426 | return true; |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 427 | } |
| 428 | } |
| 429 | |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 430 | // These variables are only non-final because they may be clear()ed to save memory. They are null |
janakr | 931d285 | 2017-12-15 13:48:29 -0800 | [diff] [blame] | 431 | // only after they are cleared except for transitivePackagesForPackageRootResolution. |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 432 | @Nullable private Label label; |
| 433 | @Nullable private Aspect aspect; |
| 434 | @Nullable private Location location; |
| 435 | @Nullable private AspectKey key; |
| 436 | @Nullable private ConfiguredAspect configuredAspect; |
janakr | 931d285 | 2017-12-15 13:48:29 -0800 | [diff] [blame] | 437 | // May be null either after clearing or because transitive packages are not tracked. |
janakr | 907ca4a | 2019-01-25 13:37:24 -0800 | [diff] [blame] | 438 | @Nullable private transient NestedSet<Package> transitivePackagesForPackageRootResolution; |
janakr | 9bad840 | 2018-03-23 15:32:37 -0700 | [diff] [blame] | 439 | |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 440 | public AspectValue( |
Dmitry Lomov | b487ac6 | 2015-11-09 13:09:12 +0000 | [diff] [blame] | 441 | AspectKey key, |
Dmitry Lomov | 2eb8bdd | 2016-04-06 08:47:30 +0000 | [diff] [blame] | 442 | Aspect aspect, |
Dmitry Lomov | b487ac6 | 2015-11-09 13:09:12 +0000 | [diff] [blame] | 443 | Label label, |
| 444 | Location location, |
| 445 | ConfiguredAspect configuredAspect, |
janakr | a81bb95 | 2019-01-28 17:30:06 -0800 | [diff] [blame] | 446 | NestedSet<Package> transitivePackagesForPackageRootResolution, |
| 447 | BigInteger nonceVersion) { |
| 448 | super(configuredAspect.getActions(), configuredAspect.getGeneratingActionIndex(), nonceVersion); |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 449 | this.label = Preconditions.checkNotNull(label, actions); |
| 450 | this.aspect = Preconditions.checkNotNull(aspect, label); |
| 451 | this.location = Preconditions.checkNotNull(location, label); |
| 452 | this.key = Preconditions.checkNotNull(key, label); |
| 453 | this.configuredAspect = Preconditions.checkNotNull(configuredAspect, label); |
janakr | 931d285 | 2017-12-15 13:48:29 -0800 | [diff] [blame] | 454 | this.transitivePackagesForPackageRootResolution = transitivePackagesForPackageRootResolution; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 455 | } |
| 456 | |
Dmitry Lomov | b487ac6 | 2015-11-09 13:09:12 +0000 | [diff] [blame] | 457 | public ConfiguredAspect getConfiguredAspect() { |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 458 | return Preconditions.checkNotNull(configuredAspect); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 459 | } |
| 460 | |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 461 | public Label getLabel() { |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 462 | return Preconditions.checkNotNull(label); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | public Location getLocation() { |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 466 | return Preconditions.checkNotNull(location); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | public AspectKey getKey() { |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 470 | return Preconditions.checkNotNull(key); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 471 | } |
| 472 | |
Dmitry Lomov | 2eb8bdd | 2016-04-06 08:47:30 +0000 | [diff] [blame] | 473 | public Aspect getAspect() { |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 474 | return Preconditions.checkNotNull(aspect); |
Dmitry Lomov | 2eb8bdd | 2016-04-06 08:47:30 +0000 | [diff] [blame] | 475 | } |
| 476 | |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 477 | void clear(boolean clearEverything) { |
| 478 | Preconditions.checkNotNull(label, this); |
| 479 | Preconditions.checkNotNull(aspect, this); |
| 480 | Preconditions.checkNotNull(location, this); |
| 481 | Preconditions.checkNotNull(key, this); |
| 482 | Preconditions.checkNotNull(configuredAspect, this); |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 483 | if (clearEverything) { |
| 484 | label = null; |
| 485 | aspect = null; |
| 486 | location = null; |
| 487 | key = null; |
| 488 | configuredAspect = null; |
| 489 | } |
janakr | 931d285 | 2017-12-15 13:48:29 -0800 | [diff] [blame] | 490 | transitivePackagesForPackageRootResolution = null; |
Marian Lobur | c62faba | 2015-09-09 10:08:06 +0000 | [diff] [blame] | 491 | } |
| 492 | |
janakr | a81bb95 | 2019-01-28 17:30:06 -0800 | [diff] [blame] | 493 | @Override |
| 494 | public final boolean mustBeReferenceComparedOnRecomputation() { |
| 495 | return true; |
| 496 | } |
| 497 | |
janakr | 931d285 | 2017-12-15 13:48:29 -0800 | [diff] [blame] | 498 | /** |
| 499 | * Returns the set of packages transitively loaded by this value. Must only be used for |
| 500 | * constructing the package -> source root map needed for some builds. If the caller has not |
| 501 | * specified that this map needs to be constructed (via the constructor argument in {@link |
| 502 | * AspectFunction#AspectFunction}), calling this will crash. |
| 503 | */ |
| 504 | public NestedSet<Package> getTransitivePackagesForPackageRootResolution() { |
| 505 | return Preconditions.checkNotNull(transitivePackagesForPackageRootResolution); |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 506 | } |
| 507 | |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 508 | @Override |
| 509 | public String toString() { |
| 510 | return MoreObjects.toStringHelper(this) |
| 511 | .add("label", label) |
| 512 | .add("key", key) |
| 513 | .add("location", location) |
| 514 | .add("aspect", aspect) |
| 515 | .add("configuredAspect", configuredAspect) |
| 516 | .toString(); |
| 517 | } |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 518 | |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 519 | public static AspectKey createAspectKey( |
janakr | db4dec2 | 2017-03-28 22:39:35 +0000 | [diff] [blame] | 520 | Label label, |
| 521 | BuildConfiguration baseConfiguration, |
| 522 | ImmutableList<AspectKey> baseKeys, |
| 523 | AspectDescriptor aspectDescriptor, |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 524 | BuildConfiguration aspectConfiguration) { |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 525 | KeyAndHost aspectKeyAndHost = ConfiguredTargetKey.keyFromConfiguration(aspectConfiguration); |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 526 | return AspectKey.createAspectKey( |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 527 | label, |
| 528 | ConfiguredTargetKey.of(label, baseConfiguration), |
Dmitry Lomov | e851fe2 | 2017-02-14 23:11:23 +0000 | [diff] [blame] | 529 | baseKeys, |
| 530 | aspectDescriptor, |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 531 | aspectKeyAndHost.key, |
| 532 | aspectKeyAndHost.isHost); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 533 | } |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 534 | |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 535 | private static final Interner<AspectKey> aspectKeyInterner = BlazeInterners.newWeakInterner(); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 536 | |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 537 | public static AspectKey createAspectKey( |
Michael Staib | 04f6f24 | 2016-03-01 15:40:29 +0000 | [diff] [blame] | 538 | Label label, |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 539 | BuildConfiguration baseConfiguration, |
| 540 | AspectDescriptor aspectDescriptor, |
| 541 | BuildConfiguration aspectConfiguration) { |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 542 | KeyAndHost aspectKeyAndHost = ConfiguredTargetKey.keyFromConfiguration(aspectConfiguration); |
janakr | 649d2b1 | 2018-02-13 15:37:30 -0800 | [diff] [blame] | 543 | return AspectKey.createAspectKey( |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 544 | label, |
| 545 | ConfiguredTargetKey.of(label, baseConfiguration), |
| 546 | ImmutableList.of(), |
| 547 | aspectDescriptor, |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 548 | aspectKeyAndHost.key, |
| 549 | aspectKeyAndHost.isHost); |
janakr | b9788e1 | 2018-01-24 11:46:25 -0800 | [diff] [blame] | 550 | } |
| 551 | |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 552 | private static final Interner<SkylarkAspectLoadingKey> skylarkAspectKeyInterner = |
| 553 | BlazeInterners.newWeakInterner(); |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 554 | |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 555 | public static SkylarkAspectLoadingKey createSkylarkAspectKey( |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 556 | Label targetLabel, |
Michael Staib | 04f6f24 | 2016-03-01 15:40:29 +0000 | [diff] [blame] | 557 | BuildConfiguration aspectConfiguration, |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 558 | BuildConfiguration targetConfiguration, |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 559 | SkylarkImport skylarkImport, |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 560 | String skylarkExportName) { |
cpeyser | a8a61ee | 2018-01-26 09:20:37 -0800 | [diff] [blame] | 561 | KeyAndHost keyAndHost = ConfiguredTargetKey.keyFromConfiguration(aspectConfiguration); |
| 562 | SkylarkAspectLoadingKey key = |
| 563 | keyAndHost.isHost |
| 564 | ? new HostSkylarkAspectLoadingKey( |
| 565 | targetLabel, |
| 566 | keyAndHost.key, |
| 567 | ConfiguredTargetKey.of(targetLabel, targetConfiguration), |
| 568 | skylarkImport, |
| 569 | skylarkExportName) |
| 570 | : new SkylarkAspectLoadingKey( |
| 571 | targetLabel, |
| 572 | keyAndHost.key, |
| 573 | ConfiguredTargetKey.of(targetLabel, targetConfiguration), |
| 574 | skylarkImport, |
| 575 | skylarkExportName); |
| 576 | |
| 577 | return skylarkAspectKeyInterner.intern(key); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 578 | } |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 579 | } |