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 | |
tomlu | f2720dc | 2018-10-02 12:10:51 -0700 | [diff] [blame] | 17 | import static java.util.stream.Collectors.toSet; |
| 18 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [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; |
ulfjack | 0629519 | 2019-01-16 09:13:34 -0800 | [diff] [blame] | 21 | import com.google.common.base.Supplier; |
| 22 | import com.google.common.base.Suppliers; |
Greg Estren | 7883bf1 | 2016-11-18 20:03:43 +0000 | [diff] [blame] | 23 | import com.google.common.collect.ArrayListMultimap; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 24 | import com.google.common.collect.ImmutableList; |
| 25 | import com.google.common.collect.ImmutableMap; |
| 26 | import com.google.common.collect.ImmutableSet; |
Greg Estren | 7883bf1 | 2016-11-18 20:03:43 +0000 | [diff] [blame] | 27 | import com.google.common.collect.Multimap; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 28 | import com.google.common.collect.Sets; |
| 29 | import com.google.common.eventbus.EventBus; |
Rumou Duan | 33bab46 | 2016-04-25 17:55:12 +0000 | [diff] [blame] | 30 | import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 31 | import com.google.devtools.build.lib.actions.ActionGraph; |
janakr | efb3f15 | 2019-06-05 17:42:34 -0700 | [diff] [blame] | 32 | import com.google.devtools.build.lib.actions.ActionLookupData; |
janakr | 93e3eea | 2017-03-30 22:09:37 +0000 | [diff] [blame] | 33 | import com.google.devtools.build.lib.actions.ActionLookupValue; |
janakr | efb3f15 | 2019-06-05 17:42:34 -0700 | [diff] [blame] | 34 | import com.google.devtools.build.lib.actions.Actions; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 35 | import com.google.devtools.build.lib.actions.Artifact; |
| 36 | import com.google.devtools.build.lib.actions.ArtifactFactory; |
janakr | ae32398 | 2017-09-29 21:11:53 +0200 | [diff] [blame] | 37 | import com.google.devtools.build.lib.actions.PackageRoots; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 38 | import com.google.devtools.build.lib.analysis.config.BuildConfiguration; |
| 39 | import com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection; |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 40 | import com.google.devtools.build.lib.analysis.config.BuildOptions; |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 41 | import com.google.devtools.build.lib.analysis.config.ConfigurationResolver.TopLevelTargetsAndConfigsResult; |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 42 | import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; |
gregce | 45ae096 | 2017-07-22 00:11:13 +0200 | [diff] [blame] | 43 | import com.google.devtools.build.lib.analysis.constraints.TopLevelConstraintSemantics; |
ulfjack | ab21d18 | 2017-08-10 15:36:14 +0200 | [diff] [blame] | 44 | import com.google.devtools.build.lib.analysis.test.CoverageReportActionFactory; |
| 45 | import com.google.devtools.build.lib.analysis.test.CoverageReportActionFactory.CoverageReportActionsWrapper; |
cparsons | b83c5f8 | 2018-11-21 14:46:57 -0800 | [diff] [blame] | 46 | import com.google.devtools.build.lib.analysis.test.InstrumentedFilesInfo; |
Lukacs Berki | 6e91eb9 | 2015-09-21 09:12:37 +0000 | [diff] [blame] | 47 | import com.google.devtools.build.lib.cmdline.Label; |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 48 | import com.google.devtools.build.lib.collect.nestedset.NestedSet; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 49 | import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 50 | import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 51 | import com.google.devtools.build.lib.events.Event; |
Klaus Aehlig | 777b30d | 2017-02-24 16:30:15 +0000 | [diff] [blame] | 52 | import com.google.devtools.build.lib.events.ExtendedEventHandler; |
Carmi Grushko | df9e5e1 | 2016-11-08 23:07:57 +0000 | [diff] [blame] | 53 | import com.google.devtools.build.lib.packages.AspectClass; |
Dmitry Lomov | 1575652 | 2016-12-16 16:52:37 +0000 | [diff] [blame] | 54 | import com.google.devtools.build.lib.packages.AspectDescriptor; |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 55 | import com.google.devtools.build.lib.packages.AspectParameters; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 56 | import com.google.devtools.build.lib.packages.Attribute; |
Dmitry Lomov | 8ff0645 | 2015-10-21 19:16:30 +0000 | [diff] [blame] | 57 | import com.google.devtools.build.lib.packages.NativeAspectClass; |
Cal Peyser | 8a638d5 | 2017-03-24 15:44:24 +0000 | [diff] [blame] | 58 | import com.google.devtools.build.lib.packages.NoSuchPackageException; |
| 59 | import com.google.devtools.build.lib.packages.NoSuchTargetException; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 60 | import com.google.devtools.build.lib.packages.Rule; |
| 61 | import com.google.devtools.build.lib.packages.Target; |
| 62 | import com.google.devtools.build.lib.packages.TargetUtils; |
nharmata | c4335cf | 2017-07-18 21:39:13 +0200 | [diff] [blame] | 63 | import com.google.devtools.build.lib.pkgcache.PackageManager.PackageManagerStatistics; |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 64 | import com.google.devtools.build.lib.profiler.Profiler; |
| 65 | import com.google.devtools.build.lib.profiler.SilentCloseable; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 66 | import com.google.devtools.build.lib.skyframe.AspectValue; |
Carmi Grushko | df9e5e1 | 2016-11-08 23:07:57 +0000 | [diff] [blame] | 67 | import com.google.devtools.build.lib.skyframe.AspectValue.AspectKey; |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 68 | import com.google.devtools.build.lib.skyframe.AspectValue.AspectValueKey; |
ulfjack | 0629519 | 2019-01-16 09:13:34 -0800 | [diff] [blame] | 69 | import com.google.devtools.build.lib.skyframe.BuildConfigurationValue; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 70 | import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; |
| 71 | import com.google.devtools.build.lib.skyframe.CoverageReportValue; |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 72 | import com.google.devtools.build.lib.skyframe.PrepareAnalysisPhaseValue; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 73 | import com.google.devtools.build.lib.skyframe.SkyframeAnalysisResult; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 74 | import com.google.devtools.build.lib.skyframe.SkyframeBuildView; |
| 75 | import com.google.devtools.build.lib.skyframe.SkyframeExecutor; |
ulfjack | 12bb59f5 | 2018-07-25 07:19:24 -0700 | [diff] [blame] | 76 | import com.google.devtools.build.lib.skyframe.TargetPatternPhaseValue; |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 77 | import com.google.devtools.build.lib.syntax.SkylarkImport; |
laurentlb | c6c9b8e | 2019-04-15 11:26:26 -0700 | [diff] [blame] | 78 | import com.google.devtools.build.lib.syntax.SkylarkImport.SkylarkImportSyntaxException; |
Klaus Aehlig | c27b4da | 2017-09-01 10:33:22 +0200 | [diff] [blame] | 79 | import com.google.devtools.build.lib.util.Pair; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 80 | import com.google.devtools.build.lib.util.RegexFilter; |
Eric Fellheimer | 9c1e12f | 2015-08-06 20:23:55 +0000 | [diff] [blame] | 81 | import com.google.devtools.build.skyframe.WalkableGraph; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 82 | import java.util.ArrayList; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 83 | import java.util.Collection; |
ulfjack | 0629519 | 2019-01-16 09:13:34 -0800 | [diff] [blame] | 84 | import java.util.HashMap; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 85 | import java.util.HashSet; |
| 86 | import java.util.LinkedHashSet; |
| 87 | import java.util.List; |
ulfjack | 0629519 | 2019-01-16 09:13:34 -0800 | [diff] [blame] | 88 | import java.util.Map; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 89 | import java.util.Set; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 90 | import java.util.logging.Logger; |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 91 | import java.util.stream.Collectors; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 92 | import javax.annotation.Nullable; |
| 93 | |
| 94 | /** |
ulfjack | 865b621 | 2018-06-14 03:41:55 -0700 | [diff] [blame] | 95 | * The BuildView presents a semantically-consistent and transitively-closed |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 96 | * dependency graph for some set of packages. |
| 97 | * |
| 98 | * <h2>Package design</h2> |
| 99 | * |
| 100 | * <p>This package contains the Blaze dependency analysis framework (aka |
| 101 | * "analysis phase"). The goal of this code is to perform semantic analysis of |
| 102 | * all of the build targets required for a given build, to report |
| 103 | * errors/warnings for any problems in the input, and to construct an "action |
| 104 | * graph" (see {@code lib.actions} package) correctly representing the work to |
| 105 | * be done during the execution phase of the build. |
| 106 | * |
| 107 | * <p><b>Configurations</b> the inputs to a build come from two sources: the |
| 108 | * intrinsic inputs, specified in the BUILD file, are called <em>targets</em>. |
| 109 | * The environmental inputs, coming from the build tool, the command-line, or |
| 110 | * configuration files, are called the <em>configuration</em>. Only when a |
| 111 | * target and a configuration are combined is there sufficient information to |
| 112 | * perform a build. </p> |
| 113 | * |
| 114 | * <p>Targets are implemented by the {@link Target} hierarchy in the {@code |
| 115 | * lib.packages} code. Configurations are implemented by {@link |
| 116 | * BuildConfiguration}. The pair of these together is represented by an |
| 117 | * instance of class {@link ConfiguredTarget}; this is the root of a hierarchy |
| 118 | * with different implementations for each kind of target: source file, derived |
| 119 | * file, rules, etc. |
| 120 | * |
| 121 | * <p>The framework code in this package (as opposed to its subpackages) is |
| 122 | * responsible for constructing the {@code ConfiguredTarget} graph for a given |
| 123 | * target and configuration, taking care of such issues as: |
| 124 | * <ul> |
| 125 | * <li>caching common subgraphs. |
| 126 | * <li>detecting and reporting cycles. |
| 127 | * <li>correct propagation of errors through the graph. |
| 128 | * <li>reporting universal errors, such as dependencies from production code |
| 129 | * to tests, or to experimental branches. |
| 130 | * <li>capturing and replaying errors. |
| 131 | * <li>maintaining the graph from one build to the next to |
| 132 | * avoid unnecessary recomputation. |
| 133 | * <li>checking software licenses. |
| 134 | * </ul> |
| 135 | * |
| 136 | * <p>See also {@link ConfiguredTarget} which documents some important |
| 137 | * invariants. |
| 138 | */ |
| 139 | public class BuildView { |
lberki | 998ec92 | 2017-09-05 10:08:25 +0200 | [diff] [blame] | 140 | private static final Logger logger = Logger.getLogger(BuildView.class.getName()); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 141 | |
| 142 | private final BlazeDirectories directories; |
| 143 | |
| 144 | private final SkyframeExecutor skyframeExecutor; |
| 145 | private final SkyframeBuildView skyframeBuildView; |
| 146 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 147 | private final ConfiguredRuleClassProvider ruleClassProvider; |
| 148 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 149 | /** |
| 150 | * A factory class to create the coverage report action. May be null. |
| 151 | */ |
| 152 | @Nullable private final CoverageReportActionFactory coverageReportActionFactory; |
| 153 | |
Ulf Adams | 59dbf68 | 2015-09-17 11:36:43 +0000 | [diff] [blame] | 154 | public BuildView(BlazeDirectories directories, |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 155 | ConfiguredRuleClassProvider ruleClassProvider, |
| 156 | SkyframeExecutor skyframeExecutor, |
Ulf Adams | 5a96d53 | 2015-09-26 09:00:57 +0000 | [diff] [blame] | 157 | CoverageReportActionFactory coverageReportActionFactory) { |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 158 | this.directories = directories; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 159 | this.coverageReportActionFactory = coverageReportActionFactory; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 160 | this.ruleClassProvider = ruleClassProvider; |
| 161 | this.skyframeExecutor = Preconditions.checkNotNull(skyframeExecutor); |
Ulf Adams | 89eefd7 | 2015-09-23 08:00:43 +0000 | [diff] [blame] | 162 | this.skyframeBuildView = skyframeExecutor.getSkyframeBuildView(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 163 | } |
| 164 | |
tomlu | f2720dc | 2018-10-02 12:10:51 -0700 | [diff] [blame] | 165 | /** The number of configured targets freshly evaluated in the last analysis run. */ |
| 166 | public int getTargetsConfigured() { |
ulfjack | 865b621 | 2018-06-14 03:41:55 -0700 | [diff] [blame] | 167 | return skyframeBuildView.getEvaluatedTargetKeys().size(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 168 | } |
| 169 | |
tomlu | f2720dc | 2018-10-02 12:10:51 -0700 | [diff] [blame] | 170 | /** The number of targets (not configured targets) loaded in the last analysis run. */ |
| 171 | public int getTargetsLoaded() { |
| 172 | return skyframeBuildView.getEvaluatedTargetKeys().stream() |
| 173 | .map(key -> ((ConfiguredTargetKey) key).getLabel()) |
| 174 | .collect(toSet()) |
| 175 | .size(); |
| 176 | } |
| 177 | |
tomlu | a0e8aae | 2018-06-19 15:07:26 -0700 | [diff] [blame] | 178 | public int getActionsConstructed() { |
| 179 | return skyframeBuildView.getEvaluatedActionCount(); |
| 180 | } |
| 181 | |
ulfjack | 865b621 | 2018-06-14 03:41:55 -0700 | [diff] [blame] | 182 | public PackageManagerStatistics getAndClearPkgManagerStatistics() { |
| 183 | return skyframeExecutor.getPackageManager().getAndClearStatistics(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 184 | } |
| 185 | |
ulfjack | 865b621 | 2018-06-14 03:41:55 -0700 | [diff] [blame] | 186 | private ArtifactFactory getArtifactFactory() { |
Ulf Adams | 89eefd7 | 2015-09-23 08:00:43 +0000 | [diff] [blame] | 187 | return skyframeBuildView.getArtifactFactory(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 188 | } |
| 189 | |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 190 | /** Returns the collection of configured targets corresponding to any of the provided targets. */ |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 191 | @VisibleForTesting |
mjhalupka | e253f83 | 2018-06-13 14:19:26 -0700 | [diff] [blame] | 192 | static LinkedHashSet<ConfiguredTarget> filterTestsByTargets( |
ulfjack | 12bb59f5 | 2018-07-25 07:19:24 -0700 | [diff] [blame] | 193 | Collection<ConfiguredTarget> targets, Set<Label> allowedTargetLabels) { |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 194 | return targets |
| 195 | .stream() |
mjhalupka | e253f83 | 2018-06-13 14:19:26 -0700 | [diff] [blame] | 196 | .filter(ct -> allowedTargetLabels.contains(ct.getLabel())) |
| 197 | .collect(Collectors.toCollection(LinkedHashSet::new)); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 198 | } |
| 199 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 200 | @ThreadCompatible |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 201 | public AnalysisResult update( |
ulfjack | 12bb59f5 | 2018-07-25 07:19:24 -0700 | [diff] [blame] | 202 | TargetPatternPhaseValue loadingResult, |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 203 | BuildOptions targetOptions, |
| 204 | Set<String> multiCpu, |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 205 | List<String> aspects, |
ulfjack | b5daae3 | 2018-06-13 07:59:33 -0700 | [diff] [blame] | 206 | AnalysisOptions viewOptions, |
juliexxia | 8a2baea | 2017-12-18 14:33:45 -0800 | [diff] [blame] | 207 | boolean keepGoing, |
juliexxia | f8b57c5 | 2017-12-21 11:37:46 -0800 | [diff] [blame] | 208 | int loadingPhaseThreads, |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 209 | TopLevelArtifactContext topLevelOptions, |
Klaus Aehlig | 777b30d | 2017-02-24 16:30:15 +0000 | [diff] [blame] | 210 | ExtendedEventHandler eventHandler, |
Ulf Adams | 8c4ae67 | 2016-03-30 11:20:41 +0000 | [diff] [blame] | 211 | EventBus eventBus) |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 212 | throws ViewCreationFailedException, InvalidConfigurationException, InterruptedException { |
lberki | 998ec92 | 2017-09-05 10:08:25 +0200 | [diff] [blame] | 213 | logger.info("Starting analysis"); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 214 | pollInterruptedStatus(); |
| 215 | |
| 216 | skyframeBuildView.resetEvaluatedConfiguredTargetKeysSet(); |
tomlu | a0e8aae | 2018-06-19 15:07:26 -0700 | [diff] [blame] | 217 | skyframeBuildView.resetEvaluationActionCount(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 218 | |
ulfjack | 12bb59f5 | 2018-07-25 07:19:24 -0700 | [diff] [blame] | 219 | // TODO(ulfjack): Expensive. Maybe we don't actually need the targets, only the labels? |
| 220 | Collection<Target> targets = |
| 221 | loadingResult.getTargets(eventHandler, skyframeExecutor.getPackageManager()); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 222 | eventBus.post(new AnalysisPhaseStartedEvent(targets)); |
| 223 | |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 224 | // Prepare the analysis phase |
| 225 | BuildConfigurationCollection configurations; |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 226 | TopLevelTargetsAndConfigsResult topLevelTargetsWithConfigsResult; |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 227 | if (viewOptions.skyframePrepareAnalysis) { |
| 228 | PrepareAnalysisPhaseValue prepareAnalysisPhaseValue; |
| 229 | try (SilentCloseable c = Profiler.instance().profile("Prepare analysis phase")) { |
| 230 | prepareAnalysisPhaseValue = skyframeExecutor.prepareAnalysisPhase( |
| 231 | eventHandler, targetOptions, multiCpu, loadingResult.getTargetLabels()); |
ulfjack | 0629519 | 2019-01-16 09:13:34 -0800 | [diff] [blame] | 232 | |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 233 | // Determine the configurations |
| 234 | configurations = |
| 235 | prepareAnalysisPhaseValue.getConfigurations(eventHandler, skyframeExecutor); |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 236 | topLevelTargetsWithConfigsResult = |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 237 | prepareAnalysisPhaseValue.getTopLevelCts(eventHandler, skyframeExecutor); |
| 238 | } |
| 239 | } else { |
| 240 | // Configuration creation. |
| 241 | // TODO(gregce): Consider dropping this phase and passing on-the-fly target / host configs as |
| 242 | // needed. This requires cleaning up the invalidation in SkyframeBuildView.setConfigurations. |
| 243 | try (SilentCloseable c = Profiler.instance().profile("createConfigurations")) { |
| 244 | configurations = |
| 245 | skyframeExecutor |
| 246 | .createConfigurations( |
| 247 | eventHandler, |
| 248 | targetOptions, |
| 249 | multiCpu, |
| 250 | keepGoing); |
| 251 | } |
| 252 | try (SilentCloseable c = Profiler.instance().profile("AnalysisUtils.getTargetsWithConfigs")) { |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 253 | topLevelTargetsWithConfigsResult = |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 254 | AnalysisUtils.getTargetsWithConfigs( |
| 255 | configurations, targets, eventHandler, ruleClassProvider, skyframeExecutor); |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
mstaib | 6cf6278 | 2018-11-14 11:54:33 -0800 | [diff] [blame] | 259 | skyframeBuildView.setConfigurations( |
| 260 | eventHandler, configurations, viewOptions.maxConfigChangesToShow); |
Marian Lobur | 86bd4fd | 2015-09-16 10:01:38 +0000 | [diff] [blame] | 261 | |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 262 | if (configurations.getTargetConfigurations().size() == 1) { |
| 263 | eventBus |
| 264 | .post( |
| 265 | new MakeEnvironmentEvent( |
| 266 | configurations.getTargetConfigurations().get(0).getMakeEnvironment())); |
| 267 | } |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 268 | |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 269 | Collection<TargetAndConfiguration> topLevelTargetsWithConfigs = |
| 270 | topLevelTargetsWithConfigsResult.getTargetsAndConfigs(); |
| 271 | |
Klaus Aehlig | 71c993b | 2017-05-09 07:49:46 -0400 | [diff] [blame] | 272 | // Report the generated association of targets to configurations |
| 273 | Multimap<Label, BuildConfiguration> byLabel = |
| 274 | ArrayListMultimap.<Label, BuildConfiguration>create(); |
| 275 | for (TargetAndConfiguration pair : topLevelTargetsWithConfigs) { |
| 276 | byLabel.put(pair.getLabel(), pair.getConfiguration()); |
| 277 | } |
Klaus Aehlig | 2a92c90 | 2017-08-11 14:03:31 +0200 | [diff] [blame] | 278 | for (Target target : targets) { |
| 279 | eventBus.post(new TargetConfiguredEvent(target, byLabel.get(target.getLabel()))); |
Klaus Aehlig | 71c993b | 2017-05-09 07:49:46 -0400 | [diff] [blame] | 280 | } |
| 281 | |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 282 | List<ConfiguredTargetKey> topLevelCtKeys = |
ulfjack | 36fbbde | 2018-08-02 05:16:00 -0700 | [diff] [blame] | 283 | topLevelTargetsWithConfigs |
| 284 | .stream() |
| 285 | .map(node -> ConfiguredTargetKey.of(node.getLabel(), node.getConfiguration())) |
| 286 | .collect(Collectors.toList()); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 287 | |
Klaus Aehlig | c27b4da | 2017-09-01 10:33:22 +0200 | [diff] [blame] | 288 | Multimap<Pair<Label, String>, BuildConfiguration> aspectConfigurations = |
| 289 | ArrayListMultimap.create(); |
Klaus Aehlig | 71c993b | 2017-05-09 07:49:46 -0400 | [diff] [blame] | 290 | |
Dmitry Lomov | c15ba2e | 2015-10-30 15:50:01 +0000 | [diff] [blame] | 291 | List<AspectValueKey> aspectKeys = new ArrayList<>(); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 292 | for (String aspect : aspects) { |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 293 | // Syntax: label%aspect |
| 294 | int delimiterPosition = aspect.indexOf('%'); |
| 295 | if (delimiterPosition >= 0) { |
John Field | a97e17f | 2015-11-13 02:19:52 +0000 | [diff] [blame] | 296 | // TODO(jfield): For consistency with Skylark loads, the aspect should be specified |
laurentlb | 940dbc5 | 2018-03-01 08:07:14 -0800 | [diff] [blame] | 297 | // as an absolute label. |
| 298 | // We convert it for compatibility reasons (this will be removed in the future). |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 299 | String bzlFileLoadLikeString = aspect.substring(0, delimiterPosition); |
| 300 | if (!bzlFileLoadLikeString.startsWith("//") && !bzlFileLoadLikeString.startsWith("@")) { |
| 301 | // "Legacy" behavior of '--aspects' parameter. |
laurentlb | 940dbc5 | 2018-03-01 08:07:14 -0800 | [diff] [blame] | 302 | if (bzlFileLoadLikeString.startsWith("/")) { |
| 303 | bzlFileLoadLikeString = bzlFileLoadLikeString.substring(1); |
| 304 | } |
| 305 | int lastSlashPosition = bzlFileLoadLikeString.lastIndexOf('/'); |
| 306 | if (lastSlashPosition >= 0) { |
| 307 | bzlFileLoadLikeString = |
| 308 | "//" |
| 309 | + bzlFileLoadLikeString.substring(0, lastSlashPosition) |
| 310 | + ":" |
| 311 | + bzlFileLoadLikeString.substring(lastSlashPosition + 1); |
| 312 | } else { |
| 313 | bzlFileLoadLikeString = "//:" + bzlFileLoadLikeString; |
| 314 | } |
| 315 | if (!bzlFileLoadLikeString.endsWith(".bzl")) { |
| 316 | bzlFileLoadLikeString = bzlFileLoadLikeString + ".bzl"; |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 317 | } |
| 318 | } |
| 319 | SkylarkImport skylarkImport; |
| 320 | try { |
dannark | f4b9ff4 | 2018-06-12 09:28:45 -0700 | [diff] [blame] | 321 | skylarkImport = |
laurentlb | c6c9b8e | 2019-04-15 11:26:26 -0700 | [diff] [blame] | 322 | SkylarkImport.create( |
dannark | f4b9ff4 | 2018-06-12 09:28:45 -0700 | [diff] [blame] | 323 | bzlFileLoadLikeString, /* repositoryMapping= */ ImmutableMap.of()); |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 324 | } catch (SkylarkImportSyntaxException e) { |
| 325 | throw new ViewCreationFailedException( |
| 326 | String.format("Invalid aspect '%s': %s", aspect, e.getMessage()), e); |
| 327 | } |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 328 | |
| 329 | String skylarkFunctionName = aspect.substring(delimiterPosition + 1); |
Dmitry Lomov | 01f85c0 | 2016-06-29 06:37:50 +0000 | [diff] [blame] | 330 | for (TargetAndConfiguration targetSpec : topLevelTargetsWithConfigs) { |
mstaib | 7c7a701 | 2019-04-23 16:19:09 -0700 | [diff] [blame] | 331 | if (targetSpec.getConfiguration() != null |
| 332 | && targetSpec.getConfiguration().trimConfigurationsRetroactively()) { |
| 333 | throw new ViewCreationFailedException( |
| 334 | "Aspects were requested, but are not supported in retroactive trimming mode."); |
| 335 | } |
Klaus Aehlig | c27b4da | 2017-09-01 10:33:22 +0200 | [diff] [blame] | 336 | aspectConfigurations.put( |
| 337 | Pair.of(targetSpec.getLabel(), aspect), targetSpec.getConfiguration()); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 338 | aspectKeys.add( |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 339 | AspectValue.createSkylarkAspectKey( |
| 340 | targetSpec.getLabel(), |
Michael Staib | 04f6f24 | 2016-03-01 15:40:29 +0000 | [diff] [blame] | 341 | // For invoking top-level aspects, use the top-level configuration for both the |
| 342 | // aspect and the base target while the top-level configuration is untrimmed. |
| 343 | targetSpec.getConfiguration(), |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 344 | targetSpec.getConfiguration(), |
Dmitry Lomov | 51aafc1 | 2016-11-18 14:02:54 +0000 | [diff] [blame] | 345 | skylarkImport, |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 346 | skylarkFunctionName)); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 347 | } |
| 348 | } else { |
Luis Fernando Pino Duque | e82713d | 2016-04-26 16:22:38 +0000 | [diff] [blame] | 349 | final NativeAspectClass aspectFactoryClass = |
| 350 | ruleClassProvider.getNativeAspectClassMap().get(aspect); |
dslomov | 99ea6b4 | 2017-04-25 17:46:17 +0200 | [diff] [blame] | 351 | |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 352 | if (aspectFactoryClass != null) { |
Dmitry Lomov | 01f85c0 | 2016-06-29 06:37:50 +0000 | [diff] [blame] | 353 | for (TargetAndConfiguration targetSpec : topLevelTargetsWithConfigs) { |
mstaib | 7c7a701 | 2019-04-23 16:19:09 -0700 | [diff] [blame] | 354 | if (targetSpec.getConfiguration() != null |
| 355 | && targetSpec.getConfiguration().trimConfigurationsRetroactively()) { |
| 356 | throw new ViewCreationFailedException( |
| 357 | "Aspects were requested, but are not supported in retroactive trimming mode."); |
| 358 | } |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 359 | // For invoking top-level aspects, use the top-level configuration for both the |
| 360 | // aspect and the base target while the top-level configuration is untrimmed. |
| 361 | BuildConfiguration configuration = targetSpec.getConfiguration(); |
Klaus Aehlig | c27b4da | 2017-09-01 10:33:22 +0200 | [diff] [blame] | 362 | aspectConfigurations.put(Pair.of(targetSpec.getLabel(), aspect), configuration); |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 363 | aspectKeys.add( |
| 364 | AspectValue.createAspectKey( |
Dmitry Lomov | 8ff0645 | 2015-10-21 19:16:30 +0000 | [diff] [blame] | 365 | targetSpec.getLabel(), |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 366 | configuration, |
dslomov | fa50c3d | 2017-05-08 08:47:44 -0400 | [diff] [blame] | 367 | new AspectDescriptor(aspectFactoryClass, AspectParameters.EMPTY), |
Dmitry Lomov | ca9bfa4 | 2016-11-15 13:22:36 +0000 | [diff] [blame] | 368 | configuration |
| 369 | )); |
Dmitry Lomov | 0b832ce | 2015-10-20 10:03:14 +0000 | [diff] [blame] | 370 | } |
| 371 | } else { |
| 372 | throw new ViewCreationFailedException("Aspect '" + aspect + "' is unknown"); |
| 373 | } |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 374 | } |
| 375 | } |
| 376 | |
Klaus Aehlig | c27b4da | 2017-09-01 10:33:22 +0200 | [diff] [blame] | 377 | for (Pair<Label, String> target : aspectConfigurations.keys()) { |
| 378 | eventBus.post( |
| 379 | new AspectConfiguredEvent( |
| 380 | target.getFirst(), target.getSecond(), aspectConfigurations.get(target))); |
| 381 | } |
| 382 | |
janakr | 1f08d4c8 | 2018-09-15 16:33:35 -0700 | [diff] [blame] | 383 | getArtifactFactory().noteAnalysisStarting(); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 384 | SkyframeAnalysisResult skyframeAnalysisResult; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 385 | try { |
ulfjack | 0629519 | 2019-01-16 09:13:34 -0800 | [diff] [blame] | 386 | Supplier<Map<BuildConfigurationValue.Key, BuildConfiguration>> configurationLookupSupplier = |
| 387 | () -> { |
| 388 | Map<BuildConfigurationValue.Key, BuildConfiguration> result = new HashMap<>(); |
| 389 | for (TargetAndConfiguration node : topLevelTargetsWithConfigs) { |
| 390 | if (node.getConfiguration() != null) { |
| 391 | result.put( |
| 392 | BuildConfigurationValue.key(node.getConfiguration()), node.getConfiguration()); |
| 393 | } |
| 394 | } |
| 395 | return result; |
| 396 | }; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 397 | skyframeAnalysisResult = |
| 398 | skyframeBuildView.configureTargets( |
ulfjack | 0629519 | 2019-01-16 09:13:34 -0800 | [diff] [blame] | 399 | eventHandler, |
| 400 | topLevelCtKeys, |
| 401 | aspectKeys, |
| 402 | Suppliers.memoize(configurationLookupSupplier), |
| 403 | eventBus, |
| 404 | keepGoing, |
| 405 | loadingPhaseThreads); |
Kristina Chodorow | 94e2742 | 2016-08-25 14:17:30 +0000 | [diff] [blame] | 406 | setArtifactRoots(skyframeAnalysisResult.getPackageRoots()); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 407 | } finally { |
| 408 | skyframeBuildView.clearInvalidatedConfiguredTargets(); |
| 409 | } |
| 410 | |
Greg Estren | 7971e67 | 2016-06-01 23:22:48 +0000 | [diff] [blame] | 411 | int numTargetsToAnalyze = topLevelTargetsWithConfigs.size(); |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 412 | int numSuccessful = skyframeAnalysisResult.getConfiguredTargets().size(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 413 | if (0 < numSuccessful && numSuccessful < numTargetsToAnalyze) { |
| 414 | String msg = String.format("Analysis succeeded for only %d of %d top-level targets", |
| 415 | numSuccessful, numTargetsToAnalyze); |
| 416 | eventHandler.handle(Event.info(msg)); |
lberki | 998ec92 | 2017-09-05 10:08:25 +0200 | [diff] [blame] | 417 | logger.info(msg); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 418 | } |
| 419 | |
gregce | 45ae096 | 2017-07-22 00:11:13 +0200 | [diff] [blame] | 420 | Set<ConfiguredTarget> targetsToSkip = |
janakr | 171a7eb | 2018-03-26 09:26:53 -0700 | [diff] [blame] | 421 | new TopLevelConstraintSemantics( |
| 422 | skyframeExecutor.getPackageManager(), |
| 423 | input -> skyframeExecutor.getConfiguration(eventHandler, input), |
| 424 | eventHandler) |
gregce | 21fdc48 | 2017-12-05 16:10:47 -0800 | [diff] [blame] | 425 | .checkTargetEnvironmentRestrictions(skyframeAnalysisResult.getConfiguredTargets()); |
gregce | 45ae096 | 2017-07-22 00:11:13 +0200 | [diff] [blame] | 426 | |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 427 | AnalysisResult result = |
| 428 | createResult( |
Ulf Adams | 5b9009b | 2015-09-24 09:52:53 +0000 | [diff] [blame] | 429 | eventHandler, |
ulfjack | b2cb640 | 2019-01-24 04:04:48 -0800 | [diff] [blame] | 430 | eventBus, |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 431 | loadingResult, |
ulfjack | 940fbd7 | 2018-06-15 03:23:58 -0700 | [diff] [blame] | 432 | configurations, |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 433 | topLevelOptions, |
| 434 | viewOptions, |
gregce | 45ae096 | 2017-07-22 00:11:13 +0200 | [diff] [blame] | 435 | skyframeAnalysisResult, |
juliexxia | 693abdc | 2018-01-03 08:59:18 -0800 | [diff] [blame] | 436 | targetsToSkip, |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 437 | topLevelTargetsWithConfigsResult); |
lberki | 998ec92 | 2017-09-05 10:08:25 +0200 | [diff] [blame] | 438 | logger.info("Finished analysis"); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 439 | return result; |
| 440 | } |
| 441 | |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 442 | private AnalysisResult createResult( |
Klaus Aehlig | 777b30d | 2017-02-24 16:30:15 +0000 | [diff] [blame] | 443 | ExtendedEventHandler eventHandler, |
ulfjack | b2cb640 | 2019-01-24 04:04:48 -0800 | [diff] [blame] | 444 | EventBus eventBus, |
ulfjack | 12bb59f5 | 2018-07-25 07:19:24 -0700 | [diff] [blame] | 445 | TargetPatternPhaseValue loadingResult, |
ulfjack | 940fbd7 | 2018-06-15 03:23:58 -0700 | [diff] [blame] | 446 | BuildConfigurationCollection configurations, |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 447 | TopLevelArtifactContext topLevelOptions, |
ulfjack | b5daae3 | 2018-06-13 07:59:33 -0700 | [diff] [blame] | 448 | AnalysisOptions viewOptions, |
gregce | 45ae096 | 2017-07-22 00:11:13 +0200 | [diff] [blame] | 449 | SkyframeAnalysisResult skyframeAnalysisResult, |
juliexxia | 693abdc | 2018-01-03 08:59:18 -0800 | [diff] [blame] | 450 | Set<ConfiguredTarget> targetsToSkip, |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 451 | TopLevelTargetsAndConfigsResult topLevelTargetsWithConfigs) |
Klaus Aehlig | 777b30d | 2017-02-24 16:30:15 +0000 | [diff] [blame] | 452 | throws InterruptedException { |
ulfjack | 12bb59f5 | 2018-07-25 07:19:24 -0700 | [diff] [blame] | 453 | Set<Label> testsToRun = loadingResult.getTestsToRunLabels(); |
gregce | 45ae096 | 2017-07-22 00:11:13 +0200 | [diff] [blame] | 454 | Set<ConfiguredTarget> configuredTargets = |
| 455 | Sets.newLinkedHashSet(skyframeAnalysisResult.getConfiguredTargets()); |
Googler | 9204499 | 2018-03-14 14:26:30 -0700 | [diff] [blame] | 456 | ImmutableSet<AspectValue> aspects = ImmutableSet.copyOf(skyframeAnalysisResult.getAspects()); |
Dmitry Lomov | cf6021a | 2016-08-09 16:49:32 +0000 | [diff] [blame] | 457 | |
gregce | 45ae096 | 2017-07-22 00:11:13 +0200 | [diff] [blame] | 458 | Set<ConfiguredTarget> allTargetsToTest = null; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 459 | if (testsToRun != null) { |
| 460 | // Determine the subset of configured targets that are meant to be run as tests. |
mjhalupka | e253f83 | 2018-06-13 14:19:26 -0700 | [diff] [blame] | 461 | allTargetsToTest = filterTestsByTargets(configuredTargets, testsToRun); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 462 | } |
| 463 | |
janakr | ccb7456 | 2018-07-30 10:56:57 -0700 | [diff] [blame] | 464 | ArtifactsToOwnerLabels.Builder artifactsToOwnerLabelsBuilder = |
| 465 | new ArtifactsToOwnerLabels.Builder(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 466 | Set<ConfiguredTarget> parallelTests = new HashSet<>(); |
| 467 | Set<ConfiguredTarget> exclusiveTests = new HashSet<>(); |
Ulf Adams | fc154ae | 2015-08-31 12:32:14 +0000 | [diff] [blame] | 468 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 469 | // build-info and build-changelist. |
Ulf Adams | 5b9009b | 2015-09-24 09:52:53 +0000 | [diff] [blame] | 470 | Collection<Artifact> buildInfoArtifacts = |
| 471 | skyframeExecutor.getWorkspaceStatusArtifacts(eventHandler); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 472 | Preconditions.checkState(buildInfoArtifacts.size() == 2, buildInfoArtifacts); |
janakr | ccb7456 | 2018-07-30 10:56:57 -0700 | [diff] [blame] | 473 | buildInfoArtifacts.forEach(artifactsToOwnerLabelsBuilder::addArtifact); |
Ulf Adams | fc154ae | 2015-08-31 12:32:14 +0000 | [diff] [blame] | 474 | |
| 475 | // Extra actions |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 476 | addExtraActionsIfRequested( |
janakr | ccb7456 | 2018-07-30 10:56:57 -0700 | [diff] [blame] | 477 | viewOptions, configuredTargets, aspects, artifactsToOwnerLabelsBuilder, eventHandler); |
Ulf Adams | fc154ae | 2015-08-31 12:32:14 +0000 | [diff] [blame] | 478 | |
| 479 | // Coverage |
janakr | 75bc18a | 2018-07-13 00:52:17 -0700 | [diff] [blame] | 480 | NestedSet<Artifact> baselineCoverageArtifacts = |
janakr | ccb7456 | 2018-07-30 10:56:57 -0700 | [diff] [blame] | 481 | getBaselineCoverageArtifacts(configuredTargets, artifactsToOwnerLabelsBuilder); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 482 | if (coverageReportActionFactory != null) { |
Googler | cdc90e9 | 2015-02-11 00:18:07 +0000 | [diff] [blame] | 483 | CoverageReportActionsWrapper actionsWrapper; |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 484 | actionsWrapper = |
| 485 | coverageReportActionFactory.createCoverageReportActionsWrapper( |
| 486 | eventHandler, |
ulfjack | b2cb640 | 2019-01-24 04:04:48 -0800 | [diff] [blame] | 487 | eventBus, |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 488 | directories, |
| 489 | allTargetsToTest, |
| 490 | baselineCoverageArtifacts, |
| 491 | getArtifactFactory(), |
janakr | efb3f15 | 2019-06-05 17:42:34 -0700 | [diff] [blame] | 492 | skyframeExecutor.getActionKeyContext(), |
elenairina | 9438d10 | 2018-07-06 03:06:21 -0700 | [diff] [blame] | 493 | CoverageReportValue.COVERAGE_REPORT_KEY, |
| 494 | loadingResult.getWorkspaceName()); |
Googler | cdc90e9 | 2015-02-11 00:18:07 +0000 | [diff] [blame] | 495 | if (actionsWrapper != null) { |
janakr | efb3f15 | 2019-06-05 17:42:34 -0700 | [diff] [blame] | 496 | Actions.GeneratingActions actions = actionsWrapper.getActions(); |
Googler | cdc90e9 | 2015-02-11 00:18:07 +0000 | [diff] [blame] | 497 | skyframeExecutor.injectCoverageReportData(actions); |
janakr | ccb7456 | 2018-07-30 10:56:57 -0700 | [diff] [blame] | 498 | actionsWrapper.getCoverageOutputs().forEach(artifactsToOwnerLabelsBuilder::addArtifact); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 499 | } |
| 500 | } |
| 501 | |
Ulf Adams | fc154ae | 2015-08-31 12:32:14 +0000 | [diff] [blame] | 502 | // Tests. This must come last, so that the exclusive tests are scheduled after everything else. |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 503 | scheduleTestsIfRequested( |
| 504 | parallelTests, |
| 505 | exclusiveTests, |
| 506 | topLevelOptions, |
| 507 | allTargetsToTest, |
| 508 | skyframeExecutor, |
| 509 | eventHandler); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 510 | |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 511 | String error = |
| 512 | createErrorMessage(loadingResult, skyframeAnalysisResult, topLevelTargetsWithConfigs); |
Eric Fellheimer | 9c1e12f | 2015-08-06 20:23:55 +0000 | [diff] [blame] | 513 | |
Ulf Adams | 53abece | 2016-02-03 08:30:07 +0000 | [diff] [blame] | 514 | final WalkableGraph graph = skyframeAnalysisResult.getWalkableGraph(); |
Janak Ramakrishnan | 3c0adb2 | 2016-08-15 21:54:55 +0000 | [diff] [blame] | 515 | final ActionGraph actionGraph = |
| 516 | new ActionGraph() { |
| 517 | @Nullable |
| 518 | @Override |
| 519 | public ActionAnalysisMetadata getGeneratingAction(Artifact artifact) { |
janakr | efb3f15 | 2019-06-05 17:42:34 -0700 | [diff] [blame] | 520 | if (artifact.isSourceArtifact()) { |
| 521 | return null; |
Janak Ramakrishnan | 3c0adb2 | 2016-08-15 21:54:55 +0000 | [diff] [blame] | 522 | } |
janakr | efb3f15 | 2019-06-05 17:42:34 -0700 | [diff] [blame] | 523 | ActionLookupData generatingActionKey = |
| 524 | ((Artifact.DerivedArtifact) artifact).getGeneratingActionKey(); |
| 525 | ActionLookupValue val; |
| 526 | try { |
| 527 | val = (ActionLookupValue) graph.getValue(generatingActionKey.getActionLookupKey()); |
| 528 | } catch (InterruptedException e) { |
| 529 | throw new IllegalStateException( |
| 530 | "Interruption not expected from this graph: " + generatingActionKey, e); |
| 531 | } |
| 532 | if (val == null) { |
| 533 | return null; |
| 534 | } |
| 535 | int actionIndex = generatingActionKey.getActionIndex(); |
| 536 | return val.isActionTemplate(actionIndex) |
| 537 | ? val.getActionTemplate(actionIndex) |
| 538 | : val.getAction(actionIndex); |
Janak Ramakrishnan | 3c0adb2 | 2016-08-15 21:54:55 +0000 | [diff] [blame] | 539 | } |
| 540 | }; |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 541 | return new AnalysisResult( |
ulfjack | 940fbd7 | 2018-06-15 03:23:58 -0700 | [diff] [blame] | 542 | configurations, |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 543 | configuredTargets, |
Dmitry Lomov | cf6021a | 2016-08-09 16:49:32 +0000 | [diff] [blame] | 544 | aspects, |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 545 | allTargetsToTest, |
gregce | 45ae096 | 2017-07-22 00:11:13 +0200 | [diff] [blame] | 546 | targetsToSkip, |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 547 | error, |
| 548 | actionGraph, |
janakr | ccb7456 | 2018-07-30 10:56:57 -0700 | [diff] [blame] | 549 | artifactsToOwnerLabelsBuilder.build(), |
Dmitry Lomov | e2033b1 | 2015-08-19 16:57:49 +0000 | [diff] [blame] | 550 | parallelTests, |
| 551 | exclusiveTests, |
Marian Lobur | 86bd4fd | 2015-09-16 10:01:38 +0000 | [diff] [blame] | 552 | topLevelOptions, |
Kristina Chodorow | 36a6c17 | 2016-07-22 15:18:07 +0000 | [diff] [blame] | 553 | skyframeAnalysisResult.getPackageRoots(), |
juliexxia | 693abdc | 2018-01-03 08:59:18 -0800 | [diff] [blame] | 554 | loadingResult.getWorkspaceName(), |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 555 | topLevelTargetsWithConfigs.getTargetsAndConfigs()); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 556 | } |
| 557 | |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 558 | /** |
| 559 | * Check for errors in "chronological" order (acknowledge that loading and analysis are |
| 560 | * interleaved, but sequential on the single target scale). |
| 561 | */ |
Janak Ramakrishnan | 6f9d7d1 | 2016-08-09 08:45:34 +0000 | [diff] [blame] | 562 | @Nullable |
| 563 | public static String createErrorMessage( |
ulfjack | 12bb59f5 | 2018-07-25 07:19:24 -0700 | [diff] [blame] | 564 | TargetPatternPhaseValue loadingResult, |
juliexxia | b75e4530 | 2019-05-24 07:48:39 -0700 | [diff] [blame] | 565 | @Nullable SkyframeAnalysisResult skyframeAnalysisResult, |
| 566 | @Nullable TopLevelTargetsAndConfigsResult topLevelTargetsAndConfigs) { |
| 567 | if (loadingResult.hasError()) { |
| 568 | return "command succeeded, but there were errors parsing the target pattern"; |
| 569 | } |
| 570 | if (loadingResult.hasPostExpansionError() |
| 571 | || (skyframeAnalysisResult != null && skyframeAnalysisResult.hasLoadingError())) { |
| 572 | return "command succeeded, but there were loading phase errors"; |
| 573 | } |
| 574 | if (topLevelTargetsAndConfigs != null && topLevelTargetsAndConfigs.hasError()) { |
| 575 | return "command succeeded, but top level configurations could not be created"; |
| 576 | } |
| 577 | if (skyframeAnalysisResult != null && skyframeAnalysisResult.hasAnalysisError()) { |
| 578 | return "command succeeded, but not all targets were analyzed"; |
| 579 | } |
| 580 | return null; |
Janak Ramakrishnan | 6f9d7d1 | 2016-08-09 08:45:34 +0000 | [diff] [blame] | 581 | } |
| 582 | |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 583 | private static NestedSet<Artifact> getBaselineCoverageArtifacts( |
janakr | 75bc18a | 2018-07-13 00:52:17 -0700 | [diff] [blame] | 584 | Collection<ConfiguredTarget> configuredTargets, |
janakr | ccb7456 | 2018-07-30 10:56:57 -0700 | [diff] [blame] | 585 | ArtifactsToOwnerLabels.Builder topLevelArtifactsToOwnerLabels) { |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 586 | NestedSetBuilder<Artifact> baselineCoverageArtifacts = NestedSetBuilder.stableOrder(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 587 | for (ConfiguredTarget target : configuredTargets) { |
cparsons | b83c5f8 | 2018-11-21 14:46:57 -0800 | [diff] [blame] | 588 | InstrumentedFilesInfo provider = target.get(InstrumentedFilesInfo.SKYLARK_CONSTRUCTOR); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 589 | if (provider != null) { |
janakr | 75bc18a | 2018-07-13 00:52:17 -0700 | [diff] [blame] | 590 | TopLevelArtifactHelper.addArtifactsWithOwnerLabel( |
| 591 | provider.getBaselineCoverageArtifacts(), |
| 592 | null, |
| 593 | target.getLabel(), |
| 594 | topLevelArtifactsToOwnerLabels); |
Ulf Adams | fc154ae | 2015-08-31 12:32:14 +0000 | [diff] [blame] | 595 | baselineCoverageArtifacts.addTransitive(provider.getBaselineCoverageArtifacts()); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 596 | } |
| 597 | } |
Lukacs Berki | 6916be2 | 2015-02-19 13:36:06 +0000 | [diff] [blame] | 598 | return baselineCoverageArtifacts.build(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 599 | } |
| 600 | |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 601 | private void addExtraActionsIfRequested( |
ulfjack | b5daae3 | 2018-06-13 07:59:33 -0700 | [diff] [blame] | 602 | AnalysisOptions viewOptions, |
Dmitry Lomov | cf6021a | 2016-08-09 16:49:32 +0000 | [diff] [blame] | 603 | Collection<ConfiguredTarget> configuredTargets, |
| 604 | Collection<AspectValue> aspects, |
janakr | ccb7456 | 2018-07-30 10:56:57 -0700 | [diff] [blame] | 605 | ArtifactsToOwnerLabels.Builder artifactsToTopLevelLabelsMap, |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 606 | ExtendedEventHandler eventHandler) { |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 607 | RegexFilter filter = viewOptions.extraActionFilter; |
Carmi Grushko | df9e5e1 | 2016-11-08 23:07:57 +0000 | [diff] [blame] | 608 | for (ConfiguredTarget target : configuredTargets) { |
| 609 | ExtraActionArtifactsProvider provider = |
| 610 | target.getProvider(ExtraActionArtifactsProvider.class); |
| 611 | if (provider != null) { |
| 612 | if (viewOptions.extraActionTopLevelOnly) { |
lberki | 9137a75 | 2017-06-09 12:49:10 +0200 | [diff] [blame] | 613 | // Collect all aspect-classes that topLevel might inject. |
| 614 | Set<AspectClass> aspectClasses = new HashSet<>(); |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 615 | Target actualTarget = null; |
| 616 | try { |
| 617 | actualTarget = |
| 618 | skyframeExecutor.getPackageManager().getTarget(eventHandler, target.getLabel()); |
| 619 | } catch (NoSuchPackageException | NoSuchTargetException | InterruptedException e) { |
| 620 | eventHandler.handle(Event.error("")); |
| 621 | } |
| 622 | for (Attribute attr : actualTarget.getAssociatedRule().getAttributes()) { |
lberki | 9137a75 | 2017-06-09 12:49:10 +0200 | [diff] [blame] | 623 | aspectClasses.addAll(attr.getAspectClasses()); |
| 624 | } |
janakr | 75bc18a | 2018-07-13 00:52:17 -0700 | [diff] [blame] | 625 | TopLevelArtifactHelper.addArtifactsWithOwnerLabel( |
| 626 | provider.getExtraActionArtifacts(), |
| 627 | filter, |
| 628 | target.getLabel(), |
| 629 | artifactsToTopLevelLabelsMap); |
lberki | 9137a75 | 2017-06-09 12:49:10 +0200 | [diff] [blame] | 630 | if (!aspectClasses.isEmpty()) { |
janakr | 75bc18a | 2018-07-13 00:52:17 -0700 | [diff] [blame] | 631 | TopLevelArtifactHelper.addArtifactsWithOwnerLabel( |
| 632 | filterTransitiveExtraActions(provider, aspectClasses), |
| 633 | filter, |
| 634 | target.getLabel(), |
| 635 | artifactsToTopLevelLabelsMap); |
Carmi Grushko | df9e5e1 | 2016-11-08 23:07:57 +0000 | [diff] [blame] | 636 | } |
Carmi Grushko | df9e5e1 | 2016-11-08 23:07:57 +0000 | [diff] [blame] | 637 | } else { |
janakr | 75bc18a | 2018-07-13 00:52:17 -0700 | [diff] [blame] | 638 | TopLevelArtifactHelper.addArtifactsWithOwnerLabel( |
| 639 | provider.getTransitiveExtraActionArtifacts(), |
| 640 | filter, |
| 641 | target.getLabel(), |
| 642 | artifactsToTopLevelLabelsMap); |
Carmi Grushko | df9e5e1 | 2016-11-08 23:07:57 +0000 | [diff] [blame] | 643 | } |
| 644 | } |
| 645 | } |
janakr | 75bc18a | 2018-07-13 00:52:17 -0700 | [diff] [blame] | 646 | for (AspectValue aspect : aspects) { |
| 647 | ExtraActionArtifactsProvider provider = |
| 648 | aspect.getConfiguredAspect().getProvider(ExtraActionArtifactsProvider.class); |
| 649 | if (provider != null) { |
| 650 | if (viewOptions.extraActionTopLevelOnly) { |
| 651 | TopLevelArtifactHelper.addArtifactsWithOwnerLabel( |
| 652 | provider.getExtraActionArtifacts(), |
| 653 | filter, |
| 654 | aspect.getLabel(), |
| 655 | artifactsToTopLevelLabelsMap); |
| 656 | } else { |
| 657 | TopLevelArtifactHelper.addArtifactsWithOwnerLabel( |
| 658 | provider.getTransitiveExtraActionArtifacts(), |
| 659 | filter, |
| 660 | aspect.getLabel(), |
| 661 | artifactsToTopLevelLabelsMap); |
| 662 | } |
| 663 | } |
| 664 | } |
Carmi Grushko | df9e5e1 | 2016-11-08 23:07:57 +0000 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | /** |
janakr | 658d47f | 2019-05-29 11:11:30 -0700 | [diff] [blame] | 668 | * Returns a list of artifacts from 'provider' that were registered by an aspect from |
| 669 | * 'aspectClasses'. All artifacts in 'provider' are considered - both direct and transitive. |
Carmi Grushko | df9e5e1 | 2016-11-08 23:07:57 +0000 | [diff] [blame] | 670 | */ |
| 671 | private ImmutableList<Artifact> filterTransitiveExtraActions( |
| 672 | ExtraActionArtifactsProvider provider, Set<AspectClass> aspectClasses) { |
| 673 | ImmutableList.Builder<Artifact> artifacts = ImmutableList.builder(); |
| 674 | // Add to 'artifacts' all extra-actions which were registered by aspects which 'topLevel' |
| 675 | // might have injected. |
janakr | efb3f15 | 2019-06-05 17:42:34 -0700 | [diff] [blame] | 676 | for (Artifact.DerivedArtifact artifact : provider.getTransitiveExtraActionArtifacts()) { |
| 677 | ActionLookupValue.ActionLookupKey owner = artifact.getArtifactOwner(); |
Carmi Grushko | babd485 | 2016-11-18 17:58:09 +0000 | [diff] [blame] | 678 | if (owner instanceof AspectKey) { |
| 679 | if (aspectClasses.contains(((AspectKey) owner).getAspectClass())) { |
| 680 | artifacts.add(artifact); |
Carmi Grushko | df9e5e1 | 2016-11-08 23:07:57 +0000 | [diff] [blame] | 681 | } |
| 682 | } |
| 683 | } |
| 684 | return artifacts.build(); |
| 685 | } |
| 686 | |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 687 | private static void scheduleTestsIfRequested( |
| 688 | Collection<ConfiguredTarget> targetsToTest, |
| 689 | Collection<ConfiguredTarget> targetsToTestExclusive, |
| 690 | TopLevelArtifactContext topLevelOptions, |
| 691 | Collection<ConfiguredTarget> allTestTargets, |
| 692 | SkyframeExecutor skyframeExecutor, |
| 693 | ExtendedEventHandler eventHandler) |
| 694 | throws InterruptedException { |
Lukacs Berki | 3f4d4e9 | 2015-02-24 10:28:26 +0000 | [diff] [blame] | 695 | Set<String> outputGroups = topLevelOptions.outputGroups(); |
dslomov | 69c45f8 | 2017-12-14 11:15:43 -0500 | [diff] [blame] | 696 | if (!outputGroups.contains(OutputGroupInfo.FILES_TO_COMPILE) |
| 697 | && !outputGroups.contains(OutputGroupInfo.COMPILATION_PREREQUISITES) |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 698 | && allTestTargets != null) { |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 699 | scheduleTests( |
| 700 | targetsToTest, |
| 701 | targetsToTestExclusive, |
| 702 | allTestTargets, |
| 703 | topLevelOptions.runTestsExclusively(), |
| 704 | skyframeExecutor, |
| 705 | eventHandler); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 706 | } |
| 707 | } |
| 708 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 709 | /** |
| 710 | * Returns set of artifacts representing test results, writing into targetsToTest and |
| 711 | * targetsToTestExclusive. |
| 712 | */ |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 713 | private static void scheduleTests( |
| 714 | Collection<ConfiguredTarget> targetsToTest, |
| 715 | Collection<ConfiguredTarget> targetsToTestExclusive, |
| 716 | Collection<ConfiguredTarget> allTestTargets, |
| 717 | boolean isExclusive, |
| 718 | SkyframeExecutor skyframeExecutor, |
| 719 | ExtendedEventHandler eventHandler) |
| 720 | throws InterruptedException { |
| 721 | for (ConfiguredTarget configuredTarget : allTestTargets) { |
| 722 | Target target = null; |
| 723 | try { |
| 724 | target = |
| 725 | skyframeExecutor |
| 726 | .getPackageManager() |
| 727 | .getTarget(eventHandler, configuredTarget.getLabel()); |
| 728 | } catch (NoSuchTargetException | NoSuchPackageException e) { |
| 729 | eventHandler.handle(Event.error("Failed to get target when scheduling tests")); |
| 730 | continue; |
| 731 | } |
| 732 | if (target instanceof Rule) { |
| 733 | boolean exclusive = isExclusive || TargetUtils.isExclusiveTestRule((Rule) target); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 734 | Collection<ConfiguredTarget> testCollection = exclusive |
| 735 | ? targetsToTestExclusive |
| 736 | : targetsToTest; |
mjhalupka | 7675dbd | 2018-01-29 12:46:58 -0800 | [diff] [blame] | 737 | testCollection.add(configuredTarget); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 738 | } |
| 739 | } |
| 740 | } |
| 741 | |
Greg Estren | 7971e67 | 2016-06-01 23:22:48 +0000 | [diff] [blame] | 742 | /** |
Ulf Adams | a385d3e | 2015-09-28 13:21:45 +0000 | [diff] [blame] | 743 | * Sets the possible artifact roots in the artifact factory. This allows the factory to resolve |
| 744 | * paths with unknown roots to artifacts. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 745 | */ |
ulfjack | 865b621 | 2018-06-14 03:41:55 -0700 | [diff] [blame] | 746 | private void setArtifactRoots(PackageRoots packageRoots) { |
janakr | ae32398 | 2017-09-29 21:11:53 +0200 | [diff] [blame] | 747 | getArtifactFactory().setPackageRoots(packageRoots.getPackageRootLookup()); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | /** |
Ulf Adams | 9c505cb | 2015-09-28 13:38:14 +0000 | [diff] [blame] | 751 | * Tests and clears the current thread's pending "interrupted" status, and |
| 752 | * throws InterruptedException iff it was set. |
| 753 | */ |
ulfjack | 865b621 | 2018-06-14 03:41:55 -0700 | [diff] [blame] | 754 | private final void pollInterruptedStatus() throws InterruptedException { |
Ulf Adams | 9c505cb | 2015-09-28 13:38:14 +0000 | [diff] [blame] | 755 | if (Thread.interrupted()) { |
| 756 | throw new InterruptedException(); |
| 757 | } |
| 758 | } |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 759 | } |