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 | |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 17 | import static com.google.devtools.build.lib.syntax.EvalUtils.SKYLARK_COMPARATOR; |
| 18 | |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableCollection; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 20 | import com.google.common.collect.ImmutableMap; |
Alex Humesky | 152feb0 | 2016-06-20 19:43:11 +0000 | [diff] [blame] | 21 | import com.google.common.collect.ImmutableSortedSet; |
| 22 | import com.google.common.collect.Sets; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 23 | import com.google.devtools.build.lib.actions.Artifact; |
ulfjack | 3562525 | 2017-08-08 19:45:46 +0200 | [diff] [blame] | 24 | import com.google.devtools.build.lib.analysis.skylark.SkylarkRuleConfiguredTargetUtil; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 25 | import com.google.devtools.build.lib.collect.nestedset.NestedSet; |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 26 | import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; |
| 27 | import com.google.devtools.build.lib.collect.nestedset.Order; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 28 | import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; |
cparsons | 2d67cf9 | 2018-05-24 14:02:09 -0700 | [diff] [blame] | 29 | import com.google.devtools.build.lib.packages.BuiltinProvider; |
adonovan | 7202d10 | 2019-12-09 13:58:57 -0800 | [diff] [blame] | 30 | import com.google.devtools.build.lib.packages.StructImpl; |
cpeyser | 10b1a5f | 2018-02-15 09:37:15 -0800 | [diff] [blame] | 31 | import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; |
cparsons | 2d67cf9 | 2018-05-24 14:02:09 -0700 | [diff] [blame] | 32 | import com.google.devtools.build.lib.skylarkbuildapi.OutputGroupInfoApi; |
Googler | d21a0d1 | 2019-11-21 13:52:30 -0800 | [diff] [blame] | 33 | import com.google.devtools.build.lib.syntax.Depset; |
Googler | a9c9363 | 2019-11-13 10:48:07 -0800 | [diff] [blame] | 34 | import com.google.devtools.build.lib.syntax.Dict; |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 35 | import com.google.devtools.build.lib.syntax.EvalException; |
adonovan | f5262c5 | 2020-04-02 09:25:14 -0700 | [diff] [blame] | 36 | import com.google.devtools.build.lib.syntax.Location; |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 37 | import com.google.devtools.build.lib.syntax.SkylarkIndexable; |
adonovan | 47bf59e | 2020-01-13 14:46:59 -0800 | [diff] [blame] | 38 | import com.google.devtools.build.lib.syntax.Starlark; |
Googler | 292a5c0 | 2019-11-25 14:53:08 -0800 | [diff] [blame] | 39 | import com.google.devtools.build.lib.syntax.StarlarkIterable; |
adonovan | 47bf59e | 2020-01-13 14:46:59 -0800 | [diff] [blame] | 40 | import com.google.devtools.build.lib.syntax.StarlarkSemantics; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 41 | import java.util.HashSet; |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 42 | import java.util.Iterator; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 43 | import java.util.List; |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 44 | import java.util.Map; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 45 | import java.util.Set; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 46 | import javax.annotation.Nullable; |
| 47 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 48 | /** |
Lukacs Berki | c1f894e | 2015-02-17 13:00:26 +0000 | [diff] [blame] | 49 | * {@code ConfiguredTarget}s implementing this interface can provide artifacts that <b>can</b> be |
| 50 | * built when the target is mentioned on the command line (as opposed to being always built, like |
| 51 | * {@link com.google.devtools.build.lib.analysis.FileProvider}) |
| 52 | * |
dslomov | de965ac | 2017-07-31 21:07:51 +0200 | [diff] [blame] | 53 | * <p>The artifacts are grouped into "output groups". Which output groups are built is controlled by |
| 54 | * the {@code --output_groups} undocumented command line option, which in turn is added to the |
Lukacs Berki | c1f894e | 2015-02-17 13:00:26 +0000 | [diff] [blame] | 55 | * command line at the discretion of the build command being run. |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 56 | * |
| 57 | * <p>Output groups starting with an underscore are "not important". This means that artifacts built |
| 58 | * because such an output group is mentioned in a {@code --output_groups} command line option are |
| 59 | * not mentioned on the output. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 60 | */ |
| 61 | @Immutable |
cpeyser | 10b1a5f | 2018-02-15 09:37:15 -0800 | [diff] [blame] | 62 | @AutoCodec |
adonovan | 7202d10 | 2019-12-09 13:58:57 -0800 | [diff] [blame] | 63 | public final class OutputGroupInfo extends StructImpl |
Googler | 292a5c0 | 2019-11-25 14:53:08 -0800 | [diff] [blame] | 64 | implements SkylarkIndexable, StarlarkIterable<String>, OutputGroupInfoApi { |
vladmos | 360fb4d | 2017-04-11 11:14:22 +0000 | [diff] [blame] | 65 | public static final String SKYLARK_NAME = "output_groups"; |
Lukacs Berki | 1b18ae9 | 2015-02-24 10:48:38 +0000 | [diff] [blame] | 66 | |
cparsons | 2d67cf9 | 2018-05-24 14:02:09 -0700 | [diff] [blame] | 67 | public static final OutputGroupInfoProvider SKYLARK_CONSTRUCTOR = new OutputGroupInfoProvider(); |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 68 | |
Lukacs Berki | 1b18ae9 | 2015-02-24 10:48:38 +0000 | [diff] [blame] | 69 | /** |
| 70 | * Prefix for output groups that are not reported to the user on the terminal output of Blaze when |
| 71 | * they are built. |
| 72 | */ |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 73 | public static final String HIDDEN_OUTPUT_GROUP_PREFIX = "_"; |
Lukacs Berki | 1b18ae9 | 2015-02-24 10:48:38 +0000 | [diff] [blame] | 74 | |
| 75 | /** |
Cal Peyser | eb85643 | 2016-06-22 14:25:36 +0000 | [diff] [blame] | 76 | * Suffix for output groups that are internal to bazel and may not be referenced from a filegroup. |
| 77 | */ |
| 78 | public static final String INTERNAL_SUFFIX = "_INTERNAL_"; |
| 79 | |
| 80 | /** |
Lukacs Berki | 1b18ae9 | 2015-02-24 10:48:38 +0000 | [diff] [blame] | 81 | * Building these artifacts only results in the compilation (and not e.g. linking) of the |
| 82 | * associated target. Mostly useful for C++, less so for e.g. Java. |
| 83 | */ |
lberki | 1dcd8f0 | 2018-04-04 03:13:55 -0700 | [diff] [blame] | 84 | public static final String FILES_TO_COMPILE = "compilation_outputs"; |
Lukacs Berki | 1b18ae9 | 2015-02-24 10:48:38 +0000 | [diff] [blame] | 85 | |
| 86 | /** |
| 87 | * These artifacts are the direct requirements for compilation, but building these does not |
| 88 | * actually compile the target. Mostly useful when IDEs want Blaze to emit generated code so that |
| 89 | * they can do the compilation in their own way. |
| 90 | */ |
Cal Peyser | eb85643 | 2016-06-22 14:25:36 +0000 | [diff] [blame] | 91 | public static final String COMPILATION_PREREQUISITES = |
| 92 | "compilation_prerequisites" + INTERNAL_SUFFIX; |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 93 | |
Lukacs Berki | 1b18ae9 | 2015-02-24 10:48:38 +0000 | [diff] [blame] | 94 | /** |
| 95 | * These files are built when a target is mentioned on the command line, but are not reported to |
| 96 | * the user. This is mostly runfiles, which is necessary because we don't want a target to |
| 97 | * successfully build if a file in its runfiles is broken. |
| 98 | */ |
Cal Peyser | eb85643 | 2016-06-22 14:25:36 +0000 | [diff] [blame] | 99 | public static final String HIDDEN_TOP_LEVEL = |
| 100 | HIDDEN_OUTPUT_GROUP_PREFIX + "hidden_top_level" + INTERNAL_SUFFIX; |
Lukacs Berki | 1b18ae9 | 2015-02-24 10:48:38 +0000 | [diff] [blame] | 101 | |
Lukacs Berki | b9e5130 | 2015-02-25 09:47:29 +0000 | [diff] [blame] | 102 | /** |
ahumesky | 60205bb | 2019-10-14 13:50:00 -0700 | [diff] [blame] | 103 | * This output group contains artifacts that are the outputs of validation actions. These actions |
| 104 | * should be run even if no other action depends on their outputs, therefore this output group is: |
| 105 | * |
| 106 | * <ul> |
| 107 | * <li>built even if <code>--output_groups</code> overrides the default output groups |
| 108 | * <li>not affected by the subtraction operation of <code>--output_groups</code> (i.e. <code> |
| 109 | * "--output_groups=-_validation"</code>) |
| 110 | * </ul> |
| 111 | * |
| 112 | * The only way to disable this output group is with <code>--run_validations=false</code>. |
| 113 | */ |
| 114 | public static final String VALIDATION = HIDDEN_OUTPUT_GROUP_PREFIX + "validation"; |
| 115 | |
| 116 | /** |
Lukacs Berki | b9e5130 | 2015-02-25 09:47:29 +0000 | [diff] [blame] | 117 | * Temporary files created during building a rule, for example, .i, .d and .s files for C++ |
| 118 | * compilation. |
| 119 | * |
| 120 | * <p>This output group is somewhat special: it is always built, but it only contains files when |
| 121 | * the {@code --save_temps} command line option present. I'm not sure if this is to save RAM by |
| 122 | * not creating the associated actions and artifacts if we don't need them or just historical |
| 123 | * baggage. |
| 124 | */ |
Cal Peyser | eb85643 | 2016-06-22 14:25:36 +0000 | [diff] [blame] | 125 | public static final String TEMP_FILES = "temp_files" + INTERNAL_SUFFIX; |
Lukacs Berki | b9e5130 | 2015-02-25 09:47:29 +0000 | [diff] [blame] | 126 | |
Lukacs Berki | 97f47ba | 2015-02-25 10:38:04 +0000 | [diff] [blame] | 127 | /** |
Lukacs Berki | 91ec274 | 2015-03-10 09:09:20 +0000 | [diff] [blame] | 128 | * The default group of files built by a target when it is mentioned on the command line. |
Lukacs Berki | 97f47ba | 2015-02-25 10:38:04 +0000 | [diff] [blame] | 129 | */ |
| 130 | public static final String DEFAULT = "default"; |
| 131 | |
Michajlo Matijkiw | c1d9450 | 2015-03-18 12:17:22 +0000 | [diff] [blame] | 132 | /** |
| 133 | * The default set of OutputGroups we typically want to build. |
| 134 | */ |
ulfjack | f000996 | 2018-07-23 01:19:20 -0700 | [diff] [blame] | 135 | public static final ImmutableSortedSet<String> DEFAULT_GROUPS = |
| 136 | ImmutableSortedSet.of(DEFAULT, TEMP_FILES, HIDDEN_TOP_LEVEL); |
Michajlo Matijkiw | c1d9450 | 2015-03-18 12:17:22 +0000 | [diff] [blame] | 137 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 138 | private final ImmutableMap<String, NestedSet<Artifact>> outputGroups; |
| 139 | |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 140 | public OutputGroupInfo(ImmutableMap<String, NestedSet<Artifact>> outputGroups) { |
adonovan | 7202d10 | 2019-12-09 13:58:57 -0800 | [diff] [blame] | 141 | super(SKYLARK_CONSTRUCTOR, Location.BUILTIN); |
Lukacs Berki | c1f894e | 2015-02-17 13:00:26 +0000 | [diff] [blame] | 142 | this.outputGroups = outputGroups; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 143 | } |
| 144 | |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 145 | @Nullable |
janakr | 6d185b8 | 2020-03-30 14:08:01 -0700 | [diff] [blame] | 146 | public static OutputGroupInfo get(ProviderCollection collection) { |
| 147 | return collection.get(SKYLARK_CONSTRUCTOR); |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 148 | } |
| 149 | |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 150 | /** Return the artifacts in a particular output group. |
| 151 | * |
| 152 | * @return the artifacts in the output group with the given name. The return value is never null. |
| 153 | * If the specified output group is not present, the empty set is returned. |
| 154 | */ |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 155 | public NestedSet<Artifact> getOutputGroup(String outputGroupName) { |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 156 | return outputGroups.containsKey(outputGroupName) |
| 157 | ? outputGroups.get(outputGroupName) |
| 158 | : NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 159 | } |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 160 | |
| 161 | /** |
| 162 | * Merges output groups from two output providers. The set of output groups must be disjoint. |
| 163 | * |
| 164 | * @param providers providers to merge {@code this} with. |
| 165 | */ |
| 166 | @Nullable |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 167 | public static OutputGroupInfo merge(List<OutputGroupInfo> providers) |
Dmitry Lomov | 9b2fc5c | 2016-11-11 11:18:48 +0000 | [diff] [blame] | 168 | throws DuplicateException { |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 169 | if (providers.size() == 0) { |
| 170 | return null; |
| 171 | } |
| 172 | if (providers.size() == 1) { |
| 173 | return providers.get(0); |
| 174 | } |
| 175 | |
| 176 | ImmutableMap.Builder<String, NestedSet<Artifact>> resultBuilder = new ImmutableMap.Builder<>(); |
| 177 | Set<String> seenGroups = new HashSet<>(); |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 178 | for (OutputGroupInfo provider : providers) { |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 179 | for (String outputGroup : provider.outputGroups.keySet()) { |
| 180 | if (!seenGroups.add(outputGroup)) { |
Dmitry Lomov | 9b2fc5c | 2016-11-11 11:18:48 +0000 | [diff] [blame] | 181 | throw new DuplicateException( |
| 182 | "Output group " + outputGroup + " provided twice"); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | resultBuilder.put(outputGroup, provider.getOutputGroup(outputGroup)); |
| 186 | } |
| 187 | } |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 188 | return new OutputGroupInfo(resultBuilder.build()); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 189 | } |
Alex Humesky | 152feb0 | 2016-06-20 19:43:11 +0000 | [diff] [blame] | 190 | |
ahumesky | 60205bb | 2019-10-14 13:50:00 -0700 | [diff] [blame] | 191 | public static ImmutableSortedSet<String> determineOutputGroups( |
| 192 | List<String> outputGroups, boolean includeValidationOutputGroup) { |
| 193 | return determineOutputGroups(DEFAULT_GROUPS, outputGroups, includeValidationOutputGroup); |
Alex Humesky | 152feb0 | 2016-06-20 19:43:11 +0000 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | public static ImmutableSortedSet<String> determineOutputGroups( |
ahumesky | 60205bb | 2019-10-14 13:50:00 -0700 | [diff] [blame] | 197 | Set<String> defaultOutputGroups, |
| 198 | List<String> outputGroups, |
| 199 | boolean includeValidationOutputGroup) { |
Alex Humesky | 152feb0 | 2016-06-20 19:43:11 +0000 | [diff] [blame] | 200 | |
| 201 | Set<String> current = Sets.newHashSet(); |
| 202 | |
| 203 | // If all of the requested output groups start with "+" or "-", then these are added or |
| 204 | // subtracted to the set of default output groups. |
| 205 | // If any of them don't start with "+" or "-", then the list of requested output groups |
ahumesky | 60205bb | 2019-10-14 13:50:00 -0700 | [diff] [blame] | 206 | // overrides the default set of output groups, except for the validation output group. |
Alex Humesky | 152feb0 | 2016-06-20 19:43:11 +0000 | [diff] [blame] | 207 | boolean addDefaultOutputGroups = true; |
| 208 | for (String outputGroup : outputGroups) { |
| 209 | if (!(outputGroup.startsWith("+") || outputGroup.startsWith("-"))) { |
| 210 | addDefaultOutputGroups = false; |
| 211 | break; |
| 212 | } |
| 213 | } |
| 214 | if (addDefaultOutputGroups) { |
| 215 | current.addAll(defaultOutputGroups); |
| 216 | } |
| 217 | |
| 218 | for (String outputGroup : outputGroups) { |
| 219 | if (outputGroup.startsWith("+")) { |
| 220 | current.add(outputGroup.substring(1)); |
| 221 | } else if (outputGroup.startsWith("-")) { |
| 222 | current.remove(outputGroup.substring(1)); |
| 223 | } else { |
| 224 | current.add(outputGroup); |
| 225 | } |
| 226 | } |
| 227 | |
ahumesky | 60205bb | 2019-10-14 13:50:00 -0700 | [diff] [blame] | 228 | // Add the validation output group regardless of the additions and subtractions above. |
| 229 | if (includeValidationOutputGroup) { |
| 230 | current.add(VALIDATION); |
| 231 | } |
| 232 | |
Alex Humesky | 152feb0 | 2016-06-20 19:43:11 +0000 | [diff] [blame] | 233 | return ImmutableSortedSet.copyOf(current); |
| 234 | } |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 235 | |
| 236 | @Override |
adonovan | 47bf59e | 2020-01-13 14:46:59 -0800 | [diff] [blame] | 237 | public Object getIndex(StarlarkSemantics semantics, Object key) throws EvalException { |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 238 | if (!(key instanceof String)) { |
adonovan | 47bf59e | 2020-01-13 14:46:59 -0800 | [diff] [blame] | 239 | throw Starlark.errorf( |
| 240 | "Output group names must be strings, got %s instead", Starlark.type(key)); |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | NestedSet<Artifact> result = outputGroups.get(key); |
| 244 | if (result != null) { |
Googler | 1a6a5a1 | 2019-11-22 11:54:01 -0800 | [diff] [blame] | 245 | return Depset.of(Artifact.TYPE, result); |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 246 | } else { |
adonovan | 47bf59e | 2020-01-13 14:46:59 -0800 | [diff] [blame] | 247 | throw Starlark.errorf("Output group %s not present", key); |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 248 | } |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | @Override |
adonovan | 47bf59e | 2020-01-13 14:46:59 -0800 | [diff] [blame] | 252 | public boolean containsKey(StarlarkSemantics semantics, Object key) throws EvalException { |
Dmitry Lomov | 8f45b7c | 2016-11-18 15:14:56 +0000 | [diff] [blame] | 253 | return outputGroups.containsKey(key); |
| 254 | } |
| 255 | |
| 256 | @Override |
| 257 | public Iterator<String> iterator() { |
| 258 | return SKYLARK_COMPARATOR.sortedCopy(outputGroups.keySet()).iterator(); |
| 259 | } |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 260 | |
| 261 | @Override |
| 262 | public Object getValue(String name) { |
| 263 | NestedSet<Artifact> result = outputGroups.get(name); |
| 264 | if (result == null) { |
| 265 | return null; |
| 266 | } |
Googler | 1a6a5a1 | 2019-11-22 11:54:01 -0800 | [diff] [blame] | 267 | return Depset.of(Artifact.TYPE, result); |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | @Override |
brandjon | d331fa7 | 2017-12-28 07:38:31 -0800 | [diff] [blame] | 271 | public ImmutableCollection<String> getFieldNames() { |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 272 | return outputGroups.keySet(); |
| 273 | } |
| 274 | |
cparsons | 2d67cf9 | 2018-05-24 14:02:09 -0700 | [diff] [blame] | 275 | /** |
| 276 | * Provider implementation for {@link OutputGroupInfoApi.OutputGroupInfoApiProvider}. |
| 277 | */ |
| 278 | public static class OutputGroupInfoProvider extends BuiltinProvider<OutputGroupInfo> |
| 279 | implements OutputGroupInfoApi.OutputGroupInfoApiProvider { |
| 280 | private OutputGroupInfoProvider() { |
| 281 | super("OutputGroupInfo", OutputGroupInfo.class); |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | @Override |
adonovan | 7891d3b | 2020-01-22 12:40:50 -0800 | [diff] [blame] | 285 | public OutputGroupInfoApi constructor(Dict<?, ?> kwargs) throws EvalException { |
cparsons | 2d67cf9 | 2018-05-24 14:02:09 -0700 | [diff] [blame] | 286 | Map<String, Object> kwargsMap = kwargs.getContents(String.class, Object.class, "kwargs"); |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 287 | |
| 288 | ImmutableMap.Builder<String, NestedSet<Artifact>> builder = ImmutableMap.builder(); |
cparsons | 2d67cf9 | 2018-05-24 14:02:09 -0700 | [diff] [blame] | 289 | for (Map.Entry<String, Object> entry : kwargsMap.entrySet()) { |
vladmos | 97d6708 | 2017-07-13 14:54:03 +0200 | [diff] [blame] | 290 | builder.put( |
| 291 | entry.getKey(), |
| 292 | SkylarkRuleConfiguredTargetUtil.convertToOutputGroupValue( |
adonovan | 7891d3b | 2020-01-22 12:40:50 -0800 | [diff] [blame] | 293 | entry.getKey(), entry.getValue())); |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 294 | } |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 295 | return new OutputGroupInfo(builder.build()); |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 296 | } |
dslomov | f969734 | 2017-05-02 16:26:39 +0200 | [diff] [blame] | 297 | } |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 298 | } |