Skip to content

Commit

Permalink
Remove the obsolete exec_tools attribute from genrule.
Browse files Browse the repository at this point in the history
DO NOT SUBMIT.

Part of bazelbuild#19132.
  • Loading branch information
katre committed Aug 1, 2023
1 parent ef9c3b3 commit 1f10baa
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,10 @@ public static class Options extends FragmentOptions {
help = "If enabled, visibility checking also applies to toolchain implementations.")
public boolean checkVisibilityForToolchains;

@Option(
name = "incompatible_remove_exec_tools",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
help = "If enabled, use of genrule's exec_tools attribute will cause an error..")
public boolean removeExecTools;

@Override
public FragmentOptions getExec() {
Options exec = (Options) getDefault();
exec.checkVisibilityForToolchains = checkVisibilityForToolchains;
exec.removeExecTools = removeExecTools;

return exec;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster",
"//src/main/java/com/google/devtools/build/lib/analysis:config/execution_transition_factory",
"//src/main/java/com/google/devtools/build/lib/analysis:rule_definition_environment",
"//src/main/java/com/google/devtools/build/lib/bazel:bazel_configuration",
"//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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import com.google.devtools.build.lib.analysis.CommandHelper;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.bazel.BazelConfiguration;
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.Type;
import com.google.devtools.build.lib.rules.genrule.GenRuleBase;

Expand All @@ -33,24 +31,4 @@ 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) {
BazelConfiguration.Options bazelOptions =
ruleContext.getConfiguration().getOptions().get(BazelConfiguration.Options.class);

if (bazelOptions.removeExecTools
&& ruleContext.attributes().has("exec_tools", BuildType.LABEL_LIST)
&& !ruleContext.attributes().get("exec_tools", BuildType.LABEL_LIST).isEmpty()) {
ruleContext.attributeError(
"exec_tools", "genrule.exec_tools has been removed, use tools instead");
}

return CommandHelper.builder(ruleContext)
.addToolDependencies("tools")
.addToolDependencies("exec_tools")
.addToolDependencies("toolchains");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,6 @@ 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.
/* <!-- #BLAZE_RULE(genrule).ATTRIBUTE(exec_tools) -->
<b>Deprecated. Use <a href="#genrule.tools"><code>tools</code></a> instead.</b>
<p>
There was a period of time when <code>exec_tools</code> and <code>tools</code> behaved
differently, but they are now equivalent and the Blaze team will be migrating all uses of
<code>exec_tools</code> to <code>tools</code>.
</p>
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.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();
Expand Down

0 comments on commit 1f10baa

Please sign in to comment.