aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benjamin Peterson <bp@benjamin.pe>2017-04-12 19:53:07 +0000
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-04-13 09:36:53 +0200
commit11b8760a59ca3278905a16a2272c7cb38628d887 (patch)
tree5a15c6388bd54743ba5e8943eaeed796ef6936e8
parent26ac674432298d138ea87bede0012aa2fb43a155 (diff)
Remove special cases for "name" in implicit outputs code
fa97703c1edf ("allow skylark implicit output callbacks to use the rule name") fixed a limitation of the skylark implicit outputs by adding a special case for "name" to the implicit outputs code. Later, 015e5954157a ("Remove special handling of name attribute") fixed the general problem of "name" being a special case in the attribute map. Therefore, we can remove my original fix. We may also excise an older special case in the implicit outputs templating code. Change-Id: I606c9decd98a8df492d2359abe540d3263f99fe1 PiperOrigin-RevId: 152974774
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java7
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/RuleClassTest.java4
2 files changed, 5 insertions, 6 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 8d7ed337ad..9dea0b725a 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
@@ -94,8 +94,6 @@ public abstract class ImplicitOutputsFunction {
attrValues.put(attrName, value == null ? Runtime.NONE : value);
}
}
- // Add 'name' explicitly, since its value is not in the attribute map.
- attrValues.put("name", map.getName());
ClassObject attrs = NativeClassObjectConstructor.STRUCT.create(
attrValues,
"Attribute '%s' either doesn't exist "
@@ -297,10 +295,7 @@ public abstract class ImplicitOutputsFunction {
* strings. Helper function for {@link #fromTemplates(Iterable)}.
*/
private static Set<String> attributeValues(AttributeMap rule, String attrName) {
- // Special case "name" since it's not treated as an attribute.
- if (attrName.equals("name")) {
- return singleton(rule.getName());
- } else if (attrName.equals("dirname")) {
+ if (attrName.equals("dirname")) {
PathFragment dir = PathFragment.create(rule.getName()).getParentDirectory();
return (dir.segmentCount() == 0) ? singleton("") : singleton(dir.getPathString() + "/");
} else if (attrName.equals("basename")) {
diff --git a/src/test/java/com/google/devtools/build/lib/packages/RuleClassTest.java b/src/test/java/com/google/devtools/build/lib/packages/RuleClassTest.java
index dab6130013..b0a23b4c5c 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/RuleClassTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/RuleClassTest.java
@@ -437,10 +437,12 @@ public class RuleClassTest extends PackageLoadingTestCase {
ImmutableSet.<Class<?>>of(),
MissingFragmentPolicy.FAIL_ANALYSIS,
true,
+ attr("name", STRING).build(),
attr("outs", OUTPUT_LIST).build());
Map<String, Object> attributeValues = new HashMap<>();
attributeValues.put("outs", Collections.singletonList("explicit_out"));
+ attributeValues.put("name", "myrule");
Rule rule = createRule(ruleClassC, "myrule", attributeValues, testRuleLocation);
@@ -677,10 +679,12 @@ public class RuleClassTest extends PackageLoadingTestCase {
ImmutableSet.<Class<?>>of(),
MissingFragmentPolicy.FAIL_ANALYSIS,
true,
+ attr("name", STRING).build(),
attr("outs", OUTPUT_LIST).build());
Map<String, Object> attributeValues = new HashMap<>();
attributeValues.put("outs", ImmutableList.of("third", "fourth"));
+ attributeValues.put("name", "myrule");
Rule rule = createRule(ruleClassC, "myrule", attributeValues, testRuleLocation);