blob: 64066cf94851c3861c9f71d0cab4c0ecc0ad387c [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2014 The Bazel Authors. All rights reserved.
Dmitry Lomove2033b12015-08-19 16:57:49 +00002//
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.
14package com.google.devtools.build.lib.skyframe;
15
Googlerbfd4e242016-07-15 22:23:37 +000016import com.google.auto.value.AutoValue;
Dmitry Lomove2033b12015-08-19 16:57:49 +000017import com.google.common.collect.Iterables;
Googlerbfd4e242016-07-15 22:23:37 +000018import com.google.devtools.build.lib.analysis.TopLevelArtifactContext;
19import com.google.devtools.build.lib.skyframe.AspectValue.AspectKey;
janakr5fb2a482018-03-02 17:48:57 -080020import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
21import com.google.devtools.build.skyframe.SkyFunctionName;
Dmitry Lomove2033b12015-08-19 16:57:49 +000022import com.google.devtools.build.skyframe.SkyKey;
23import com.google.devtools.build.skyframe.SkyValue;
Dmitry Lomove2033b12015-08-19 16:57:49 +000024import java.util.Collection;
25
26/**
27 * The value of an AspectCompletion. Currently this just stores an Aspect.
28 */
29public class AspectCompletionValue implements SkyValue {
janakr5fb2a482018-03-02 17:48:57 -080030 @AutoCodec static final AspectCompletionValue INSTANCE = new AspectCompletionValue();
Dmitry Lomove2033b12015-08-19 16:57:49 +000031
janakr5fb2a482018-03-02 17:48:57 -080032 private AspectCompletionValue() {}
Dmitry Lomove2033b12015-08-19 16:57:49 +000033
Googlerbfd4e242016-07-15 22:23:37 +000034 public static Iterable<SkyKey> keys(
35 Collection<AspectValue> targets, final TopLevelArtifactContext ctx) {
Dmitry Lomove2033b12015-08-19 16:57:49 +000036 return Iterables.transform(
janakr5fb2a482018-03-02 17:48:57 -080037 targets, aspectValue -> AspectCompletionKey.create(aspectValue.getKey(), ctx));
Dmitry Lomove2033b12015-08-19 16:57:49 +000038 }
Googlerbfd4e242016-07-15 22:23:37 +000039
tomlu6ed4fd52018-04-03 10:01:10 -070040 /** The key of an AspectCompletionValue. */
janakr5fb2a482018-03-02 17:48:57 -080041 @AutoValue
tomlu6ed4fd52018-04-03 10:01:10 -070042 public abstract static class AspectCompletionKey implements SkyKey {
Googlerbfd4e242016-07-15 22:23:37 +000043 public static AspectCompletionKey create(
44 AspectKey aspectKey, TopLevelArtifactContext topLevelArtifactContext) {
45 return new AutoValue_AspectCompletionValue_AspectCompletionKey(
46 aspectKey, topLevelArtifactContext);
47 }
48
49 public abstract AspectKey aspectKey();
50 public abstract TopLevelArtifactContext topLevelArtifactContext();
janakr5fb2a482018-03-02 17:48:57 -080051
52 @Override
53 public SkyFunctionName functionName() {
54 return SkyFunctions.ASPECT_COMPLETION;
55 }
Googlerbfd4e242016-07-15 22:23:37 +000056 }
Dmitry Lomove2033b12015-08-19 16:57:49 +000057}