aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
diff options
context:
space:
mode:
authorGravatar Cal Peyser <cpeyser@google.com>2016-09-01 14:02:58 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-09-01 14:50:05 +0000
commit530876d5d6b80a94b0861a3684178cbb7f5072e8 (patch)
tree57c661726bd94113bc0f96ded9ce2bb386f1b703 /src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
parent5748e2d444616a533de6261f07cb9c50da8743a9 (diff)
Create injectable semantics for include validation, to allow it to be turned
off in the objc case. -- MOS_MIGRATED_REVID=131943500
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java56
1 files changed, 31 insertions, 25 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 0debf56da0..308b7a0686 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
@@ -176,6 +176,7 @@ public class CppCompileAction extends AbstractAction
private final FeatureConfiguration featureConfiguration;
protected final Class<? extends CppCompileActionContext> actionContext;
private final SpecialInputsHandler specialInputsHandler;
+ private final CppSemantics semantics;
/**
* Identifier for the actual execution time behavior of the action.
@@ -202,32 +203,29 @@ public class CppCompileAction extends AbstractAction
/**
* Creates a new action to compile C/C++ source files.
*
- * @param owner the owner of the action, usually the configured target that
- * emitted it
- * @param sourceFile the source file that should be compiled. {@code mandatoryInputs} must
- * contain this file
- * @param shouldScanIncludes a boolean indicating whether scanning of {@code sourceFile}
- * is to be performed looking for inclusions.
+ * @param owner the owner of the action, usually the configured target that emitted it
+ * @param sourceFile the source file that should be compiled. {@code mandatoryInputs} must contain
+ * this file
+ * @param shouldScanIncludes a boolean indicating whether scanning of {@code sourceFile} is to be
+ * performed looking for inclusions.
* @param sourceLabel the label of the rule the source file is generated by
- * @param mandatoryInputs any additional files that need to be present for the
- * compilation to succeed, can be empty but not null, for example, extra sources for FDO.
- * @param outputFile the object file that is written as result of the
- * compilation, or the fake object for {@link FakeCppCompileAction}s
- * @param dotdFile the .d file that is generated as a side-effect of
- * compilation
- * @param gcnoFile the coverage notes that are written in coverage mode, can
- * be null
- * @param dwoFile the .dwo output file where debug information is stored for Fission
- * builds (null if Fission mode is disabled)
+ * @param mandatoryInputs any additional files that need to be present for the compilation to
+ * succeed, can be empty but not null, for example, extra sources for FDO.
+ * @param outputFile the object file that is written as result of the compilation, or the fake
+ * object for {@link FakeCppCompileAction}s
+ * @param dotdFile the .d file that is generated as a side-effect of compilation
+ * @param gcnoFile the coverage notes that are written in coverage mode, can be null
+ * @param dwoFile the .dwo output file where debug information is stored for Fission builds (null
+ * if Fission mode is disabled)
* @param optionalSourceFile an additional optional source file (null if unneeded)
* @param configuration the build configurations
* @param context the compilation context
* @param copts options for the compiler
* @param coptsFilter regular expression to remove options from {@code copts}
* @param executionRequirements out-of-band hints to be passed to the execution backend to signal
- * platform requirements
+ * platform requirements
* @param actionName a string giving the name of this action for the purpose of toolchain
- * evaluation
+ * evaluation
*/
protected CppCompileAction(
ActionOwner owner,
@@ -258,7 +256,8 @@ public class CppCompileAction extends AbstractAction
ImmutableSet<String> executionRequirements,
ImmutableMap<String, String> environment,
String actionName,
- RuleContext ruleContext) {
+ RuleContext ruleContext,
+ CppSemantics semantics) {
super(
owner,
createInputs(
@@ -297,6 +296,7 @@ public class CppCompileAction extends AbstractAction
// artifact and will definitely exist prior to this action execution.
this.mandatoryInputs = mandatoryInputs;
this.builtinIncludeFiles = CppHelper.getToolchain(ruleContext).getBuiltinIncludeFiles();
+ this.semantics = semantics;
verifyIncludePaths(ruleContext);
}
@@ -994,7 +994,10 @@ public class CppCompileAction extends AbstractAction
problems.add(execPathFragment.getPathString());
}
}
- problems.assertProblemFree(this, getSourceFile());
+ //TODO(b/22551695): Remove in favor of seperate implementations.
+ if (semantics.needsIncludeValidation()) {
+ problems.assertProblemFree(this, getSourceFile());
+ }
} catch (IOException e) {
// Some kind of IO or parse exception--wrap & rethrow it to stop the build.
throw new ActionExecutionException("error while parsing .d file", e, this, false);
@@ -1196,11 +1199,14 @@ public class CppCompileAction extends AbstractAction
updateActionInputs(discoveredInputs);
}
- // hdrs_check: This cannot be switched off, because doing so would allow for incorrect builds.
- validateInclusions(
- discoveredInputs,
- actionExecutionContext.getArtifactExpander(),
- executor.getEventHandler());
+ // hdrs_check: Turning this off opens the door to incorrect builds. However, we allow it
+ // to accommodate the current behavior in the objc rules.
+ if (semantics.needsIncludeValidation()) {
+ validateInclusions(
+ discoveredInputs,
+ actionExecutionContext.getArtifactExpander(),
+ executor.getEventHandler());
+ }
}
/**