Skylark: Expose output_to_genfiles rule attribute
--
MOS_MIGRATED_REVID=90616271
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 3c8172a..d265a44 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 @@
* 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 36444a3..803d3da 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 @@
+ "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 @@
}
}
+ if (arguments.containsKey("output_to_genfiles")
+ && (Boolean) arguments.get("output_to_genfiles")) {
+ builder.setOutputToGenfiles();
+ }
+
builder.setConfiguredTargetFunction(
(UserDefinedFunction) arguments.get("implementation"));
builder.setRuleDefinitionEnvironment((SkylarkEnvironment) funcallEnv);