blob: 46e7d4b3cf602386d153c08e88f2d7db983ce6a7 [file] [log] [blame]
cparsonse2d200f2018-03-06 16:15:11 -08001// Copyright 2018 The Bazel Authors. All rights reserved.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01002//
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.
cparsonse2d200f2018-03-06 16:15:11 -080014
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010015package com.google.devtools.build.lib.skyframe;
16
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010017import com.google.common.collect.ImmutableList;
cparsonse2d200f2018-03-06 16:15:11 -080018import com.google.devtools.build.lib.actions.Action;
Rumou Duan33bab462016-04-25 17:55:12 +000019import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010020import com.google.devtools.build.lib.analysis.ConfiguredTarget;
21import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
Lukacs Berki6e91eb92015-09-21 09:12:37 +000022import com.google.devtools.build.lib.cmdline.Label;
Marian Loburc62faba2015-09-09 10:08:06 +000023import com.google.devtools.build.lib.collect.nestedset.NestedSet;
Marian Loburc62faba2015-09-09 10:08:06 +000024import com.google.devtools.build.lib.packages.Package;
janakra86c2672018-06-18 09:04:43 -070025import com.google.devtools.build.skyframe.NotComparableSkyValue;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010026import com.google.devtools.build.skyframe.SkyKey;
cparsonse2d200f2018-03-06 16:15:11 -080027import com.google.devtools.build.skyframe.SkyValue;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010028
janakra86c2672018-06-18 09:04:43 -070029/** A {@link SkyValue} for a {@link ConfiguredTarget}. */
30public interface ConfiguredTargetValue extends NotComparableSkyValue {
cparsonse2d200f2018-03-06 16:15:11 -080031 static SkyKey key(Label label, BuildConfiguration configuration) {
janakr573807d2018-01-11 14:02:35 -080032 return ConfiguredTargetKey.of(label, configuration);
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010033 }
34
35 static ImmutableList<SkyKey> keys(Iterable<ConfiguredTargetKey> lacs) {
36 ImmutableList.Builder<SkyKey> keys = ImmutableList.builder();
37 for (ConfiguredTargetKey lac : lacs) {
janakr573807d2018-01-11 14:02:35 -080038 keys.add(lac);
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010039 }
40 return keys.build();
41 }
42
43 /**
cparsonse2d200f2018-03-06 16:15:11 -080044 * Returns the configured target for this value.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010045 */
cparsonse2d200f2018-03-06 16:15:11 -080046 ConfiguredTarget getConfiguredTarget();
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010047
cparsonse2d200f2018-03-06 16:15:11 -080048 /**
49 * Returns the set of packages transitively loaded by this value. Must only be used for
50 * constructing the package -> source root map needed for some builds. If the caller has not
51 * specified that this map needs to be constructed (via the constructor argument in {@link
52 * ConfiguredTargetFunction#ConfiguredTargetFunction}), calling this will crash.
53 */
54 NestedSet<Package> getTransitivePackagesForPackageRootResolution();
55
tomlu9e91f202018-06-18 16:16:36 -070056 /** Returns the actions registered by the configured target for this value. */
57 ImmutableList<ActionAnalysisMetadata> getActions();
cparsonse2d200f2018-03-06 16:15:11 -080058
59 /**
60 * Returns the number of {@link Action} objects present in this value.
61 */
62 int getNumActions();
63
64 /**
65 * Clears configured target data from this value, leaving only the artifact->generating action
66 * map.
67 *
68 * <p>Should only be used when user specifies --discard_analysis_cache. Must be called at most
69 * once per value, after which {@link #getConfiguredTarget} and {@link #getActions} cannot be
70 * called.
71 */
72 void clear(boolean clearEverything);
janakra81bb952019-01-28 17:30:06 -080073
74 @Override
75 default boolean mustBeReferenceComparedOnRecomputation() {
76 return true;
77 }
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010078}