diff options
author | 2017-01-27 10:02:36 +0000 | |
---|---|---|
committer | 2017-01-27 10:13:25 +0000 | |
commit | 7e7d6094b26e906ea0714e3b006f1458dfc3b825 (patch) | |
tree | 5fb6e002089b3a19ae7c9f1fe096df814fd06b09 | |
parent | d6eaf589416338b03f6965009d1556099ca316ff (diff) |
Unify CppCompileActionContext#{getScannedIncludeFiles,findAdditionalInputs}.
They differed only in reporting action state and the way they reported "no include scanning happened" so there was no reason to have both of them around.
--
PiperOrigin-RevId: 145773972
MOS_MIGRATED_REVID=145773972
3 files changed, 30 insertions, 26 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 12cb38cb85..ed88bebca5 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 @@ -26,6 +26,7 @@ import com.google.devtools.build.lib.actions.ActionExecutionContext; import com.google.devtools.build.lib.actions.ActionExecutionException; import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.ActionOwner; +import com.google.devtools.build.lib.actions.ActionStatusMessage; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander; import com.google.devtools.build.lib.actions.ArtifactResolver; @@ -506,15 +507,24 @@ public class CppCompileAction extends AbstractAction public Iterable<Artifact> discoverInputs(ActionExecutionContext actionExecutionContext) throws ActionExecutionException, InterruptedException { Executor executor = actionExecutionContext.getExecutor(); - Collection<Artifact> initialResult; - - try { - initialResult = executor.getContext(actionContext) - .findAdditionalInputs(this, actionExecutionContext); - } catch (ExecException e) { - throw e.toActionExecutionException("Include scanning of rule '" + getOwner().getLabel() + "'", - executor.getVerboseFailures(), this); + Collection<Artifact> initialResult = null; + + // Switch running status to "analysis". + if (shouldScanIncludes()) { + actionExecutionContext.getExecutor().getEventBus() + .post(ActionStatusMessage.analysisStrategy(this)); + + try { + initialResult = executor.getContext(actionContext) + .findAdditionalInputs(this, actionExecutionContext); + } catch (ExecException e) { + throw e.toActionExecutionException( + "Include scanning of rule '" + getOwner().getLabel() + "'", + executor.getVerboseFailures(), + this); + } } + if (initialResult == null) { // We will find inputs during execution. Store an empty list to show we did try to discover // inputs and return null to inform the caller that inputs will be discovered later. @@ -1372,9 +1382,18 @@ public class CppCompileAction extends AbstractAction public Iterable<Artifact> getInputFilesForExtraAction( ActionExecutionContext actionExecutionContext) throws ActionExecutionException, InterruptedException { - Collection<Artifact> scannedIncludes = - actionExecutionContext.getExecutor().getContext(actionContext) - .getScannedIncludeFiles(this, actionExecutionContext); + Collection<Artifact> scannedIncludes; + try { + scannedIncludes = actionExecutionContext.getExecutor().getContext(actionContext) + .findAdditionalInputs(this, actionExecutionContext); + } catch (ExecException e) { + throw e.toActionExecutionException(this); + } + + if (scannedIncludes == null) { + return ImmutableList.of(); + } + // Use a set to eliminate duplicates. ImmutableSet.Builder<Artifact> result = ImmutableSet.builder(); return result.addAll(getInputs()).addAll(scannedIncludes).build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionContext.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionContext.java index b306fd06a8..33b83454b2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionContext.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionContext.java @@ -68,12 +68,4 @@ public interface CppCompileActionContext extends ActionContext { * Returns the estimated resource consumption of the action. */ ResourceSet estimateResourceConsumption(CppCompileAction action); - - /** - * Returns the include files that should be shipped to the executor in addition the ones that - * were declared. - */ - Collection<Artifact> getScannedIncludeFiles( - CppCompileAction action, ActionExecutionContext actionExecutionContext) - throws ActionExecutionException, InterruptedException; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/SpawnGccStrategy.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/SpawnGccStrategy.java index 1025068f76..acf9f26974 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/SpawnGccStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/SpawnGccStrategy.java @@ -14,7 +14,6 @@ package com.google.devtools.build.lib.rules.cpp; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.ActionExecutionContext; @@ -81,12 +80,6 @@ public class SpawnGccStrategy implements CppCompileActionContext { } @Override - public Collection<Artifact> getScannedIncludeFiles( - CppCompileAction action, ActionExecutionContext actionExecutionContext) { - return ImmutableList.of(); - } - - @Override public Reply getReplyFromException(ExecException e, CppCompileAction action) { return null; } |