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.analysis; |
| 16 | |
Carmi Grushko | eaaa9d0d | 2015-11-17 01:54:45 +0000 | [diff] [blame] | 17 | import static com.google.devtools.build.lib.analysis.ExtraActionUtils.createExtraActionProvider; |
| 18 | |
Dmitry Lomov | 2473b9f | 2015-09-14 08:53:10 +0000 | [diff] [blame] | 19 | import com.google.common.annotations.VisibleForTesting; |
tomlu | a155b53 | 2017-11-08 20:12:47 +0100 | [diff] [blame] | 20 | import com.google.common.base.Preconditions; |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 21 | import com.google.common.collect.ImmutableList; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 22 | import com.google.common.collect.ImmutableMap; |
Carmi Grushko | 4076e44 | 2016-01-21 20:05:42 +0000 | [diff] [blame] | 23 | import com.google.common.collect.ImmutableSet; |
Rumou Duan | 33bab46 | 2016-04-25 17:55:12 +0000 | [diff] [blame] | 24 | import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 25 | import com.google.devtools.build.lib.actions.Actions; |
| 26 | import com.google.devtools.build.lib.actions.Actions.GeneratingActions; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 27 | import com.google.devtools.build.lib.actions.Artifact; |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 28 | import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 29 | import com.google.devtools.build.lib.collect.nestedset.NestedSet; |
| 30 | import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 31 | import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 32 | import com.google.devtools.build.lib.events.Location; |
Dmitry Lomov | dce0170 | 2016-11-28 15:51:32 +0000 | [diff] [blame] | 33 | import com.google.devtools.build.lib.packages.AspectClass; |
Dmitry Lomov | 1575652 | 2016-12-16 16:52:37 +0000 | [diff] [blame] | 34 | import com.google.devtools.build.lib.packages.AspectDescriptor; |
Dmitry Lomov | dce0170 | 2016-11-28 15:51:32 +0000 | [diff] [blame] | 35 | import com.google.devtools.build.lib.packages.AspectParameters; |
dslomov | de965ac | 2017-07-31 21:07:51 +0200 | [diff] [blame] | 36 | import com.google.devtools.build.lib.packages.Info; |
| 37 | import com.google.devtools.build.lib.packages.Provider; |
dslomov | ea7d482 | 2017-05-03 13:01:27 +0200 | [diff] [blame] | 38 | import com.google.devtools.build.lib.packages.SkylarkProviderIdentifier; |
janakr | bffa2db | 2018-03-25 12:42:11 -0700 | [diff] [blame] | 39 | import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; |
Dmitry Lomov | 2aa1a98 | 2015-10-20 12:18:36 +0000 | [diff] [blame] | 40 | import com.google.devtools.build.lib.syntax.EvalException; |
Googler | 94d35de | 2016-09-16 15:21:39 +0000 | [diff] [blame] | 41 | import java.util.Arrays; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 42 | import java.util.Map; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 43 | import java.util.TreeMap; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 44 | import javax.annotation.Nullable; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Extra information about a configured target computed on request of a dependent. |
| 48 | * |
| 49 | * <p>Analogous to {@link ConfiguredTarget}: contains a bunch of transitive info providers, which |
Googler | 4e0a5cb | 2017-04-09 17:58:18 -0400 | [diff] [blame] | 50 | * are merged with the providers of the associated configured target before they are passed to the |
| 51 | * configured target factories that depend on the configured target to which this aspect is added. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 52 | * |
| 53 | * <p>Aspects are created alongside configured targets on request from dependents. |
Lukacs Berki | 2300cd6 | 2016-05-19 11:06:37 +0000 | [diff] [blame] | 54 | * |
Googler | 4e0a5cb | 2017-04-09 17:58:18 -0400 | [diff] [blame] | 55 | * <p>For more information about aspects, see {@link |
| 56 | * com.google.devtools.build.lib.packages.AspectClass}. |
Lukacs Berki | 2300cd6 | 2016-05-19 11:06:37 +0000 | [diff] [blame] | 57 | * |
ulfjack | 26d0e49 | 2017-08-07 13:42:33 +0200 | [diff] [blame] | 58 | * @see com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory |
Lukacs Berki | 2300cd6 | 2016-05-19 11:06:37 +0000 | [diff] [blame] | 59 | * @see com.google.devtools.build.lib.packages.AspectClass |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 60 | */ |
| 61 | @Immutable |
janakr | bffa2db | 2018-03-25 12:42:11 -0700 | [diff] [blame] | 62 | @AutoCodec |
Googler | 4e0a5cb | 2017-04-09 17:58:18 -0400 | [diff] [blame] | 63 | public final class ConfiguredAspect { |
Dmitry Lomov | dce0170 | 2016-11-28 15:51:32 +0000 | [diff] [blame] | 64 | private final AspectDescriptor descriptor; |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 65 | private final ImmutableList<ActionAnalysisMetadata> actions; |
| 66 | private final ImmutableMap<Artifact, Integer> generatingActionIndex; |
| 67 | private final TransitiveInfoProviderMap providers; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 68 | |
janakr | bffa2db | 2018-03-25 12:42:11 -0700 | [diff] [blame] | 69 | @AutoCodec.VisibleForSerialization |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 70 | ConfiguredAspect( |
| 71 | AspectDescriptor descriptor, |
| 72 | ImmutableList<ActionAnalysisMetadata> actions, |
| 73 | ImmutableMap<Artifact, Integer> generatingActionIndex, |
| 74 | TransitiveInfoProviderMap providers) { |
Dmitry Lomov | dce0170 | 2016-11-28 15:51:32 +0000 | [diff] [blame] | 75 | this.descriptor = descriptor; |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 76 | this.actions = actions; |
| 77 | this.generatingActionIndex = generatingActionIndex; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 78 | this.providers = providers; |
| 79 | } |
| 80 | |
| 81 | /** |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 82 | * Returns the aspect name. |
| 83 | */ |
| 84 | public String getName() { |
Dmitry Lomov | dce0170 | 2016-11-28 15:51:32 +0000 | [diff] [blame] | 85 | return descriptor.getAspectClass().getName(); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * The aspect descriptor originating this ConfiguredAspect. |
| 90 | */ |
| 91 | public AspectDescriptor getDescriptor() { |
| 92 | return descriptor; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 93 | } |
| 94 | |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 95 | public ImmutableList<ActionAnalysisMetadata> getActions() { |
| 96 | return actions; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Returns a map where keys are artifacts that are action outputs of this rule, and values are the |
| 101 | * index of the action that generates that artifact. |
| 102 | */ |
| 103 | public ImmutableMap<Artifact, Integer> getGeneratingActionIndex() { |
| 104 | return generatingActionIndex; |
| 105 | } |
| 106 | |
Googler | 94d35de | 2016-09-16 15:21:39 +0000 | [diff] [blame] | 107 | /** Returns the providers created by the aspect. */ |
| 108 | public TransitiveInfoProviderMap getProviders() { |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 109 | return providers; |
| 110 | } |
| 111 | |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 112 | @Nullable |
Dmitry Lomov | 2473b9f | 2015-09-14 08:53:10 +0000 | [diff] [blame] | 113 | @VisibleForTesting |
| 114 | public <P extends TransitiveInfoProvider> P getProvider(Class<P> providerClass) { |
dslomov | 211a3ba | 2017-05-16 00:21:22 +0200 | [diff] [blame] | 115 | AnalysisUtils.checkProvider(providerClass); |
Googler | 94d35de | 2016-09-16 15:21:39 +0000 | [diff] [blame] | 116 | return providers.getProvider(providerClass); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 117 | } |
| 118 | |
dslomov | ea7d482 | 2017-05-03 13:01:27 +0200 | [diff] [blame] | 119 | public Object getProvider(SkylarkProviderIdentifier id) { |
| 120 | if (id.isLegacy()) { |
| 121 | return get(id.getLegacyId()); |
| 122 | } else { |
| 123 | return get(id.getKey()); |
| 124 | } |
| 125 | } |
| 126 | |
dslomov | de965ac | 2017-07-31 21:07:51 +0200 | [diff] [blame] | 127 | public Info get(Provider.Key key) { |
dslomov | f6a7e5a | 2017-07-05 07:23:31 -0400 | [diff] [blame] | 128 | return providers.getProvider(key); |
dslomov | ea7d482 | 2017-05-03 13:01:27 +0200 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | public Object get(String legacyKey) { |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 132 | if (OutputGroupInfo.SKYLARK_NAME.equals(legacyKey)) { |
| 133 | return get(OutputGroupInfo.SKYLARK_CONSTRUCTOR.getKey()); |
dslomov | ea7d482 | 2017-05-03 13:01:27 +0200 | [diff] [blame] | 134 | } |
dslomov | f6a7e5a | 2017-07-05 07:23:31 -0400 | [diff] [blame] | 135 | return providers.getProvider(legacyKey); |
dslomov | ea7d482 | 2017-05-03 13:01:27 +0200 | [diff] [blame] | 136 | } |
| 137 | |
Lukacs Berki | 549bfce | 2016-04-22 15:29:12 +0000 | [diff] [blame] | 138 | public static ConfiguredAspect forAlias(ConfiguredAspect real) { |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 139 | return new ConfiguredAspect( |
| 140 | real.descriptor, real.getActions(), real.getGeneratingActionIndex(), real.getProviders()); |
Lukacs Berki | 549bfce | 2016-04-22 15:29:12 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Dmitry Lomov | 6cd9897 | 2017-03-01 15:44:00 +0000 | [diff] [blame] | 143 | public static ConfiguredAspect forNonapplicableTarget(AspectDescriptor descriptor) { |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 144 | return new ConfiguredAspect( |
| 145 | descriptor, |
| 146 | ImmutableList.of(), |
| 147 | ImmutableMap.of(), |
| 148 | new TransitiveInfoProviderMapBuilder().add().build()); |
Dmitry Lomov | 6cd9897 | 2017-03-01 15:44:00 +0000 | [diff] [blame] | 149 | } |
| 150 | |
dslomov | 99ea6b4 | 2017-04-25 17:46:17 +0200 | [diff] [blame] | 151 | public static Builder builder( |
| 152 | AspectClass aspectClass, AspectParameters parameters, RuleContext ruleContext) { |
| 153 | return new Builder(aspectClass, parameters, ruleContext); |
| 154 | } |
| 155 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 156 | /** |
Dmitry Lomov | b487ac6 | 2015-11-09 13:09:12 +0000 | [diff] [blame] | 157 | * Builder for {@link ConfiguredAspect}. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 158 | */ |
| 159 | public static class Builder { |
Googler | 4b7aae4 | 2017-05-04 17:16:09 -0400 | [diff] [blame] | 160 | private final TransitiveInfoProviderMapBuilder providers = |
| 161 | new TransitiveInfoProviderMapBuilder(); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 162 | private final Map<String, NestedSetBuilder<Artifact>> outputGroupBuilders = new TreeMap<>(); |
Carmi Grushko | eaaa9d0d | 2015-11-17 01:54:45 +0000 | [diff] [blame] | 163 | private final RuleContext ruleContext; |
Dmitry Lomov | dce0170 | 2016-11-28 15:51:32 +0000 | [diff] [blame] | 164 | private final AspectDescriptor descriptor; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 165 | |
Dmitry Lomov | dce0170 | 2016-11-28 15:51:32 +0000 | [diff] [blame] | 166 | public Builder( |
| 167 | AspectClass aspectClass, |
| 168 | AspectParameters parameters, |
| 169 | RuleContext context) { |
| 170 | this(new AspectDescriptor(aspectClass, parameters), context); |
| 171 | } |
| 172 | |
| 173 | public Builder(AspectDescriptor descriptor, RuleContext ruleContext) { |
| 174 | this.descriptor = descriptor; |
Carmi Grushko | eaaa9d0d | 2015-11-17 01:54:45 +0000 | [diff] [blame] | 175 | this.ruleContext = ruleContext; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 176 | } |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 177 | |
Googler | 94d35de | 2016-09-16 15:21:39 +0000 | [diff] [blame] | 178 | public <T extends TransitiveInfoProvider> Builder addProvider( |
| 179 | Class<? extends T> providerClass, T provider) { |
| 180 | Preconditions.checkNotNull(provider); |
| 181 | checkProviderClass(providerClass); |
| 182 | providers.put(providerClass, provider); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 183 | return this; |
| 184 | } |
| 185 | |
Googler | 94d35de | 2016-09-16 15:21:39 +0000 | [diff] [blame] | 186 | /** Adds a provider to the aspect. */ |
| 187 | public Builder addProvider(TransitiveInfoProvider provider) { |
| 188 | Preconditions.checkNotNull(provider); |
Googler | 4b7aae4 | 2017-05-04 17:16:09 -0400 | [diff] [blame] | 189 | addProvider(TransitiveInfoProviderEffectiveClassHelper.get(provider), provider); |
Googler | 94d35de | 2016-09-16 15:21:39 +0000 | [diff] [blame] | 190 | return this; |
| 191 | } |
| 192 | |
| 193 | private void checkProviderClass(Class<? extends TransitiveInfoProvider> providerClass) { |
| 194 | Preconditions.checkNotNull(providerClass); |
Googler | 94d35de | 2016-09-16 15:21:39 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /** Adds providers to the aspect. */ |
| 198 | public Builder addProviders(TransitiveInfoProviderMap providers) { |
dslomov | f6a7e5a | 2017-07-05 07:23:31 -0400 | [diff] [blame] | 199 | this.providers.addAll(providers); |
Googler | 94d35de | 2016-09-16 15:21:39 +0000 | [diff] [blame] | 200 | return this; |
| 201 | } |
| 202 | |
| 203 | /** Adds providers to the aspect. */ |
| 204 | public Builder addProviders(TransitiveInfoProvider... providers) { |
| 205 | return addProviders(Arrays.asList(providers)); |
| 206 | } |
| 207 | |
| 208 | /** Adds providers to the aspect. */ |
| 209 | public Builder addProviders(Iterable<TransitiveInfoProvider> providers) { |
| 210 | for (TransitiveInfoProvider provider : providers) { |
| 211 | addProvider(provider); |
Carmi Grushko | b8f0e86 | 2015-11-23 23:26:15 +0000 | [diff] [blame] | 212 | } |
| 213 | return this; |
| 214 | } |
| 215 | |
Carmi Grushko | 65ac355 | 2015-08-21 16:43:26 +0000 | [diff] [blame] | 216 | /** |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 217 | * Adds a set of files to an output group. |
| 218 | */ |
| 219 | public Builder addOutputGroup(String name, NestedSet<Artifact> artifacts) { |
| 220 | NestedSetBuilder<Artifact> nestedSetBuilder = outputGroupBuilders.get(name); |
| 221 | if (nestedSetBuilder == null) { |
| 222 | nestedSetBuilder = NestedSetBuilder.<Artifact>stableOrder(); |
| 223 | outputGroupBuilders.put(name, nestedSetBuilder); |
| 224 | } |
| 225 | nestedSetBuilder.addTransitive(artifacts); |
| 226 | return this; |
| 227 | } |
| 228 | |
Googler | 63ce8f2 | 2017-01-09 15:32:16 +0000 | [diff] [blame] | 229 | public Builder addSkylarkTransitiveInfo(String name, Object value) { |
dslomov | f6a7e5a | 2017-07-05 07:23:31 -0400 | [diff] [blame] | 230 | providers.put(name, value); |
Googler | 63ce8f2 | 2017-01-09 15:32:16 +0000 | [diff] [blame] | 231 | return this; |
| 232 | } |
| 233 | |
Dmitry Lomov | 2aa1a98 | 2015-10-20 12:18:36 +0000 | [diff] [blame] | 234 | public Builder addSkylarkTransitiveInfo(String name, Object value, Location loc) |
| 235 | throws EvalException { |
dslomov | f6a7e5a | 2017-07-05 07:23:31 -0400 | [diff] [blame] | 236 | providers.put(name, value); |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 237 | return this; |
| 238 | } |
| 239 | |
brandjon | 11bcd24 | 2017-12-27 12:01:27 -0800 | [diff] [blame] | 240 | public Builder addSkylarkDeclaredProvider(Info declaredProvider) |
Vladimir Moskva | 6c28fe9 | 2017-03-03 12:55:08 +0000 | [diff] [blame] | 241 | throws EvalException { |
dslomov | de965ac | 2017-07-31 21:07:51 +0200 | [diff] [blame] | 242 | Provider constructor = declaredProvider.getProvider(); |
Vladimir Moskva | 6c28fe9 | 2017-03-03 12:55:08 +0000 | [diff] [blame] | 243 | if (!constructor.isExported()) { |
| 244 | throw new EvalException( |
| 245 | constructor.getLocation(), "All providers must be top level values"); |
| 246 | } |
dslomov | 11da220 | 2017-07-27 23:48:56 +0200 | [diff] [blame] | 247 | addDeclaredProvider(declaredProvider); |
Vladimir Moskva | 6c28fe9 | 2017-03-03 12:55:08 +0000 | [diff] [blame] | 248 | return this; |
| 249 | } |
| 250 | |
dslomov | de965ac | 2017-07-31 21:07:51 +0200 | [diff] [blame] | 251 | private void addDeclaredProvider(Info declaredProvider) { |
dslomov | 11da220 | 2017-07-27 23:48:56 +0200 | [diff] [blame] | 252 | providers.put(declaredProvider); |
dslomov | ea7d482 | 2017-05-03 13:01:27 +0200 | [diff] [blame] | 253 | } |
| 254 | |
dslomov | de965ac | 2017-07-31 21:07:51 +0200 | [diff] [blame] | 255 | public Builder addNativeDeclaredProvider(Info declaredProvider) { |
| 256 | Provider constructor = declaredProvider.getProvider(); |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 257 | Preconditions.checkState(constructor.isExported()); |
dslomov | 11da220 | 2017-07-27 23:48:56 +0200 | [diff] [blame] | 258 | addDeclaredProvider(declaredProvider); |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 259 | return this; |
| 260 | } |
| 261 | |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 262 | public ConfiguredAspect build() throws ActionConflictException { |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 263 | if (!outputGroupBuilders.isEmpty()) { |
| 264 | ImmutableMap.Builder<String, NestedSet<Artifact>> outputGroups = ImmutableMap.builder(); |
| 265 | for (Map.Entry<String, NestedSetBuilder<Artifact>> entry : outputGroupBuilders.entrySet()) { |
| 266 | outputGroups.put(entry.getKey(), entry.getValue().build()); |
| 267 | } |
| 268 | |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 269 | if (providers.contains(OutputGroupInfo.SKYLARK_CONSTRUCTOR.getKey())) { |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 270 | throw new IllegalStateException( |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 271 | "OutputGroupInfo was provided explicitly; do not use addOutputGroup"); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 272 | } |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 273 | addDeclaredProvider(new OutputGroupInfo(outputGroups.build())); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 274 | } |
| 275 | |
Carmi Grushko | 4076e44 | 2016-01-21 20:05:42 +0000 | [diff] [blame] | 276 | addProvider( |
Carmi Grushko | 4076e44 | 2016-01-21 20:05:42 +0000 | [diff] [blame] | 277 | createExtraActionProvider( |
cushon | 8c6b7ab | 2018-04-27 01:25:50 -0700 | [diff] [blame] | 278 | /* actionsWithoutExtraAction= */ ImmutableSet.<ActionAnalysisMetadata>of(), |
Rumou Duan | 33bab46 | 2016-04-25 17:55:12 +0000 | [diff] [blame] | 279 | ruleContext)); |
Carmi Grushko | eaaa9d0d | 2015-11-17 01:54:45 +0000 | [diff] [blame] | 280 | |
tomlu | 39a0a38 | 2018-06-22 09:43:23 -0700 | [diff] [blame^] | 281 | AnalysisEnvironment analysisEnvironment = ruleContext.getAnalysisEnvironment(); |
| 282 | GeneratingActions generatingActions = |
| 283 | Actions.filterSharedActionsAndThrowActionConflict( |
| 284 | analysisEnvironment.getActionKeyContext(), |
| 285 | analysisEnvironment.getRegisteredActions()); |
| 286 | |
| 287 | return new ConfiguredAspect( |
| 288 | descriptor, |
| 289 | generatingActions.getActions(), |
| 290 | generatingActions.getGeneratingActionIndex(), |
| 291 | providers.build()); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 292 | } |
| 293 | } |
Carmi Grushko | 65ac355 | 2015-08-21 16:43:26 +0000 | [diff] [blame] | 294 | } |