From a47780541536764cf56d09f78a988d6155689c7f Mon Sep 17 00:00:00 2001 From: hlopko Date: Fri, 26 May 2017 11:37:28 +0200 Subject: Use FeatureConfiguration to compute value of CC_FLAGS make variable This cl introduces new action_config type for Crosstool named 'generic'. This can be used to set the value of CC_FLAGS make variable using much more expressive mechanism (action_configs + features) than previous make_variable Crosstool messages. This has been requested by the C++ LPT. However, as FeatureConfiguration needs RuleContext, CC_FLAGS cannot be computed using configuration only anymore. Also, FeatureConfiguration is C++ rules specific class, and Bazel build-base cannot depend on it. Therefore we cannot use FeatureConfiguration for ExtraActions, for example. Because it cannot be made perfect, this cl is not updating all the possible places that expand make variables but limits the scope to: * genrule (the only widely used rule that often expands make variables) * *_test (CC_FLAGS is used by Tensorflow in the 'args' attribute) * cc_rules (people sometimes set 'copts' to something like: "-DCC_STRING=\\\"$(CC)\\\" -DCC_FLAGS_STRING=\"$(CC_FLAGS)\"" The long term plan is to use Skylark C++ API to get C++ command lines, so CC_FLAGS together with this inconsistent solution will be removed. RELNOTES: CC_FLAGS can be defined using 'generic' action_config in CROSSTOOL PiperOrigin-RevId: 157202883 --- .../com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java') 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 4f540224ff..abb218d4d0 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 @@ -101,6 +101,7 @@ public final class CcLibraryHelper { CppFileTypes.ASSEMBLER, CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR), ImmutableSet.of( + CppCompileAction.CC_FLAGS_MAKE_VARIABLE_ACTION_NAME, CppCompileAction.C_COMPILE, CppCompileAction.CPP_COMPILE, CppCompileAction.CPP_HEADER_PARSING, @@ -128,6 +129,7 @@ public final class CcLibraryHelper { CppFileTypes.ASSEMBLER, CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR), ImmutableSet.of( + CppCompileAction.CC_FLAGS_MAKE_VARIABLE_ACTION_NAME, CppCompileAction.C_COMPILE, CppCompileAction.CPP_COMPILE, CppCompileAction.OBJC_COMPILE, @@ -147,9 +149,9 @@ public final class CcLibraryHelper { Link.LinkTargetType.EXECUTABLE.getActionName())); private final FileTypeSet sourceTypeSet; - private final Set actionConfigSet; + private final ImmutableSet actionConfigSet; - private SourceCategory(FileTypeSet sourceTypeSet, Set actionConfigSet) { + private SourceCategory(FileTypeSet sourceTypeSet, ImmutableSet actionConfigSet) { this.sourceTypeSet = sourceTypeSet; this.actionConfigSet = actionConfigSet; } -- cgit v1.2.3