aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Greg Estren <gregce@google.com>2015-07-10 21:50:10 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-07-13 12:08:48 +0000
commit630c064877ac6da25d2f729ce924611cbb5dc710 (patch)
treebc09141feaa3a796b5eed11ea3d45d25b8081036 /src
parent3ac608ffffbda9a40e99f0ad3c6c990f1fefa739 (diff)
Disallow Skylark implicit outputs from referencing attributes
that use 'select': fail with a clean user error rather than crashing. Rule outputs are "special" in that they need to be defined before select statements can be evaluated (e.g. before the analysis phase begins). -- MOS_MIGRATED_REVID=98000760
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java b/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java
index 61ffea55d8..b05082ade0 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java
@@ -86,14 +86,16 @@ public abstract class ImplicitOutputsFunction {
public ImmutableMap<String, String> calculateOutputs(AttributeMap map) throws EvalException {
Map<String, Object> attrValues = new HashMap<>();
for (String attrName : map.getAttributeNames()) {
- // TODO(bazel-team): support configurable attributes - which value would we want to
- // pass on to the child outputs function? Maybe implicit output functions shouldn't
- // have access to configurable values (makes them too complicated?). Maybe they
- // should have *full* access (gives them the most power?).
- Object value = map.get(attrName, map.getAttributeType(attrName));
- attrValues.put(attrName, value == null ? Environment.NONE : value);
+ Type<?> attrType = map.getAttributeType(attrName);
+ // Don't include configurable attributes: we don't know which value they might take
+ // since we don't yet have a build configuration.
+ if (!map.isConfigurable(attrName, attrType)) {
+ Object value = map.get(attrName, attrType);
+ attrValues.put(attrName, value == null ? Environment.NONE : value);
+ }
}
- ClassObject attrs = new SkylarkClassObject(attrValues, "No such attribute '%s'");
+ ClassObject attrs = new SkylarkClassObject(attrValues, "Attribute '%s' either doesn't exist "
+ + "or uses a select() (i.e. could have multiple values)");
try {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (Map.Entry<String, String> entry : castMap(callback.call(attrs),