cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 1 | // Copyright 2018 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. |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 14 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 15 | package com.google.devtools.build.lib.skyframe; |
| 16 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 17 | import com.google.common.collect.ImmutableList; |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 18 | import com.google.devtools.build.lib.actions.Action; |
Rumou Duan | 33bab46 | 2016-04-25 17:55:12 +0000 | [diff] [blame] | 19 | import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 20 | import com.google.devtools.build.lib.analysis.ConfiguredTarget; |
| 21 | import com.google.devtools.build.lib.analysis.config.BuildConfiguration; |
Lukacs Berki | 6e91eb9 | 2015-09-21 09:12:37 +0000 | [diff] [blame] | 22 | import com.google.devtools.build.lib.cmdline.Label; |
Marian Lobur | c62faba | 2015-09-09 10:08:06 +0000 | [diff] [blame] | 23 | import com.google.devtools.build.lib.collect.nestedset.NestedSet; |
Marian Lobur | c62faba | 2015-09-09 10:08:06 +0000 | [diff] [blame] | 24 | import com.google.devtools.build.lib.packages.Package; |
janakr | a86c267 | 2018-06-18 09:04:43 -0700 | [diff] [blame] | 25 | import com.google.devtools.build.skyframe.NotComparableSkyValue; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 26 | import com.google.devtools.build.skyframe.SkyKey; |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 27 | import com.google.devtools.build.skyframe.SkyValue; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 28 | |
janakr | a86c267 | 2018-06-18 09:04:43 -0700 | [diff] [blame] | 29 | /** A {@link SkyValue} for a {@link ConfiguredTarget}. */ |
| 30 | public interface ConfiguredTargetValue extends NotComparableSkyValue { |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 31 | static SkyKey key(Label label, BuildConfiguration configuration) { |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 32 | return ConfiguredTargetKey.of(label, configuration); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | static ImmutableList<SkyKey> keys(Iterable<ConfiguredTargetKey> lacs) { |
| 36 | ImmutableList.Builder<SkyKey> keys = ImmutableList.builder(); |
| 37 | for (ConfiguredTargetKey lac : lacs) { |
janakr | 573807d | 2018-01-11 14:02:35 -0800 | [diff] [blame] | 38 | keys.add(lac); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 39 | } |
| 40 | return keys.build(); |
| 41 | } |
| 42 | |
| 43 | /** |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 44 | * Returns the configured target for this value. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 45 | */ |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 46 | ConfiguredTarget getConfiguredTarget(); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 47 | |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 48 | /** |
| 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 | |
tomlu | 9e91f20 | 2018-06-18 16:16:36 -0700 | [diff] [blame] | 56 | /** Returns the actions registered by the configured target for this value. */ |
| 57 | ImmutableList<ActionAnalysisMetadata> getActions(); |
cparsons | e2d200f | 2018-03-06 16:15:11 -0800 | [diff] [blame] | 58 | |
| 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); |
janakr | a81bb95 | 2019-01-28 17:30:06 -0800 | [diff] [blame] | 73 | |
| 74 | @Override |
| 75 | default boolean mustBeReferenceComparedOnRecomputation() { |
| 76 | return true; |
| 77 | } |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 78 | } |