diff options
author | 2015-03-27 20:07:28 +0000 | |
---|---|---|
committer | 2015-03-30 12:19:58 +0000 | |
commit | b3a6ca7e5cf6140e4030fdeacd3148eb17e9781f (patch) | |
tree | 3a7a1d5886b501f4a3e42606e99730d7fb72ca79 /src/main/java/com/google/devtools/build/lib/skyframe/ActionLookupValue.java | |
parent | 90f3d34417043bd1bfe6098ad6b8d229bb76d78b (diff) |
Catch action conflicts in the same target during configured target analysis, and fail hard in other cases.
--
MOS_MIGRATED_REVID=89720528
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/ActionLookupValue.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/ActionLookupValue.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionLookupValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionLookupValue.java index 1dfa7225ec..4d51cfe9d5 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionLookupValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionLookupValue.java @@ -19,12 +19,12 @@ import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ArtifactOwner; +import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException; import com.google.devtools.build.lib.syntax.Label; import com.google.devtools.build.skyframe.SkyFunctionName; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; -import java.util.HashMap; import java.util.Map; /** @@ -35,23 +35,28 @@ import java.util.Map; public class ActionLookupValue implements SkyValue { protected final ImmutableMap<Artifact, Action> generatingActionMap; - ActionLookupValue(Iterable<Action> actions) { - // Duplicate/shared actions get passed in all the time. Blaze is weird. We can't double-register - // the generated artifacts in an immutable map builder, so we double-register them in a more - // forgiving map, and then use that map to create the immutable one. - Map<Artifact, Action> generatingActions = new HashMap<>(); - for (Action action : actions) { - for (Artifact artifact : action.getOutputs()) { - generatingActions.put(artifact, action); - } + private static Map<Artifact, Action> filterSharedActionsAndThrowRuntimeIfConflict( + Iterable<Action> actions) { + try { + return ConfiguredTargetFunction.filterSharedActionsAndThrowIfConflict(actions); + } catch (ActionConflictException e) { + // Programming bug. + throw new IllegalStateException(e); } - generatingActionMap = ImmutableMap.copyOf(generatingActions); + } + + ActionLookupValue(Iterable<Action> actions) { + this(filterSharedActionsAndThrowRuntimeIfConflict(actions)); } ActionLookupValue(Action action) { this(ImmutableList.of(action)); } + ActionLookupValue(Map<Artifact, Action> generatingActionMap) { + this.generatingActionMap = ImmutableMap.copyOf(generatingActionMap); + } + Action getGeneratingAction(Artifact artifact) { return generatingActionMap.get(artifact); } |