aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/actions
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-05-24 22:20:45 +0200
committerGravatar Irina Iancu <elenairina@google.com>2017-05-26 09:36:15 +0200
commitd0e58c4790f499afa5d1fcafb2f9e4c3f47b3ca0 (patch)
tree15af629799daa35970627d59fe138a7b17e17e58 /src/main/java/com/google/devtools/build/lib/analysis/actions
parent721ea3e46922df63205e0ba87e49a50449e2f78b (diff)
Automated g4 rollback of commit e2edf2e141a09c025a958d580c7cac7b57c70d83.
*** Reason for rollback *** Rollforward with fix. *** Original change description *** Automated g4 rollback of commit c78c947e6a8cbb323304f872a3dcabb989a3d76b. *** Reason for rollback *** Breaks android targets in the nightly - see [] *** Original change description *** Do not retain transitive data in AndroidLocalTestBase... *** ROLLBACK_OF=156745610 RELNOTES: None PiperOrigin-RevId: 157028029
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/actions')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java43
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java2
2 files changed, 38 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java
index 1d3e0bebb8..7bc670569a 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java
@@ -19,10 +19,17 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander;
import com.google.devtools.build.lib.collect.CollectionUtils;
-import com.google.devtools.build.lib.util.Preconditions;
/** A representation of a list of arguments, often a command executed by {@link SpawnAction}. */
public abstract class CommandLine {
+ public static final CommandLine EMPTY =
+ new CommandLine() {
+ @Override
+ public Iterable<String> arguments() {
+ return ImmutableList.of();
+ }
+ };
+
/**
* Returns the command line.
*/
@@ -55,18 +62,42 @@ public abstract class CommandLine {
* Returns a {@link CommandLine} that is constructed by prepending the {@code executableArgs} to
* {@code commandLine}.
*/
- CommandLine prepend(final ImmutableList<String> executableArgs) {
- final CommandLine self = this;
- Preconditions.checkState(!executableArgs.isEmpty());
+ public static CommandLine concat(
+ final ImmutableList<String> executableArgs, final CommandLine commandLine) {
+ if (executableArgs.isEmpty()) {
+ return commandLine;
+ }
+ return new CommandLine() {
+ @Override
+ public Iterable<String> arguments() {
+ return Iterables.concat(executableArgs, commandLine.arguments());
+ }
+
+ @Override
+ public Iterable<String> arguments(ArtifactExpander artifactExpander) {
+ return Iterables.concat(executableArgs, commandLine.arguments(artifactExpander));
+ }
+ };
+ }
+
+ /**
+ * Returns a {@link CommandLine} that is constructed by appending the {@code args} to {@code
+ * commandLine}.
+ */
+ public static CommandLine concat(
+ final CommandLine commandLine, final ImmutableList<String> args) {
+ if (args.isEmpty()) {
+ return commandLine;
+ }
return new CommandLine() {
@Override
public Iterable<String> arguments() {
- return Iterables.concat(executableArgs, self.arguments());
+ return Iterables.concat(commandLine.arguments(), args);
}
@Override
public Iterable<String> arguments(ArtifactExpander artifactExpander) {
- return Iterables.concat(executableArgs, self.arguments(artifactExpander));
+ return Iterables.concat(commandLine.arguments(artifactExpander), args);
}
};
}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java
index e39401ac04..d1253c98e0 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java
@@ -137,7 +137,7 @@ public final class ParamFileHelper {
return commandLine;
}
- return commandLine.prepend(ImmutableList.copyOf(executableArgs));
+ return CommandLine.concat(ImmutableList.copyOf(executableArgs), commandLine);
}
/**