blob: 1667c982af68b084aa3aa556e1d6b22140ec2e95 [file] [log] [blame]
janakr6d185b82020-03-30 14:08:01 -07001// Copyright 2014 The Bazel Authors. All rights reserved.
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.
14package com.google.devtools.build.lib.skyframe;
15
janakr1a4066a2020-04-13 13:24:27 -070016import static com.google.common.base.Preconditions.checkArgument;
janakr6d185b82020-03-30 14:08:01 -070017
janakr6d185b82020-03-30 14:08:01 -070018import com.google.common.collect.Interner;
19import com.google.devtools.build.lib.actions.ActionLookupValue;
janakr1a4066a2020-04-13 13:24:27 -070020import com.google.devtools.build.lib.actions.Artifact;
janakr6d185b82020-03-30 14:08:01 -070021import com.google.devtools.build.lib.concurrent.BlazeInterners;
22import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
23import com.google.devtools.build.skyframe.AbstractSkyKey;
24import com.google.devtools.build.skyframe.SkyFunctionName;
janakr6d185b82020-03-30 14:08:01 -070025import com.google.devtools.build.skyframe.SkyValue;
26
27/**
28 * A marker for an {@link ActionLookupValue} which is known to be transitively error-free from
29 * action conflict issues.
30 */
janakr1a4066a2020-04-13 13:24:27 -070031public class ActionLookupConflictFindingValue implements SkyValue {
janakr6d185b82020-03-30 14:08:01 -070032 @AutoCodec
33 static final ActionLookupConflictFindingValue INSTANCE = new ActionLookupConflictFindingValue();
34
35 private ActionLookupConflictFindingValue() {}
36
janakr6d185b82020-03-30 14:08:01 -070037 public static Key key(ActionLookupValue.ActionLookupKey lookupKey) {
38 return Key.create(lookupKey);
39 }
40
janakr1a4066a2020-04-13 13:24:27 -070041 public static Key key(Artifact artifact) {
42 checkArgument(artifact instanceof Artifact.DerivedArtifact, artifact);
43 return ActionLookupConflictFindingValue.key(
44 ((Artifact.DerivedArtifact) artifact).getGeneratingActionKey().getActionLookupKey());
45 }
46
janakr6d185b82020-03-30 14:08:01 -070047 @AutoCodec.VisibleForSerialization
48 @AutoCodec
49 static class Key extends AbstractSkyKey<ActionLookupValue.ActionLookupKey> {
50 private static final Interner<Key> interner = BlazeInterners.newWeakInterner();
51
52 private Key(ActionLookupValue.ActionLookupKey arg) {
53 super(arg);
54 }
55
56 @AutoCodec.VisibleForSerialization
57 @AutoCodec.Instantiator
58 static Key create(ActionLookupValue.ActionLookupKey arg) {
59 return interner.intern(new Key(arg));
60 }
61
62 @Override
63 public SkyFunctionName functionName() {
64 return SkyFunctions.ACTION_LOOKUP_CONFLICT_FINDING;
65 }
66 }
67}