diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BUILD index a36517048f7c6c..2b791a509d5363 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BUILD @@ -20,5 +20,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:rule_definition_environment", "//src/main/java/com/google/devtools/build/lib/packages", "//src/main/java/com/google/devtools/build/lib/rules/genrule", + "//src/main/java/com/google/devtools/build/lib/util:filetype", ], ) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRule.java index 967e8fd7801101..ab47564cfb9d49 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRule.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.bazel.rules.genrule; +import com.google.devtools.build.lib.analysis.CommandHelper; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.packages.Type; import com.google.devtools.build.lib.rules.genrule.GenRuleBase; @@ -30,4 +31,15 @@ protected boolean isStampingEnabled(RuleContext ruleContext) { } return ruleContext.attributes().get("stamp", Type.BOOLEAN); } + + // TODO(https://github.com/bazelbuild/bazel/issues/19132): Remove this override once downstream + // projects are migrated. + @Override + protected CommandHelper.Builder commandHelperBuilder(RuleContext ruleContext) { + return CommandHelper.builder(ruleContext) + .addToolDependencies("tools") + // TODO(https://github.com/bazelbuild/bazel/issues/19132): Add an actual incompatible flag. + .addToolDependencies("exec_tools") + .addToolDependencies("toolchains"); + } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRuleRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRuleRule.java index 685925c287ff7c..5055b89fa2f0a9 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRuleRule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRuleRule.java @@ -15,6 +15,7 @@ import static com.google.devtools.build.lib.packages.Attribute.attr; import static com.google.devtools.build.lib.packages.BuildType.LABEL; +import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST; import static com.google.devtools.build.lib.packages.Type.BOOLEAN; import com.google.devtools.build.lib.analysis.RuleDefinition; @@ -22,6 +23,7 @@ import com.google.devtools.build.lib.analysis.config.ExecutionTransitionFactory; import com.google.devtools.build.lib.packages.RuleClass; import com.google.devtools.build.lib.rules.genrule.GenRuleBaseRule; +import com.google.devtools.build.lib.util.FileTypeSet; /** * Rule definition for genrule for Bazel. @@ -44,6 +46,23 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) .cfg(ExecutionTransitionFactory.createFactory()) .value(env.getToolsLabel(GENRULE_SETUP_LABEL))) + // TODO(https://github.com/bazelbuild/bazel/issues/19132): Remove this once downstream + // projects are migrated. + /* + Deprecated. Use tools instead. + +

+ There was a period of time when exec_tools and tools behaved + differently, but they are now equivalent and the Blaze team will be migrating all uses of + exec_tools to tools. +

+ */ + .add( + attr("exec_tools", LABEL_LIST) + .cfg(ExecutionTransitionFactory.createFactory()) + .allowedFileTypes(FileTypeSet.ANY_FILE) + .dontCheckConstraints()) + // TODO(bazel-team): stamping doesn't seem to work. Fix it or remove attribute. .add(attr("stamp", BOOLEAN).value(false)) .build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java b/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java index 2e176731dde46f..ecbcfbfdf9de3e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java +++ b/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java @@ -289,7 +289,6 @@ public String toString() { protected CommandHelper.Builder commandHelperBuilder(RuleContext ruleContext) { return CommandHelper.builder(ruleContext) .addToolDependencies("tools") - .addToolDependencies("exec_tools") .addToolDependencies("toolchains"); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBaseRule.java b/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBaseRule.java index 57bb1991a8fc08..bfecb964386e6b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBaseRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBaseRule.java @@ -85,21 +85,6 @@ public RuleClass build( .cfg(ExecutionTransitionFactory.createFactory()) .allowedFileTypes(FileTypeSet.ANY_FILE)) - /* - Deprecated. Use tools instead. - -

- There was a period of time when exec_tools and tools behaved - differently, but they are now equivalent and the Blaze team will be migrating all uses of - exec_tools to tools. -

- */ - .add( - attr("exec_tools", LABEL_LIST) - .cfg(ExecutionTransitionFactory.createFactory()) - .allowedFileTypes(FileTypeSet.ANY_FILE) - .dontCheckConstraints()) - /* A list of files generated by this rule.