diff options
author | hlopko <hlopko@google.com> | 2017-12-19 01:23:10 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-19 01:25:08 -0800 |
commit | e48a9c855614f61b95e3bc694687f49b8d957a78 (patch) | |
tree | 244984871275dcf282ed917afe2dcab0d507abad /src/main/java/com/google/devtools/build | |
parent | cf1d6c4724b32b07a2f0e21942b562d0bacedbc1 (diff) |
Remove source category from CcCommon.configureFeatures
Inline SourceCategory.CC action configs, as CC is the only source category that
is ever passed to this method.
RELNOTES: None.
PiperOrigin-RevId: 179522955
Diffstat (limited to 'src/main/java/com/google/devtools/build')
3 files changed, 32 insertions, 94 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 053e56f930..24666bd7b0 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 @@ -87,6 +87,31 @@ public final class CcCommon { } }; + /** Action configs we request to enable. */ + private static final ImmutableSet<String> DEFAULT_ACTION_CONFIGS = + ImmutableSet.of( + CppCompileAction.CC_FLAGS_MAKE_VARIABLE_ACTION_NAME, + CppCompileAction.STRIP_ACTION_NAME, + CppCompileAction.C_COMPILE, + CppCompileAction.CPP_COMPILE, + CppCompileAction.CPP_HEADER_PARSING, + CppCompileAction.CPP_HEADER_PREPROCESSING, + CppCompileAction.CPP_MODULE_COMPILE, + CppCompileAction.CPP_MODULE_CODEGEN, + CppCompileAction.ASSEMBLE, + CppCompileAction.PREPROCESS_ASSEMBLE, + CppCompileAction.CLIF_MATCH, + CppCompileAction.LINKSTAMP_COMPILE, + Link.LinkTargetType.STATIC_LIBRARY.getActionName(), + // We need to create pic-specific actions for link actions, as they will produce + // differently named outputs. + Link.LinkTargetType.PIC_STATIC_LIBRARY.getActionName(), + Link.LinkTargetType.INTERFACE_DYNAMIC_LIBRARY.getActionName(), + Link.LinkTargetType.DYNAMIC_LIBRARY.getActionName(), + Link.LinkTargetType.ALWAYS_LINK_STATIC_LIBRARY.getActionName(), + Link.LinkTargetType.ALWAYS_LINK_PIC_STATIC_LIBRARY.getActionName(), + Link.LinkTargetType.EXECUTABLE.getActionName()); + /** Features we request to enable unless a rule explicitly doesn't support them. */ private static final ImmutableSet<String> DEFAULT_FEATURES = ImmutableSet.of( @@ -570,18 +595,12 @@ public final class CcCommon { /** * Creates the feature configuration for a given rule. * - * @see CcCommon#configureFeatures( - * RuleContext, FeatureSpecification, SourceCategory, CcToolchainProvider) - * - * @param features CcToolchainFeatures instance to use to get FeatureConfiguration * @return the feature configuration for the given {@code ruleContext}. */ public static FeatureConfiguration configureFeatures( RuleContext ruleContext, FeatureSpecification featureSpecification, - SourceCategory sourceCategory, - CcToolchainProvider toolchain, - CcToolchainFeatures features) { + CcToolchainProvider toolchain) { ImmutableSet.Builder<String> unsupportedFeaturesBuilder = ImmutableSet.builder(); unsupportedFeaturesBuilder.addAll(featureSpecification.getUnsupportedFeatures()); if (!toolchain.supportsHeaderParsing()) { @@ -623,13 +642,13 @@ public final class CcCommon { } requestedFeatures.addAll(featureSpecification.getRequestedFeatures()); - requestedFeatures.addAll(sourceCategory.getActionConfigSet()); + requestedFeatures.addAll(DEFAULT_ACTION_CONFIGS); FeatureSpecification currentFeatureSpecification = FeatureSpecification.create(requestedFeatures.build(), unsupportedFeatures); try { FeatureConfiguration configuration = - features.getFeatureConfiguration(currentFeatureSpecification); + toolchain.getFeatures().getFeatureConfiguration(currentFeatureSpecification); for (String feature : unsupportedFeatures) { if (configuration.isEnabled(feature)) { ruleContext.ruleError( @@ -650,37 +669,6 @@ public final class CcCommon { } } - - /** - * Creates the feature configuration for a given rule. - * - * @see CcCommon#configureFeatures(RuleContext, CcToolchainProvider, SourceCategory) - * - * @param toolchain the current toolchain provider - * @return the feature configuration for the given {@code ruleContext}. - */ - public static FeatureConfiguration configureFeatures( - RuleContext ruleContext, - FeatureSpecification featureSpecification, - SourceCategory sourceCategory, - CcToolchainProvider toolchain) { - return configureFeatures( - ruleContext, featureSpecification, sourceCategory, toolchain, toolchain.getFeatures()); - } - - /** - * Creates a feature configuration for a given rule. - * - * @see CcCommon#configureFeatures(RuleContext, CcToolchainProvider) - * - * @param sourceCategory the category of sources to be used in this build. - * @return the feature configuration for the given {@code ruleContext}. - */ - public static FeatureConfiguration configureFeatures( - RuleContext ruleContext, CcToolchainProvider toolchain, SourceCategory sourceCategory) { - return configureFeatures(ruleContext, FeatureSpecification.EMPTY, sourceCategory, toolchain); - } - /** * Creates a feature configuration for a given rule. Assumes strictly cc sources. * @@ -690,7 +678,7 @@ public final class CcCommon { */ public static FeatureConfiguration configureFeatures( RuleContext ruleContext, CcToolchainProvider toolchain) { - return configureFeatures(ruleContext, toolchain, SourceCategory.CC); + return configureFeatures(ruleContext, FeatureSpecification.EMPTY, toolchain); } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java index bdedfa8751..83a36f74a3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java @@ -106,29 +106,7 @@ public final class CcLibraryHelper { CppFileTypes.CPP_HEADER, CppFileTypes.C_SOURCE, CppFileTypes.ASSEMBLER, - CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR), - ImmutableSet.<String>of( - CppCompileAction.CC_FLAGS_MAKE_VARIABLE_ACTION_NAME, - CppCompileAction.STRIP_ACTION_NAME, - CppCompileAction.C_COMPILE, - CppCompileAction.CPP_COMPILE, - CppCompileAction.CPP_HEADER_PARSING, - CppCompileAction.CPP_HEADER_PREPROCESSING, - CppCompileAction.CPP_MODULE_COMPILE, - CppCompileAction.CPP_MODULE_CODEGEN, - CppCompileAction.ASSEMBLE, - CppCompileAction.PREPROCESS_ASSEMBLE, - CppCompileAction.CLIF_MATCH, - CppCompileAction.LINKSTAMP_COMPILE, - Link.LinkTargetType.STATIC_LIBRARY.getActionName(), - // We need to create pic-specific actions for link actions, as they will produce - // differently named outputs. - Link.LinkTargetType.PIC_STATIC_LIBRARY.getActionName(), - Link.LinkTargetType.INTERFACE_DYNAMIC_LIBRARY.getActionName(), - Link.LinkTargetType.DYNAMIC_LIBRARY.getActionName(), - Link.LinkTargetType.ALWAYS_LINK_STATIC_LIBRARY.getActionName(), - Link.LinkTargetType.ALWAYS_LINK_PIC_STATIC_LIBRARY.getActionName(), - Link.LinkTargetType.EXECUTABLE.getActionName())), + CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR)), CC_AND_OBJC( FileTypeSet.of( CppFileTypes.CPP_SOURCE, @@ -137,34 +115,12 @@ public final class CcLibraryHelper { CppFileTypes.OBJCPP_SOURCE, CppFileTypes.C_SOURCE, CppFileTypes.ASSEMBLER, - CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR), - ImmutableSet.<String>of( - CppCompileAction.CC_FLAGS_MAKE_VARIABLE_ACTION_NAME, - CppCompileAction.C_COMPILE, - CppCompileAction.CPP_COMPILE, - CppCompileAction.OBJC_COMPILE, - CppCompileAction.OBJCPP_COMPILE, - CppCompileAction.CPP_HEADER_PARSING, - CppCompileAction.CPP_HEADER_PREPROCESSING, - CppCompileAction.ASSEMBLE, - CppCompileAction.PREPROCESS_ASSEMBLE, - CppCompileAction.LINKSTAMP_COMPILE, - Link.LinkTargetType.STATIC_LIBRARY.getActionName(), - // We need to create pic-specific actions for link actions, as they will produce - // differently named outputs. - Link.LinkTargetType.PIC_STATIC_LIBRARY.getActionName(), - Link.LinkTargetType.INTERFACE_DYNAMIC_LIBRARY.getActionName(), - Link.LinkTargetType.DYNAMIC_LIBRARY.getActionName(), - Link.LinkTargetType.ALWAYS_LINK_STATIC_LIBRARY.getActionName(), - Link.LinkTargetType.ALWAYS_LINK_PIC_STATIC_LIBRARY.getActionName(), - Link.LinkTargetType.EXECUTABLE.getActionName())); + CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR)); private final FileTypeSet sourceTypeSet; - private final ImmutableSet<String> actionConfigSet; - private SourceCategory(FileTypeSet sourceTypeSet, ImmutableSet<String> actionConfigSet) { + private SourceCategory(FileTypeSet sourceTypeSet) { this.sourceTypeSet = sourceTypeSet; - this.actionConfigSet = actionConfigSet; } /** @@ -173,11 +129,6 @@ public final class CcLibraryHelper { public FileTypeSet getSourceTypes() { return sourceTypeSet; } - - /** Returns the set of enabled actions for this category. */ - public Set<String> getActionConfigSet() { - return actionConfigSet; - } } /** Function for extracting module maps from CppCompilationDependencies. */ diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java index 8cb5fe7bbe..37b68a8ce0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java @@ -215,7 +215,6 @@ public class CcProtoAspect extends NativeAspectClass implements ConfiguredAspect CcCommon.configureFeatures( ruleContext, FeatureSpecification.create(requestedFeatures.build(), unsupportedFeatures.build()), - CcLibraryHelper.SourceCategory.CC, ccToolchain(ruleContext)); return featureConfiguration; } |