aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar dbabkin <dbabkin@google.com>2018-06-07 05:19:54 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-07 05:22:04 -0700
commit2df323407b1df9c50b12d9de9febf7a6f0cd19bd (patch)
treea5e726f8b0f35afbb04f4be5973e52bedac6a863
parentf137cea0ac74334013e7b064e59d1624cf032ac4 (diff)
Add LabelLateBoundDefault to :coverage_report_generator attribute
RELNOTES:none PiperOrigin-RevId: 199619691
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/BaseRuleClasses.java19
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleClassFunctions.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/test/TestActionBuilder.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java3
4 files changed, 27 insertions, 5 deletions
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 e38a5e41d6..86c5cd62d2 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
@@ -95,6 +95,19 @@ public class BaseRuleClasses {
TestConfiguration.class, defaultValue, COVERAGE_SUPPORT_CONFIGURATION_RESOLVER);
}
+ public static final String DEFAULT_COVERAGE_REPORT_GENERATOR_VALUE =
+ "//tools/test:coverage_report_generator";
+
+ @AutoCodec
+ static final Resolver<TestConfiguration, Label> COVERAGE_REPORT_GENERATOR_CONFIGURATION_RESOLVER =
+ (rule, attributes, configuration) -> configuration.getCoverageReportGenerator();
+
+ public static LabelLateBoundDefault<TestConfiguration> coverageReportGeneratorAttribute(
+ Label defaultValue) {
+ return LabelLateBoundDefault.fromTargetConfiguration(
+ TestConfiguration.class, defaultValue, COVERAGE_REPORT_GENERATOR_CONFIGURATION_RESOLVER);
+ }
+
// TODO(b/65746853): provide a way to do this without passing the entire configuration
/** Implementation for the :run_under attribute. */
@AutoCodec
@@ -170,9 +183,11 @@ public class BaseRuleClasses {
coverageSupportAttribute(env.getToolsLabel(DEFAULT_COVERAGE_SUPPORT_VALUE))))
// Used in the one-per-build coverage report generation action.
.add(
- attr("$coverage_report_generator", LABEL)
+ attr(":coverage_report_generator", LABEL)
.cfg(HostTransition.INSTANCE)
- .value(env.getLabel("//tools/defaults:coverage_report_generator"))
+ .value(
+ coverageReportGeneratorAttribute(
+ env.getToolsLabel(DEFAULT_COVERAGE_REPORT_GENERATOR_VALUE)))
.singleArtifact())
// The target itself and run_under both run on the same machine. We use the DATA config
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleClassFunctions.java b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleClassFunctions.java
index 73236d45da..5c386177b8 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleClassFunctions.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleClassFunctions.java
@@ -191,9 +191,13 @@ public class SkylarkRuleClassFunctions implements SkylarkRuleFunctionsApi<Artifa
toolsRepository + BaseRuleClasses.DEFAULT_COVERAGE_SUPPORT_VALUE))))
// Used in the one-per-build coverage report generation action.
.add(
- attr("$coverage_report_generator", LABEL)
+ attr(":coverage_report_generator", LABEL)
.cfg(HostTransition.INSTANCE)
- .value(labelCache.getUnchecked("//tools/defaults:coverage_report_generator"))
+ .value(
+ BaseRuleClasses.coverageReportGeneratorAttribute(
+ labelCache.getUnchecked(
+ toolsRepository
+ + BaseRuleClasses.DEFAULT_COVERAGE_REPORT_GENERATOR_VALUE)))
.singleArtifact())
.add(attr(":run_under", LABEL).cfg(lipoDataTransition).value(RUN_UNDER))
.build();
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/TestActionBuilder.java b/src/main/java/com/google/devtools/build/lib/analysis/test/TestActionBuilder.java
index b6b59414f6..e421c15596 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/test/TestActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/test/TestActionBuilder.java
@@ -329,7 +329,7 @@ public final class TestActionBuilder {
// contain rules with baseline coverage but no test rules that have coverage enabled, and in
// that case, we still need the report generator.
reportGenerator = ruleContext.getPrerequisiteArtifact(
- "$coverage_report_generator", Mode.HOST);
+ ":coverage_report_generator", Mode.HOST);
}
return new TestParams(runsPerTest, shards, TestTimeout.getTestTimeout(ruleContext.getRule()),
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java
index 1749528904..1eb91467de 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/test/TestConfiguration.java
@@ -180,7 +180,10 @@ public class TestConfiguration extends Fragment {
@Override
public FragmentOptions getHost() {
TestOptions hostOptions = (TestOptions) getDefault();
+ // These fields are used in late-bound attributes, which must not be null in the host
+ // configuration.
hostOptions.coverageSupport = this.coverageSupport;
+ hostOptions.coverageReportGenerator = this.coverageReportGenerator;
return hostOptions;
}
}