aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
index 94d9495911..81febbc1ea 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
@@ -673,19 +673,11 @@ public final class CcCommon {
withBaselineCoverage);
}
- private static String getHostOrNonHostFeature(RuleContext ruleContext) {
- if (ruleContext.getConfiguration().isHostConfiguration()) {
- return "host";
- } else {
- return "nonhost";
- }
- }
-
- public static ImmutableList<String> getCoverageFeatures(RuleContext ruleContext) {
+ public static ImmutableList<String> getCoverageFeatures(CcToolchainProvider toolchain) {
ImmutableList.Builder<String> coverageFeatures = ImmutableList.builder();
- if (ruleContext.getConfiguration().isCodeCoverageEnabled()) {
+ if (toolchain.isCodeCoverageEnabled()) {
coverageFeatures.add(CppRuleClasses.COVERAGE);
- if (ruleContext.getFragment(CppConfiguration.class).useLLVMCoverageMapFormat()) {
+ if (toolchain.useLLVMCoverageMapFormat()) {
coverageFeatures.add(CppRuleClasses.LLVM_COVERAGE_MAP_FORMAT);
} else {
coverageFeatures.add(CppRuleClasses.GCC_COVERAGE_MAP_FORMAT);
@@ -704,6 +696,7 @@ public final class CcCommon {
ImmutableSet<String> requestedFeatures,
ImmutableSet<String> unsupportedFeatures,
CcToolchainProvider toolchain) {
+ CppConfiguration cppConfiguration = toolchain.getCppConfiguration();
ImmutableSet.Builder<String> allRequestedFeaturesBuilder = ImmutableSet.builder();
ImmutableSet.Builder<String> unsupportedFeaturesBuilder = ImmutableSet.builder();
unsupportedFeaturesBuilder.addAll(unsupportedFeatures);
@@ -742,21 +735,23 @@ public final class CcCommon {
ImmutableList.Builder<String> allFeatures =
new ImmutableList.Builder<String>()
- .addAll(
- ImmutableSet.of(
- toolchain.getCompilationMode().toString(),
- getHostOrNonHostFeature(ruleContext)))
+ .addAll(ImmutableSet.of(toolchain.getCompilationMode().toString()))
.addAll(DEFAULT_FEATURES)
.addAll(DEFAULT_ACTION_CONFIGS)
.addAll(requestedFeatures)
.addAll(toolchain.getFeatures().getDefaultFeaturesAndActionConfigs());
- if (CppHelper.useFission(ruleContext.getFragment(CppConfiguration.class), toolchain)) {
- allFeatures.add(CppRuleClasses.PER_OBJECT_DEBUG_INFO);
+
+ if (toolchain.isHostConfiguration()) {
+ allFeatures.add("host");
+ } else {
+ allFeatures.add("nonhost");
}
- CppConfiguration cppConfiguration = toolchain.getCppConfiguration();
+ if (CppHelper.useFission(cppConfiguration, toolchain)) {
+ allFeatures.add(CppRuleClasses.PER_OBJECT_DEBUG_INFO);
+ }
- allFeatures.addAll(getCoverageFeatures(ruleContext));
+ allFeatures.addAll(getCoverageFeatures(toolchain));
if (cppConfiguration.getFdoInstrument() != null
&& !allUnsupportedFeatures.contains(CppRuleClasses.FDO_INSTRUMENT)) {