Replace getToolsRepository() with getToolsLabel(String labelValue) which prepends the tools repository path to the given string and parses the result as a label.
This is a cleaner way to access the tools repository label.
--
MOS_MIGRATED_REVID=114105929
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java b/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java
index 9f592fa..2c340bf 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java
@@ -164,7 +164,7 @@
.add(attr("args", STRING_LIST)
.nonconfigurable("policy decision: should be consistent across configurations"))
.add(attr("$test_runtime", LABEL_LIST).cfg(HOST).value(ImmutableList.of(
- env.getLabel(env.getToolsRepository() + "//tools/test:runtime"))))
+ env.getToolsLabel("//tools/test:runtime"))))
// TODO(bazel-team): TestActions may need to be run with coverage, so all tests
// implicitly depend on crosstool, which provides gcov. We could add gcov to
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
index 746eb9e..62ab8a6 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
@@ -130,7 +130,7 @@
this.runfilesPrefix = runfilesPrefix;
return this;
}
-
+
public Builder setToolsRepository(String toolsRepository) {
this.toolsRepository = toolsRepository;
return this;
@@ -271,10 +271,10 @@
public Label getLabel(String labelValue) {
return LABELS.getUnchecked(labelValue);
}
-
+
@Override
- public String getToolsRepository() {
- return toolsRepository;
+ public Label getToolsLabel(String labelValue) {
+ return getLabel(toolsRepository + labelValue);
}
}
@@ -309,7 +309,7 @@
* The default runfiles prefix.
*/
private final String runfilesPrefix;
-
+
/**
* The path to the tools repository.
*/
@@ -405,7 +405,7 @@
public String getRunfilesPrefix() {
return runfilesPrefix;
}
-
+
@Override
public String getToolsRepository() {
return toolsRepository;
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleDefinitionEnvironment.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleDefinitionEnvironment.java
index 2eab411..45200fb 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleDefinitionEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleDefinitionEnvironment.java
@@ -28,7 +28,8 @@
Label getLabel(String labelValue);
/**
- * Returns the path to the tools repository. It is different for blaze and bazel.
+ * Prepends the tools repository path to the given string and parses the result
+ * using {@link RuleDefinitionEnvironment#getLabel}
*/
- String getToolsRepository();
+ Label getToolsLabel(String labelValue);
}