aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2016-02-29 12:13:30 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-02-29 17:40:17 +0000
commitfa1d76f5485f898c285c68cf28eeed10e6a08b1e (patch)
tree9dc5f35acc7f60dc70a66abffe50b342cc141c98 /src/main/java/com/google/devtools/build
parentde54bca47ff6a902edef6b4e1730edafc35581af (diff)
Fix the excepton when Skylark rule has 2 executable attributes pointing to the same artifact.
This fix is that we pick the random executable. Filed #987 for a better fix (the current behavior just crashes the build randomly and the real fix is involved). -- MOS_MIGRATED_REVID=115835198
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java
index 523c9c758d..8abc00bf51 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java
@@ -64,6 +64,7 @@ import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -279,6 +280,7 @@ public final class SkylarkRuleContext {
Builder<Artifact, FilesToRunProvider> executableRunfilesbuilder = new Builder<>();
Builder<String, Object> fileBuilder = new Builder<>();
Builder<String, Object> filesBuilder = new Builder<>();
+ HashSet<Artifact> seenExecutables = new HashSet<>();
for (Attribute a : attributes) {
Type<?> type = a.getType();
Object val = attributeValueExtractor.apply(a);
@@ -296,7 +298,16 @@ public final class SkylarkRuleContext {
if (provider != null && provider.getExecutable() != null) {
Artifact executable = provider.getExecutable();
executableBuilder.put(skyname, executable);
- executableRunfilesbuilder.put(executable, provider);
+ if (!seenExecutables.contains(executable)) {
+ // todo(dslomov,laurentlb): In general, this is incorrect.
+ // We associate the first encountered FilesToRunProvider with
+ // the executable (this provider is later used to build the spawn).
+ // However ideally we should associate a provider with the attribute name,
+ // and pass the correct FilesToRunProvider to the spawn depending on
+ // what attribute is used to access the executable.
+ executableRunfilesbuilder.put(executable, provider);
+ seenExecutables.add(executable);
+ }
} else {
executableBuilder.put(skyname, Runtime.NONE);
}