aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar jcater <jcater@google.com>2017-03-31 19:24:47 +0000
committerGravatar Marcel Hlopko <hlopko@google.com>2017-04-03 13:37:02 +0200
commitbe5f25ca01d443193a97dae99ff4d1e90311bdaf (patch)
tree5e37193755ef87253fc9b413a89a7ee7840e7f35 /src/main
parentba03c11bb8155bca74ddb4539acd0c0f2105da11 (diff)
Rename the ToolchainProvider to a more accurate name (and free up the name for the new ToolchainProvider).
Change-Id: I3537e1ed924c598707759c4a7040d5ba00de559c PiperOrigin-RevId: 151853764
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/MakeVariableProvider.java (renamed from src/main/java/com/google/devtools/build/lib/rules/ToolchainProvider.java)12
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/ToolchainType.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBaseRule.java65
4 files changed, 47 insertions, 40 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/ToolchainProvider.java b/src/main/java/com/google/devtools/build/lib/rules/MakeVariableProvider.java
index e25ee2b229..1c56c20bfb 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/ToolchainProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/MakeVariableProvider.java
@@ -21,14 +21,12 @@ import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import java.util.TreeMap;
-/**
- * A toolchain, determined from the current platform.
- */
+/** Provides access to make variables from the current fragments. */
@Immutable
-public final class ToolchainProvider implements TransitiveInfoProvider {
+public final class MakeVariableProvider implements TransitiveInfoProvider {
private final ImmutableMap<String, String> makeVariables;
- public ToolchainProvider(ImmutableMap<String, String> makeVariables) {
+ public MakeVariableProvider(ImmutableMap<String, String> makeVariables) {
this.makeVariables = makeVariables;
}
@@ -40,8 +38,8 @@ public final class ToolchainProvider implements TransitiveInfoProvider {
RuleContext ruleContext, String attributeName) {
// Cannot be an ImmutableMap.Builder because we want to support duplicate keys
TreeMap<String, String> result = new TreeMap<>();
- for (ToolchainProvider provider :
- ruleContext.getPrerequisites(attributeName, Mode.TARGET, ToolchainProvider.class)) {
+ for (MakeVariableProvider provider :
+ ruleContext.getPrerequisites(attributeName, Mode.TARGET, MakeVariableProvider.class)) {
result.putAll(provider.getMakeVariables());
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/ToolchainType.java b/src/main/java/com/google/devtools/build/lib/rules/ToolchainType.java
index a752db0da2..fbb1b4b616 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/ToolchainType.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/ToolchainType.java
@@ -61,7 +61,7 @@ public class ToolchainType implements RuleConfiguredTargetFactory {
// out the lookup rule -> toolchain rule mapping. For now, it only provides Make variables that
// come from BuildConfiguration so no need to ask Skyframe.
return new RuleConfiguredTargetBuilder(ruleContext)
- .addProvider(new ToolchainProvider(ImmutableMap.copyOf(makeVariables)))
+ .addProvider(new MakeVariableProvider(ImmutableMap.copyOf(makeVariables)))
.addProvider(RunfilesProvider.simple(Runfiles.EMPTY))
.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 8a2983ba90..407a45cb3d 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
@@ -39,8 +39,8 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.packages.TargetUtils;
import com.google.devtools.build.lib.rules.AliasProvider;
+import com.google.devtools.build.lib.rules.MakeVariableProvider;
import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory;
-import com.google.devtools.build.lib.rules.ToolchainProvider;
import com.google.devtools.build.lib.rules.cpp.CppHelper;
import com.google.devtools.build.lib.rules.java.JavaHelper;
import com.google.devtools.build.lib.syntax.Type;
@@ -292,8 +292,10 @@ public abstract class GenRuleBase implements RuleConfiguredTargetFactory {
public CommandResolverContext(RuleContext ruleContext, NestedSet<Artifact> resolvedSrcs,
NestedSet<Artifact> filesToBuild) {
- super(ruleContext.getRule().getPackage(), ruleContext.getConfiguration(),
- ToolchainProvider.getToolchainMakeVariables(ruleContext, "toolchains"));
+ super(
+ ruleContext.getRule().getPackage(),
+ ruleContext.getConfiguration(),
+ MakeVariableProvider.getToolchainMakeVariables(ruleContext, "toolchains"));
this.ruleContext = ruleContext;
this.resolvedSrcs = resolvedSrcs;
this.filesToBuild = filesToBuild;
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 59d1c59129..544a03df21 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
@@ -34,7 +34,7 @@ import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
-import com.google.devtools.build.lib.rules.ToolchainProvider;
+import com.google.devtools.build.lib.rules.MakeVariableProvider;
import com.google.devtools.build.lib.rules.cpp.CppConfiguration;
import com.google.devtools.build.lib.rules.cpp.CppRuleClasses;
import com.google.devtools.build.lib.syntax.Type;
@@ -85,9 +85,10 @@ public class GenRuleBaseRule implements RuleDefinition {
//<code>srcs</code>.
</p>
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("srcs", LABEL_LIST)
- .direct_compile_time_input()
- .allowedFileTypes(FileTypeSet.ANY_FILE))
+ .add(
+ attr("srcs", LABEL_LIST)
+ .direct_compile_time_input()
+ .allowedFileTypes(FileTypeSet.ANY_FILE))
/* <!-- #BLAZE_RULE(genrule).ATTRIBUTE(tools) -->
A list of <i>tool</i> dependencies for this rule. See the definition of
@@ -104,12 +105,13 @@ public class GenRuleBaseRule implements RuleDefinition {
list, not in <code>srcs</code>, to ensure they are built in the correct configuration.
</p>
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("tools", LABEL_LIST).cfg(HOST)
- .allowedFileTypes(FileTypeSet.ANY_FILE))
- .add(attr("toolchains", LABEL_LIST)
- .allowedFileTypes(FileTypeSet.NO_FILE)
- .mandatoryNativeProviders(ImmutableList.<Class<? extends TransitiveInfoProvider>>of(
- ToolchainProvider.class)))
+ .add(attr("tools", LABEL_LIST).cfg(HOST).allowedFileTypes(FileTypeSet.ANY_FILE))
+ .add(
+ attr("toolchains", LABEL_LIST)
+ .allowedFileTypes(FileTypeSet.NO_FILE)
+ .mandatoryNativeProviders(
+ ImmutableList.<Class<? extends TransitiveInfoProvider>>of(
+ MakeVariableProvider.class)))
/* <!-- #BLAZE_RULE(genrule).ATTRIBUTE(outs) -->
A list of files generated by this rule.
@@ -179,8 +181,11 @@ public class GenRuleBaseRule implements RuleDefinition {
</p>
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
// TODO(bazel-team): find a location to document genfiles/binfiles, link to them from here.
- .add(attr("output_to_bindir", BOOLEAN).value(false)
- .nonconfigurable("policy decision: no reason for this to depend on the configuration"))
+ .add(
+ attr("output_to_bindir", BOOLEAN)
+ .value(false)
+ .nonconfigurable(
+ "policy decision: no reason for this to depend on the configuration"))
/* <!-- #BLAZE_RULE(genrule).ATTRIBUTE(local) -->
<p>
@@ -224,29 +229,31 @@ public class GenRuleBaseRule implements RuleDefinition {
</p>
<p>Declaring data dependencies for the generated executable is not supported.</p>
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("executable", BOOLEAN).value(false).nonconfigurable(
- "Used in computed default for $is_executable, which is itself non-configurable (and "
- + " thus expects its dependencies to be non-configurable), because $is_executable"
- + " is called from RunCommand.isExecutable, which has no configuration context"))
-
- .add(attr("$is_executable", BOOLEAN)
- .nonconfigurable("Called from RunCommand.isExecutable, which takes a Target")
- .value(
- new Attribute.ComputedDefault() {
- @Override
- public Object getDefault(AttributeMap rule) {
- return (rule.get("outs", BuildType.OUTPUT_LIST).size() == 1)
- && rule.get("executable", BOOLEAN);
- }
- }))
+ .add(
+ attr("executable", BOOLEAN)
+ .value(false)
+ .nonconfigurable(
+ "Used in computed default for $is_executable, which is itself non-configurable"
+ + " (and thus expects its dependencies to be non-configurable), because"
+ + " $is_executable is called from RunCommand.isExecutable, which has no"
+ + " configuration context"))
+ .add(
+ attr("$is_executable", BOOLEAN)
+ .nonconfigurable("Called from RunCommand.isExecutable, which takes a Target")
+ .value(
+ new Attribute.ComputedDefault() {
+ @Override
+ public Object getDefault(AttributeMap rule) {
+ return (rule.get("outs", BuildType.OUTPUT_LIST).size() == 1)
+ && rule.get("executable", BOOLEAN);
+ }
+ }))
// This is a misfeature, so don't document it. We would like to get rid of it, but that
// would require a cleanup of existing rules.
.add(attr("heuristic_label_expansion", BOOLEAN).value(false))
-
.removeAttribute("data")
.removeAttribute("deps")
-
.build();
}