aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions/MutableActionGraph.java
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2017-11-29 14:01:21 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-11-29 14:03:30 -0800
commit3d1a194ff9e76f25f1a7242ff2d021523ba8e4a0 (patch)
tree9fec583a59b8ee6ee0f4fac513d5471956dfe1d3 /src/main/java/com/google/devtools/build/lib/actions/MutableActionGraph.java
parent8f8b8859fc7d85feee97481443fb11c0b7ae03ce (diff)
Add ActionKeyContext to Action#getKey.
This key context can be used by actions to share partial key computations, for instance when computing MD5s for nested sets. RELNOTES: None PiperOrigin-RevId: 177359607
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/MutableActionGraph.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/MutableActionGraph.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/MutableActionGraph.java b/src/main/java/com/google/devtools/build/lib/actions/MutableActionGraph.java
index 1b1955a5e5..24a74ad28c 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/MutableActionGraph.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/MutableActionGraph.java
@@ -61,15 +61,19 @@ public interface MutableActionGraph extends ActionGraph {
* about the artifact for which the conflict is found, and data about the two conflicting actions
* and their owners.
*/
- public static final class ActionConflictException extends Exception {
+ final class ActionConflictException extends Exception {
+ private final ActionKeyContext actionKeyContext;
private final Artifact artifact;
private final ActionAnalysisMetadata previousAction;
private final ActionAnalysisMetadata attemptedAction;
private static final int MAX_DIFF_ARTIFACTS_TO_REPORT = 5;
- public ActionConflictException(Artifact artifact, ActionAnalysisMetadata previousAction,
+ public ActionConflictException(
+ ActionKeyContext actionKeyContext,
+ Artifact artifact,
+ ActionAnalysisMetadata previousAction,
ActionAnalysisMetadata attemptedAction) {
super(
String.format(
@@ -77,6 +81,7 @@ public interface MutableActionGraph extends ActionGraph {
artifact.prettyPrint(),
previousAction.prettyPrint(),
attemptedAction.prettyPrint()));
+ this.actionKeyContext = actionKeyContext;
this.artifact = artifact;
this.previousAction = previousAction;
this.attemptedAction = attemptedAction;
@@ -91,7 +96,7 @@ public interface MutableActionGraph extends ActionGraph {
"file '"
+ artifact.prettyPrint()
+ "' is generated by these conflicting actions:\n"
- + suffix(attemptedAction, previousAction);
+ + suffix(actionKeyContext, attemptedAction, previousAction);
eventListener.handle(Event.error(msg));
}
@@ -143,14 +148,13 @@ public interface MutableActionGraph extends ActionGraph {
}
}
- private static String getKey(ActionAnalysisMetadata action) {
- return action instanceof Action
- ? ((Action) action).getKey()
- : null;
+ private static String getKey(ActionKeyContext actionKeyContext, ActionAnalysisMetadata action) {
+ return action instanceof Action ? ((Action) action).getKey(actionKeyContext) : null;
}
// See also Actions.canBeShared()
- private static String suffix(ActionAnalysisMetadata a, ActionAnalysisMetadata b) {
+ private static String suffix(
+ ActionKeyContext actionKeyContext, ActionAnalysisMetadata a, ActionAnalysisMetadata b) {
// Note: the error message reveals to users the names of intermediate files that are not
// documented in the BUILD language. This error-reporting logic is rather elaborate but it
// does help to diagnose some tricky situations.
@@ -167,7 +171,7 @@ public interface MutableActionGraph extends ActionGraph {
addStringDetail(sb, "Configuration", aNull ? null : aOwner.getConfigurationChecksum(),
bNull ? null : bOwner.getConfigurationChecksum());
addStringDetail(sb, "Mnemonic", a.getMnemonic(), b.getMnemonic());
- addStringDetail(sb, "Action key", getKey(a), getKey(b));
+ addStringDetail(sb, "Action key", getKey(actionKeyContext, a), getKey(actionKeyContext, b));
if ((a instanceof ActionExecutionMetadata) && (b instanceof ActionExecutionMetadata)) {
addStringDetail(