diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java | 43 |
1 files changed, 6 insertions, 37 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 7bc670569a..1d3e0bebb8 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,17 +19,10 @@ 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. */ @@ -62,42 +55,18 @@ public abstract class CommandLine { * Returns a {@link CommandLine} that is constructed by prepending the {@code executableArgs} to * {@code commandLine}. */ - 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; - } + CommandLine prepend(final ImmutableList<String> executableArgs) { + final CommandLine self = this; + Preconditions.checkState(!executableArgs.isEmpty()); return new CommandLine() { @Override public Iterable<String> arguments() { - return Iterables.concat(commandLine.arguments(), args); + return Iterables.concat(executableArgs, self.arguments()); } @Override public Iterable<String> arguments(ArtifactExpander artifactExpander) { - return Iterables.concat(commandLine.arguments(artifactExpander), args); + return Iterables.concat(executableArgs, self.arguments(artifactExpander)); } }; } |