aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar Laurent Le Brun <laurentlb@google.com>2015-04-08 16:27:21 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-04-08 18:40:23 +0000
commitc2efe4556849e4eaa11472d070e5172d1629af92 (patch)
treeee604824073e9e61f17b67c88c4a360ab568ff09 /src/main/java/com/google
parent01f36002951f1b86924a0a06b44621e80795d5dd (diff)
Skylark: Expose output_to_genfiles rule attribute
-- MOS_MIGRATED_REVID=90616271
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/RuleClass.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java10
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
index 3c8172a0e2..d265a44a6a 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -1508,7 +1508,8 @@ public final class RuleClass {
* individual rule instance, derived from the 'output_to_bindir' attribute;
* see Rule.hasBinaryOutput().
*/
- boolean hasBinaryOutput() {
+ @VisibleForTesting
+ public boolean hasBinaryOutput() {
return binaryOutput;
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
index 36444a3d04..803d3dad67 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
@@ -205,7 +205,10 @@ public class SkylarkRuleClassFunctions {
+ "returning such a dictionary."),
@Param(name = "executable", type = Boolean.class,
doc = "whether this rule always outputs an executable of the same name or not. If True, "
- + "there must be an action that generates <code>ctx.outputs.executable</code>.")})
+ + "there must be an action that generates <code>ctx.outputs.executable</code>."),
+ @Param(name = "output_to_genfiles", type = Boolean.class,
+ doc = "If true, the files will be generated in the genfiles directory instead of the "
+ + "bin directory. This is used for compatibility with existing rules.")})
private static final SkylarkFunction rule = new SkylarkFunction("rule") {
@Override
@@ -254,6 +257,11 @@ public class SkylarkRuleClassFunctions {
}
}
+ if (arguments.containsKey("output_to_genfiles")
+ && (Boolean) arguments.get("output_to_genfiles")) {
+ builder.setOutputToGenfiles();
+ }
+
builder.setConfiguredTargetFunction(
(UserDefinedFunction) arguments.get("implementation"));
builder.setRuleDefinitionEnvironment((SkylarkEnvironment) funcallEnv);