diff options
author | cpeyser <cpeyser@google.com> | 2017-05-22 18:23:41 +0200 |
---|---|---|
committer | Irina Iancu <elenairina@google.com> | 2017-05-23 12:45:08 +0200 |
commit | e2edf2e141a09c025a958d580c7cac7b57c70d83 (patch) | |
tree | e04eadb53c175ffb910222683a3a56f616c4e608 /src/main/java/com/google/devtools/build/lib/analysis/actions | |
parent | 7e91ad631a660ae12a2b8dcfb8ba42574a7a76d3 (diff) |
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.
The argument strings and artifacts were both transitive and flattened, causing O(N^2) memory consumption.
PiperOrigin-RevId: 156745610
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.java | 43 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java | 2 |
2 files changed, 7 insertions, 38 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)); } }; } 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 d1253c98e0..e39401ac04 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.concat(ImmutableList.copyOf(executableArgs), commandLine); + return commandLine.prepend(ImmutableList.copyOf(executableArgs)); } /** |