aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2015-06-02 16:35:01 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-06-03 13:48:28 +0000
commit96d6687a7754fff5bb659b80e606ec5c4ede62a5 (patch)
treecaa52103090c1682024099f92c40b320eace6de8
parent3234b2be02472e6715945344d6f4077d49e1974b (diff)
Make sure that all system includes that are specified in the CROSSTOOL file are present in CppCompileAction#getSystemIncludeDirs.
-- MOS_MIGRATED_REVID=95014774
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
index 2ceecab5ef..b2380f92b6 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
@@ -476,12 +476,25 @@ public class CppCompileAction extends AbstractAction implements IncludeScannable
@Override
public List<PathFragment> getSystemIncludeDirs() {
+ // TODO(bazel-team): parsing the command line flags here couples us to gcc-style compiler
+ // command lines; use a different way to specify system includes (for example through a
+ // system_includes attribute in cc_toolchain); note that that would disallow users from
+ // specifying system include paths via the copts attribute.
+ // Currently, this works together with the include_paths features because getCommandLine() will
+ // get the system include paths from the CppCompilationContext instead.
ImmutableList.Builder<PathFragment> result = ImmutableList.builder();
- result.addAll(context.getSystemIncludeDirs());
- for (String opt : cppCompileCommandLine.copts) {
- if (opt.startsWith("-isystem") && opt.length() > 8) {
- // We insist on the combined form "-isystemdir".
- result.add(new PathFragment(opt.substring(8)));
+ List<String> compilerOptions = getCompilerOptions();
+ for (int i = 0; i < compilerOptions.size(); i++) {
+ String opt = compilerOptions.get(i);
+ if (opt.startsWith("-isystem")) {
+ if (opt.length() > 8) {
+ result.add(new PathFragment(opt.substring(8).trim()));
+ } else if (i + 1 < compilerOptions.size()) {
+ i++;
+ result.add(new PathFragment(compilerOptions.get(i)));
+ } else {
+ System.err.println("WARNING: dangling -isystem flag in options for " + prettyPrint());
+ }
}
}
return result.build();
@@ -1255,7 +1268,9 @@ public class CppCompileAction extends AbstractAction implements IncludeScannable
CcToolchainFeatures.Variables.Builder buildVariables =
new CcToolchainFeatures.Variables.Builder();
- if (featureConfiguration.isEnabled(CppRuleClasses.MODULE_MAPS)) {
+ if (featureConfiguration.isEnabled(CppRuleClasses.MODULE_MAPS) && cppModuleMap != null) {
+ // If the feature is enabled and cppModuleMap is null, we are about to fail during analysis
+ // in any case, but don't crash.
buildVariables.addVariable("module_name", cppModuleMap.getName());
buildVariables.addVariable("module_map_file",
cppModuleMap.getArtifact().getExecPathString());