aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/PseudoAction.java
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2017-08-24 00:44:45 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-08-24 14:00:00 +0200
commit3fb6ac385df80a5f583072c0b84247d503e330b7 (patch)
treef708d2e1132a71236307bb1bce3f2179b7701bad /src/main/java/com/google/devtools/build/lib/analysis/PseudoAction.java
parent4e08dfcf563f1ef036a1561bd5312ad469077049 (diff)
Allow CommandLine expansion to throw an exception.
This paves the way for Skylark-side compact command lines that can fail during expansion. In general, expansion happens in these scenarios: * Action execution expands the command line to execute it. This is fine since we are well equipped already to handle failing actions. * In the analysis phase we expand command lines to investigate whether we need a params file. This could be moved to the execution phase, which would have the benefit of getting params files out of the action graph and saving memory. * Key computation expands the command line. This could be fixed by allowing command lines to compute their own keys (which wouldn't try to expand the command line). This could have the benefit of being more efficient. * Extra actions expand the command line to construct the extra action proto. This could maybe be deferred to the execution phase (writing the extra action), which would also be more memory efficient. For failed key computations, we return a singleton "error" key. This means multiple actions that will fail will map to the same key. These actions will necessarily fail if executed, so we should not need to worry about these ending up in the action cache. If we do manage to make the command line compute its own keys then this will become moot in the future. RELNOTES: None PiperOrigin-RevId: 166266385
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/PseudoAction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/PseudoAction.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PseudoAction.java b/src/main/java/com/google/devtools/build/lib/analysis/PseudoAction.java
index 37ba410a96..d37770fd77 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/PseudoAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/PseudoAction.java
@@ -19,6 +19,7 @@ import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionExecutionException;
import com.google.devtools.build.lib.actions.ActionOwner;
import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.actions.CommandLineExpansionException;
import com.google.devtools.build.lib.actions.extra.ExtraActionInfo;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.util.Fingerprint;
@@ -71,7 +72,11 @@ public class PseudoAction<InfoType extends MessageLite> extends AbstractAction {
@Override
public ExtraActionInfo.Builder getExtraActionInfo() {
- return super.getExtraActionInfo().setExtension(infoExtension, getInfo());
+ try {
+ return super.getExtraActionInfo().setExtension(infoExtension, getInfo());
+ } catch (CommandLineExpansionException e) {
+ throw new AssertionError("PsedoAction command line expansion cannot fail");
+ }
}
public static Artifact getDummyOutput(RuleContext ruleContext) {