aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp
diff options
context:
space:
mode:
authorGravatar hlopko <hlopko@google.com>2017-08-10 11:21:46 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-08-10 13:48:19 +0200
commit1e91fa5da8a1833b66984ec470295002d328b7f9 (patch)
tree87278f3a5b65b66c83b20a9d5d2f5356b088f83e /src/main/java/com/google/devtools/build/lib/rules/cpp
parentb79a9fcd40f448d3aebb2b93a2ebe80d09b38408 (diff)
Only patch in C++ compile features when they are not already defined in crosstool
RELNOTES: None. PiperOrigin-RevId: 164830825
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java134
1 files changed, 71 insertions, 63 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java
index a6ba263e24..4bc7fa19f8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java
@@ -132,59 +132,65 @@ public class CppActionConfigs {
// -M[M]D alone breaks some of the .d naming assumptions
// This combination gets user and system includes with specified name:
// -MD -MF <name>
- "feature {",
- " name: 'dependency_file'",
- " flag_set {",
- " action: 'assemble'",
- " action: 'preprocess-assemble'",
- " action: 'c-compile'",
- " action: 'c++-compile'",
- " action: 'c++-module-compile'",
- " action: 'objc-compile'",
- " action: 'objc++-compile'",
- " action: 'c++-header-preprocessing'",
- " action: 'c++-header-parsing'",
- " action: 'clif-match'",
- " expand_if_all_available: 'dependency_file'",
- " flag_group {",
- " flag: '-MD'",
- " flag: '-MF'",
- " flag: '%{dependency_file}'",
- " }",
- " }",
- "}",
+ ifTrue(
+ !features.contains(CppRuleClasses.DEPENDENCY_FILE),
+ "feature {",
+ " name: 'dependency_file'",
+ " flag_set {",
+ " action: 'assemble'",
+ " action: 'preprocess-assemble'",
+ " action: 'c-compile'",
+ " action: 'c++-compile'",
+ " action: 'c++-module-compile'",
+ " action: 'objc-compile'",
+ " action: 'objc++-compile'",
+ " action: 'c++-header-preprocessing'",
+ " action: 'c++-header-parsing'",
+ " action: 'clif-match'",
+ " expand_if_all_available: 'dependency_file'",
+ " flag_group {",
+ " flag: '-MD'",
+ " flag: '-MF'",
+ " flag: '%{dependency_file}'",
+ " }",
+ " }",
+ "}"),
// GCC and Clang give randomized names to symbols which are defined in
// an anonymous namespace but have external linkage. To make
// computation of these deterministic, we want to override the
// default seed for the random number generator. It's safe to use
// any value which differs for all translation units; we use the
// path to the object file.
- "feature {",
- " name: 'random_seed'",
- " flag_set {",
- " action: 'c++-compile'",
- " action: 'c++-module-codegen'",
- " action: 'c++-module-compile'",
- " flag_group {",
- " flag: '-frandom-seed=%{output_file}'",
- " }",
- " }",
- "}",
- "feature {",
- " name: 'pic'",
- " flag_set {",
- " action: 'assemble'",
- " action: 'preprocess-assemble'",
- " action: 'c-compile'",
- " action: 'c++-compile'",
- " action: 'c++-module-codegen'",
- " action: 'c++-module-compile'",
- " expand_if_all_available: 'pic'",
- " flag_group {",
- " flag: '-fPIC'",
- " }",
- " }",
- "}",
+ ifTrue(
+ !features.contains(CppRuleClasses.RANDOM_SEED),
+ "feature {",
+ " name: 'random_seed'",
+ " flag_set {",
+ " action: 'c++-compile'",
+ " action: 'c++-module-codegen'",
+ " action: 'c++-module-compile'",
+ " flag_group {",
+ " flag: '-frandom-seed=%{output_file}'",
+ " }",
+ " }",
+ "}"),
+ ifTrue(
+ !features.contains(CppRuleClasses.PIC),
+ "feature {",
+ " name: 'pic'",
+ " flag_set {",
+ " action: 'assemble'",
+ " action: 'preprocess-assemble'",
+ " action: 'c-compile'",
+ " action: 'c++-compile'",
+ " action: 'c++-module-codegen'",
+ " action: 'c++-module-compile'",
+ " expand_if_all_available: 'pic'",
+ " flag_group {",
+ " flag: '-fPIC'",
+ " }",
+ " }",
+ "}"),
ifTrue(
!features.contains(CppRuleClasses.PER_OBJECT_DEBUG_INFO),
"feature {",
@@ -201,22 +207,24 @@ public class CppActionConfigs {
" }",
" }",
"}"),
- "feature {",
- " name: 'preprocessor_defines'",
- " flag_set {",
- " action: 'preprocess-assemble'",
- " action: 'c-compile'",
- " action: 'c++-compile'",
- " action: 'c++-header-parsing'",
- " action: 'c++-header-preprocessing'",
- " action: 'c++-module-compile'",
- " action: 'clif-match'",
- " flag_group {",
- " iterate_over: 'preprocessor_defines'",
- " flag: '-D%{preprocessor_defines}'",
- " }",
- " }",
- "}",
+ ifTrue(
+ !features.contains(CppRuleClasses.PREPROCESSOR_DEFINES),
+ "feature {",
+ " name: 'preprocessor_defines'",
+ " flag_set {",
+ " action: 'preprocess-assemble'",
+ " action: 'c-compile'",
+ " action: 'c++-compile'",
+ " action: 'c++-header-parsing'",
+ " action: 'c++-header-preprocessing'",
+ " action: 'c++-module-compile'",
+ " action: 'clif-match'",
+ " flag_group {",
+ " iterate_over: 'preprocessor_defines'",
+ " flag: '-D%{preprocessor_defines}'",
+ " }",
+ " }",
+ "}"),
ifTrue(
!features.contains(CppRuleClasses.INCLUDE_PATHS),
"feature {",