aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2017-09-11 22:25:33 +0200
committerGravatar Philipp Wollermann <philwo@google.com>2017-09-12 14:05:28 +0200
commitbb50580a7f3eb3f4e7c5fba8e92d20e931591a70 (patch)
tree26b0b3b0e1dcac29980476b38f8ca99a320a6061 /src
parentd24f3cbfc0b3102aaf550a282f26bc9c1ba073bf (diff)
Inline CustomCommandLine methods that can be expressed using VectorArg.
This whole CL was done using IDE refactoring tools and should be safe. PiperOrigin-RevId: 168275575
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java508
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java11
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceValidatorActionBuilder.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainerConverter.java15
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java14
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/OneVersionCheckActionBuilder.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java15
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java18
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java26
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java12
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java347
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java5
19 files changed, 352 insertions, 677 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java
index eab60e78dc..bfc88bea31 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java
@@ -876,514 +876,6 @@ public final class CustomCommandLine extends CommandLine {
return addVectorArgInternal(arg, vectorArg);
}
- /** Adds the passed mapped values to the command line. */
- public <T> Builder addAll(@Nullable NestedSet<T> values, Function<T, String> mapFn) {
- return addAll(VectorArg.of(values).mapped(mapFn));
- }
-
- /** Adds the passed mapped values to the command line. */
- public <T> Builder addAll(@Nullable Collection<T> values, Function<T, String> mapFn) {
- return addAll(VectorArg.of(values).mapped(mapFn));
- }
-
- /**
- * Adds the arg followed by the passed mapped values.
- *
- * <p>If values is empty, the arg isn't added.
- */
- public <T> Builder addAll(
- @CompileTimeConstant String arg,
- @Nullable Collection<T> values,
- Function<T, String> mapFn) {
- return addAll(arg, VectorArg.of(values).mapped(mapFn));
- }
-
- /**
- * Adds the arg followed by the mapped values.
- *
- * <p>If values is empty, the arg isn't added.
- */
- public <T> Builder addAll(
- @CompileTimeConstant String arg, @Nullable NestedSet<T> values, Function<T, String> mapFn) {
- return addAll(arg, VectorArg.of(values).mapped(mapFn));
- }
-
- /** Adds the values joined with the supplied string. */
- public Builder addJoined(String delimiter, Collection<String> values) {
- return addAll(VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the path strings joined with the supplied string. */
- public Builder addJoinedPaths(String delimiter, Collection<PathFragment> values) {
- return addPaths(VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the exec path strings joined with the supplied string. */
- public Builder addJoinedExecPaths(String delimiter, Collection<Artifact> values) {
- return addExecPaths(VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the mapped values joined with the supplied string. */
- public <T> Builder addJoined(
- String delimiter, Collection<T> values, Function<T, String> mapFn) {
- return addAll(VectorArg.join(delimiter).each(values).mapped(mapFn));
- }
-
- /** Adds the values joined with the supplied string. */
- public Builder addJoined(String delimiter, NestedSet<String> values) {
- return addAll(VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the path strings joined with the supplied string. */
- public Builder addJoinedPaths(String delimiter, NestedSet<PathFragment> values) {
- return addPaths(VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the exec path strings joined with the supplied string. */
- public Builder addJoinedExecPaths(String delimiter, NestedSet<Artifact> values) {
- return addExecPaths(VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the mapped values joined with the supplied string. */
- public <T> Builder addJoined(String delimiter, NestedSet<T> values, Function<T, String> mapFn) {
- return addAll(VectorArg.join(delimiter).each(values).mapped(mapFn));
- }
-
- /** Adds the values joined with the supplied string. */
- public Builder addJoined(
- @CompileTimeConstant String arg, String delimiter, Collection<String> values) {
- return addAll(arg, VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the path strings joined with the supplied string. */
- public Builder addJoinedPaths(
- @CompileTimeConstant String arg, String delimiter, Collection<PathFragment> values) {
- return addPaths(arg, VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the exec path strings joined with the supplied string. */
- public Builder addJoinedExecPaths(
- @CompileTimeConstant String arg, String delimiter, Collection<Artifact> values) {
- return addExecPaths(arg, VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the mapped values joined with the supplied string. */
- public <T> Builder addJoined(
- @CompileTimeConstant String arg,
- String delimiter,
- Collection<T> values,
- Function<T, String> mapFn) {
- return addAll(arg, VectorArg.join(delimiter).each(values).mapped(mapFn));
- }
-
- /** Adds the values joined with the supplied string. */
- public Builder addJoined(
- @CompileTimeConstant String arg, String delimiter, NestedSet<String> values) {
- return addAll(arg, VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the path strings joined with the supplied string. */
- public Builder addJoinedPaths(
- @CompileTimeConstant String arg, String delimiter, NestedSet<PathFragment> values) {
- return addPaths(arg, VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the exec path strings joined with the supplied string. */
- public Builder addJoinedExecPaths(
- @CompileTimeConstant String arg, String delimiter, NestedSet<Artifact> values) {
- return addExecPaths(arg, VectorArg.join(delimiter).each(values));
- }
-
- /** Adds the mapped values joined with the supplied string. */
- public <T> Builder addJoined(
- @CompileTimeConstant String arg,
- String delimiter,
- NestedSet<T> values,
- Function<T, String> mapFn) {
- return addAll(arg, VectorArg.join(delimiter).each(values).mapped(mapFn));
- }
-
- /** Adds the values with each value formatted by the supplied format string. */
- public Builder addFormatEach(@CompileTimeConstant String formatStr, Collection<String> values) {
- return addAll(VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the path strings with each path formatted by the supplied format string. */
- public Builder addFormatEachPath(
- @CompileTimeConstant String formatStr, Collection<PathFragment> values) {
- return addPaths(VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the exec path strings with each path formatted by the supplied format string. */
- public Builder addFormatEachExecPath(
- @CompileTimeConstant String formatStr, Collection<Artifact> values) {
- return addExecPaths(VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the mapped values with each value formatted by the supplied format string. */
- public <T> Builder addFormatEach(
- @CompileTimeConstant String formatStr, Collection<T> values, Function<T, String> mapFn) {
- return addAll(VectorArg.format(formatStr).each(values).mapped(mapFn));
- }
-
- /** Adds the values with each value formatted by the supplied format string. */
- public Builder addFormatEach(@CompileTimeConstant String formatStr, NestedSet<String> values) {
- return addAll(VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the path strings with each path formatted by the supplied format string. */
- public Builder addFormatEachPath(
- @CompileTimeConstant String formatStr, NestedSet<PathFragment> values) {
- return addPaths(VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the exec path strings with each path formatted by the supplied format string. */
- public Builder addFormatEachExecPath(
- @CompileTimeConstant String formatStr, NestedSet<Artifact> values) {
- return addExecPaths(VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the mapped values with each value formatted by the supplied format string. */
- public <T> Builder addFormatEach(
- @CompileTimeConstant String formatStr, NestedSet<T> values, Function<T, String> mapFn) {
- return addAll(VectorArg.format(formatStr).each(values).mapped(mapFn));
- }
-
- /** Adds the values with each value formatted by the supplied format string. */
- public Builder addFormatEach(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- Collection<String> values) {
- return addAll(arg, VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the path strings with each path formatted by the supplied format string. */
- public Builder addFormatEachPath(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- Collection<PathFragment> values) {
- return addPaths(arg, VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the exec path strings with each path formatted by the supplied format string. */
- public Builder addFormatEachExecPath(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- Collection<Artifact> values) {
- return addExecPaths(arg, VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the mapped values with each value formatted by the supplied format string. */
- public <T> Builder addFormatEach(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- Collection<T> values,
- Function<T, String> mapFn) {
- return addAll(arg, VectorArg.format(formatStr).each(values).mapped(mapFn));
- }
-
- /** Adds the values with each value formatted by the supplied format string. */
- public Builder addFormatEach(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- NestedSet<String> values) {
- return addAll(arg, VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the path strings with each path formatted by the supplied format string. */
- public Builder addFormatEachPath(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- NestedSet<PathFragment> values) {
- return addPaths(arg, VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the exec path strings with each path formatted by the supplied format string. */
- public Builder addFormatEachExecPath(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- NestedSet<Artifact> values) {
- return addExecPaths(arg, VectorArg.format(formatStr).each(values));
- }
-
- /** Adds the mapped values with each value formatted by the supplied format string. */
- public <T> Builder addFormatEach(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- NestedSet<T> values,
- Function<T, String> mapFn) {
- return addAll(arg, VectorArg.format(formatStr).each(values).mapped(mapFn));
- }
-
- /** Adds the values with each value formatted by the supplied format string, then joined. */
- public Builder addFormatEachJoined(
- @CompileTimeConstant String formatStr, String delimiter, Collection<String> values) {
- return addAll(VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the path strings with each path formatted by the supplied format string, then joined.
- */
- public Builder addFormatEachPathJoined(
- @CompileTimeConstant String formatStr, String delimiter, Collection<PathFragment> values) {
- return addPaths(VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the exec path strings with each path formatted by the supplied format string, then
- * joined.
- */
- public Builder addFormatEachExecPathJoined(
- @CompileTimeConstant String formatStr, String delimiter, Collection<Artifact> values) {
- return addExecPaths(VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the mapped values with each value formatted by the supplied format string, then joined.
- */
- public <T> Builder addFormatEachJoined(
- @CompileTimeConstant String formatStr,
- String delimiter,
- Collection<T> values,
- Function<T, String> mapFn) {
- return addAll(VectorArg.format(formatStr).join(delimiter).each(values).mapped(mapFn));
- }
-
- /** Adds the values with each value formatted by the supplied format string, then joined. */
- public Builder addFormatEachJoined(
- @CompileTimeConstant String formatStr, String delimiter, NestedSet<String> values) {
- return addAll(VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the path strings with each path formatted by the supplied format string, then joined.
- */
- public Builder addFormatEachPathJoined(
- @CompileTimeConstant String formatStr, String delimiter, NestedSet<PathFragment> values) {
- return addPaths(VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the exec path strings with each path formatted by the supplied format string, then
- * joined.
- */
- public Builder addFormatEachExecPathJoined(
- @CompileTimeConstant String formatStr, String delimiter, NestedSet<Artifact> values) {
- return addExecPaths(VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the mapped values with each value formatted by the supplied format string, then joined.
- */
- public <T> Builder addFormatEachJoined(
- @CompileTimeConstant String formatStr,
- String delimiter,
- NestedSet<T> values,
- Function<T, String> mapFn) {
- return addAll(VectorArg.format(formatStr).join(delimiter).each(values).mapped(mapFn));
- }
-
- /** Adds the values with each value formatted by the supplied format string, then joined. */
- public Builder addFormatEachJoined(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- String delimiter,
- Collection<String> values) {
- return addAll(arg, VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the path strings with each path formatted by the supplied format string, then joined.
- */
- public Builder addFormatEachPathJoined(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- String delimiter,
- Collection<PathFragment> values) {
- return addPaths(arg, VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the exec path strings with each path formatted by the supplied format string, then
- * joined.
- */
- public Builder addFormatEachExecPathJoined(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- String delimiter,
- Collection<Artifact> values) {
- return addExecPaths(arg, VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the mapped values with each value formatted by the supplied format string, then joined.
- */
- public <T> Builder addFormatEachJoined(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- String delimiter,
- Collection<T> values,
- Function<T, String> mapFn) {
- return addAll(arg, VectorArg.format(formatStr).join(delimiter).each(values).mapped(mapFn));
- }
-
- /** Adds the values with each value formatted by the supplied format string, then joined. */
- public Builder addFormatEachJoined(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- String delimiter,
- NestedSet<String> values) {
- return addAll(arg, VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the path strings with each path formatted by the supplied format string, then joined.
- */
- public Builder addFormatEachPathJoined(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- String delimiter,
- NestedSet<PathFragment> values) {
- return addPaths(arg, VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the exec path strings with each path formatted by the supplied format string, then
- * joined.
- */
- public Builder addFormatEachExecPathJoined(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- String delimiter,
- NestedSet<Artifact> values) {
- return addExecPaths(arg, VectorArg.format(formatStr).join(delimiter).each(values));
- }
-
- /**
- * Adds the mapped values with each value formatted by the supplied format string, then joined.
- */
- public <T> Builder addFormatEachJoined(
- @CompileTimeConstant String arg,
- @CompileTimeConstant String formatStr,
- String delimiter,
- NestedSet<T> values,
- Function<T, String> mapFn) {
- return addAll(arg, VectorArg.format(formatStr).join(delimiter).each(values).mapped(mapFn));
- }
-
- /** Adds the beforeEach string and the values interspersed. */
- public Builder addBeforeEach(
- @CompileTimeConstant String beforeEach, Collection<String> values) {
- return addAll(VectorArg.addBefore(beforeEach).each(values));
- }
-
- /** Adds the beforeEach string and the path strings interspersed. */
- public Builder addBeforeEachPath(
- @CompileTimeConstant String beforeEach, Collection<PathFragment> values) {
- return addPaths(VectorArg.addBefore(beforeEach).each(values));
- }
-
- /** Adds the beforeEach string and the exec path strings interspersed. */
- public Builder addBeforeEachExecPath(
- @CompileTimeConstant String beforeEach, Collection<Artifact> values) {
- return addExecPaths(VectorArg.addBefore(beforeEach).each(values));
- }
-
- /** Adds the beforeEach string and the mapped values interspersed. */
- public <T> Builder addBeforeEach(
- @CompileTimeConstant String beforeEach, Collection<T> values, Function<T, String> mapFn) {
- return addAll(VectorArg.addBefore(beforeEach).each(values).mapped(mapFn));
- }
-
- /** Adds the beforeEach string and the values interspersed. */
- public Builder addBeforeEach(@CompileTimeConstant String beforeEach, NestedSet<String> values) {
- return addAll(VectorArg.addBefore(beforeEach).each(values));
- }
-
- /** Adds the beforeEach string and the path strings interspersed. */
- public Builder addBeforeEachPath(
- @CompileTimeConstant String beforeEach, NestedSet<PathFragment> values) {
- return addPaths(VectorArg.addBefore(beforeEach).each(values));
- }
-
- /** Adds the beforeEach string and the exec path strings interspersed. */
- public Builder addBeforeEachExecPath(
- @CompileTimeConstant String beforeEach, NestedSet<Artifact> values) {
- return addExecPaths(VectorArg.addBefore(beforeEach).each(values));
- }
-
- /** Adds the beforeEach string and the values interspersed. */
- public <T> Builder addBeforeEach(
- @CompileTimeConstant String beforeEach, NestedSet<T> values, Function<T, String> mapFn) {
- return addAll(VectorArg.addBefore(beforeEach).each(values).mapped(mapFn));
- }
-
- /** Adds the beforeEach string and the values interspersed. */
- public Builder addBeforeEachFormatted(
- @CompileTimeConstant String beforeEach,
- @CompileTimeConstant String formatStr,
- Collection<String> values) {
- return addAll(VectorArg.addBefore(beforeEach).format(formatStr).each(values));
- }
-
- /** Adds the beforeEach string and the path strings interspersed. */
- public Builder addBeforeEachPathFormatted(
- @CompileTimeConstant String beforeEach,
- @CompileTimeConstant String formatStr,
- Collection<PathFragment> values) {
- return addPaths(VectorArg.addBefore(beforeEach).format(formatStr).each(values));
- }
-
- /** Adds the beforeEach string and the exec path strings interspersed. */
- public Builder addBeforeEachExecPathFormatted(
- @CompileTimeConstant String beforeEach,
- @CompileTimeConstant String formatStr,
- Collection<Artifact> values) {
- return addExecPaths(VectorArg.addBefore(beforeEach).format(formatStr).each(values));
- }
-
- /** Adds the beforeEach string and the mapped values interspersed. */
- public <T> Builder addBeforeEachFormatted(
- @CompileTimeConstant String beforeEach,
- @CompileTimeConstant String formatStr,
- Collection<T> values,
- Function<T, String> mapFn) {
- return addAll(VectorArg.addBefore(beforeEach).format(formatStr).each(values).mapped(mapFn));
- }
-
- /** Adds the beforeEach string and the values interspersed. */
- public Builder addBeforeEachFormatted(
- @CompileTimeConstant String beforeEach,
- @CompileTimeConstant String formatStr,
- NestedSet<String> values) {
- return addAll(VectorArg.addBefore(beforeEach).format(formatStr).each(values));
- }
-
- /** Adds the beforeEach string and the path strings interspersed. */
- public Builder addBeforeEachPathFormatted(
- @CompileTimeConstant String beforeEach,
- @CompileTimeConstant String formatStr,
- NestedSet<PathFragment> values) {
- return addPaths(VectorArg.addBefore(beforeEach).format(formatStr).each(values));
- }
-
- /** Adds the beforeEach string and the exec path strings interspersed. */
- public Builder addBeforeEachExecPathFormatted(
- @CompileTimeConstant String beforeEach,
- @CompileTimeConstant String formatStr,
- NestedSet<Artifact> values) {
- return addExecPaths(VectorArg.addBefore(beforeEach).format(formatStr).each(values));
- }
-
- /** Adds the beforeEach string and the mapped values interspersed. */
- public <T> Builder addBeforeEachFormatted(
- @CompileTimeConstant String beforeEach,
- @CompileTimeConstant String formatStr,
- NestedSet<T> values,
- Function<T, String> mapFn) {
- return addAll(VectorArg.addBefore(beforeEach).format(formatStr).each(values).mapped(mapFn));
- }
-
public Builder addCustomMultiArgv(@Nullable CustomMultiArgv arg) {
if (arg != null) {
arguments.add(arg);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
index d8d856cd58..ec5f03a7ae 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
@@ -43,6 +43,7 @@ import com.google.devtools.build.lib.analysis.RunfilesProvider;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.actions.CommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction.Builder;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -1016,7 +1017,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
CommandLine mergeCommandLine =
CustomCommandLine.builder()
- .addBeforeEachExecPath("--input_zip", shardDexes)
+ .addExecPaths(VectorArg.addBefore("--input_zip").each(shardDexes))
.addExecPath("--output_zip", classesDex)
.build();
ruleContext.registerAction(
@@ -1247,7 +1248,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
CustomCommandLine.Builder shardCommandLine =
CustomCommandLine.builder()
- .addBeforeEachExecPath("--output_jar", shards)
+ .addExecPaths(VectorArg.addBefore("--output_jar").each(shards))
.addExecPath("--output_resources", javaResourceJar);
if (mainDexList != null) {
@@ -1302,7 +1303,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
} else {
classpath = classpath.stream().map(derivedJarFunction::apply).collect(toImmutableList());
}
- shardCommandLine.addBeforeEachExecPath("--input_jar", classpath);
+ shardCommandLine.addExecPaths(VectorArg.addBefore("--input_jar").each(classpath));
shardAction.addInputs(classpath);
if (inclusionFilterJar != null) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java
index 01c4e6b89b..9c46ee398e 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java
@@ -34,6 +34,7 @@ import com.google.devtools.build.lib.analysis.RunfilesProvider;
import com.google.devtools.build.lib.analysis.RunfilesSupport;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.rules.android.AndroidLibraryAarProvider.Aar;
@@ -255,12 +256,14 @@ public abstract class AndroidLocalTestBase implements RuleConfiguredTargetFactor
CustomCommandLine.Builder cmdLineArgs = CustomCommandLine.builder();
if (!transitiveAars.isEmpty()) {
- cmdLineArgs.addJoined(
- "--android_libraries", ",", transitiveAars, AndroidLocalTestBase::aarCmdLineArg);
+ cmdLineArgs.addAll(
+ "--android_libraries",
+ VectorArg.join(",").each(transitiveAars).mapped(AndroidLocalTestBase::aarCmdLineArg));
}
if (!strictAars.isEmpty()) {
- cmdLineArgs.addJoined(
- "--strict_libraries", ",", strictAars, AndroidLocalTestBase::aarCmdLineArg);
+ cmdLineArgs.addAll(
+ "--strict_libraries",
+ VectorArg.join(",").each(strictAars).mapped(AndroidLocalTestBase::aarCmdLineArg));
}
RunfilesSupport runfilesSupport =
RunfilesSupport.withExecutable(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceValidatorActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceValidatorActionBuilder.java
index 9117465a22..50cfa8acb3 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceValidatorActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceValidatorActionBuilder.java
@@ -23,6 +23,7 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import java.util.ArrayList;
import java.util.List;
@@ -164,8 +165,9 @@ public class AndroidResourceValidatorActionBuilder {
builder
.add("--libraries")
- .addJoinedExecPaths(
- context.getConfiguration().getHostPathSeparator(), ImmutableList.copyOf(libraries));
+ .addExecPaths(
+ VectorArg.join(context.getConfiguration().getHostPathSeparator())
+ .each(libraries.toList()));
inputs.addAll(libraries);
builder.addExecPath("--compiled", compiledSymbols);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
index 9f0b04bc0a..19ac49e21a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourcesProcessorBuilder.java
@@ -22,6 +22,7 @@ import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.Builder;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.rules.android.AndroidConfiguration.AndroidAaptVersion;
@@ -464,16 +465,16 @@ public class AndroidResourcesProcessorBuilder {
}
ImmutableList<String> filteredResources = resourceFilter.getResourcesToIgnoreInExecution();
if (!filteredResources.isEmpty()) {
- builder.addJoined("--prefilteredResources", ",", filteredResources);
+ builder.addAll("--prefilteredResources", VectorArg.join(",").each(filteredResources));
}
if (!uncompressedExtensions.isEmpty()) {
- builder.addJoined("--uncompressedExtensions", ",", uncompressedExtensions);
+ builder.addAll("--uncompressedExtensions", VectorArg.join(",").each(uncompressedExtensions));
}
if (!crunchPng) {
builder.add("--useAaptCruncher=no");
}
if (!assetsToIgnore.isEmpty()) {
- builder.addJoined("--assetsToIgnore", ",", assetsToIgnore);
+ builder.addAll("--assetsToIgnore", VectorArg.join(",").each(assetsToIgnore));
}
if (debug) {
builder.add("--debug");
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java b/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java
index 7abcc34319..bf5491f132 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveAspect.java
@@ -43,6 +43,7 @@ import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
import com.google.devtools.build.lib.analysis.WrappingProvider;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.Builder;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.cmdline.Label;
@@ -374,8 +375,8 @@ public final class DexArchiveAspect extends NativeAspectClass implements Configu
new Builder()
.addExecPath("--input", jar)
.addExecPath("--output", result)
- .addBeforeEachExecPath("--classpath_entry", classpath)
- .addBeforeEachExecPath("--bootclasspath_entry", bootclasspath)
+ .addExecPaths(VectorArg.addBefore("--classpath_entry").each(classpath))
+ .addExecPaths(VectorArg.addBefore("--bootclasspath_entry").each(bootclasspath))
.build();
// Just use params file, since classpaths can get long
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java
index 4835d09ebb..137bd653cb 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/RClassGeneratorActionBuilder.java
@@ -23,6 +23,7 @@ import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
@@ -102,9 +103,11 @@ public class RClassGeneratorActionBuilder {
// TODO(corysmith): Remove NestedSet as we are already flattening it.
Iterable<ResourceContainer> depResources = dependencies.getResources();
if (!Iterables.isEmpty(depResources)) {
- builder.addBeforeEach(
- "--library",
- ImmutableList.copyOf(Iterables.transform(depResources, chooseDepsToArg(version))));
+ builder.addAll(
+ VectorArg.addBefore("--library")
+ .each(
+ ImmutableList.copyOf(
+ Iterables.transform(depResources, chooseDepsToArg(version)))));
inputs.addTransitive(
NestedSetBuilder.wrap(
Order.NAIVE_LINK_ORDER,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainerConverter.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainerConverter.java
index 041059e9a4..16a8c2845a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainerConverter.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceContainerConverter.java
@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
@@ -240,12 +241,18 @@ public class ResourceContainerConverter {
if (dependencies != null) {
if (!dependencies.getTransitiveResources().isEmpty()) {
- cmdBuilder.addJoined(
- "--data", toArg.listSeparator(), dependencies.getTransitiveResources(), toArg);
+ cmdBuilder.addAll(
+ "--data",
+ VectorArg.join(toArg.listSeparator())
+ .each(dependencies.getTransitiveResources())
+ .mapped(toArg));
}
if (!dependencies.getDirectResources().isEmpty()) {
- cmdBuilder.addJoined(
- "--directData", toArg.listSeparator(), dependencies.getDirectResources(), toArg);
+ cmdBuilder.addAll(
+ "--directData",
+ VectorArg.join(toArg.listSeparator())
+ .each(dependencies.getDirectResources())
+ .mapped(toArg));
}
// This flattens the nested set. Since each ResourceContainer needs to be transformed into
// Artifacts, and the NestedSetBuilder.wrap doesn't support lazy Iterator evaluation
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java
index fb0c79d19f..b38898a8dd 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java
@@ -20,6 +20,7 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.config.CompilationMode;
import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
@@ -170,10 +171,11 @@ public class ResourceShrinkerActionBuilder {
inputs.add(sdk.getAndroidJar());
if (!uncompressedExtensions.isEmpty()) {
- commandLine.addJoined("--uncompressedExtensions", ",", uncompressedExtensions);
+ commandLine.addAll(
+ "--uncompressedExtensions", VectorArg.join(",").each(uncompressedExtensions));
}
if (!assetsToIgnore.isEmpty()) {
- commandLine.addJoined("--assetsToIgnore", ",", assetsToIgnore);
+ commandLine.addAll("--assetsToIgnore", VectorArg.join(",").each(assetsToIgnore));
}
if (ruleContext.getConfiguration().getCompilationMode() != CompilationMode.OPT) {
commandLine.add("--debug");
@@ -213,7 +215,7 @@ public class ResourceShrinkerActionBuilder {
ImmutableList<String> resourcePackages =
getResourcePackages(primaryResources, dependencyResources);
- commandLine.addJoined("--resourcePackages", ",", resourcePackages);
+ commandLine.addAll("--resourcePackages", VectorArg.join(",").each(resourcePackages));
commandLine.addExecPath("--shrunkResourceApk", resourceApkOut);
outputs.add(resourceApkOut);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java
index fa537bfa95..64b99d3d66 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/RobolectricResourceSymbolsActionBuilder.java
@@ -20,6 +20,7 @@ import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
@@ -85,11 +86,11 @@ public class RobolectricResourceSymbolsActionBuilder {
inputs.add(sdk.getAndroidJar());
if (!Iterables.isEmpty(dependencies.getResources())) {
- builder.addJoined(
+ builder.addAll(
"--data",
- RESOURCE_CONTAINER_TO_ARG.listSeparator(),
- dependencies.getResources(),
- RESOURCE_CONTAINER_TO_ARG);
+ VectorArg.join(RESOURCE_CONTAINER_TO_ARG.listSeparator())
+ .each(dependencies.getResources())
+ .mapped(RESOURCE_CONTAINER_TO_ARG));
}
// This flattens the nested set.
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java
index c0c8ae4e80..04ffa63f27 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java
@@ -44,6 +44,7 @@ import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.CustomMultiArgv;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -441,13 +442,14 @@ public final class JavaCompileAction extends SpawnAction {
CustomCommandLine.builder().addPath(javaExecutable).addAll(javaBuilderJvmFlags);
if (!instrumentationJars.isEmpty()) {
builder
- .addJoinedExecPaths(
+ .addExecPaths(
"-cp",
- pathDelimiter,
- ImmutableList.<Artifact>builder()
- .addAll(instrumentationJars)
- .add(javaBuilderJar)
- .build())
+ VectorArg.join(pathDelimiter)
+ .each(
+ ImmutableList.<Artifact>builder()
+ .addAll(instrumentationJars)
+ .add(javaBuilderJar)
+ .build()))
.addDynamicString(javaBuilderMainClass);
} else {
// If there are no instrumentation jars, use simpler '-jar' option to launch JavaBuilder.
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/OneVersionCheckActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/java/OneVersionCheckActionBuilder.java
index fa643bd421..8646b90987 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/OneVersionCheckActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/OneVersionCheckActionBuilder.java
@@ -20,6 +20,7 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
@@ -92,7 +93,8 @@ public final class OneVersionCheckActionBuilder {
oneVersionArgsBuilder.add("--succeed_on_found_violations");
}
oneVersionArgsBuilder.addAll(
- "--inputs", jarsToCheck, OneVersionCheckActionBuilder::jarAndTargetArg);
+ "--inputs",
+ VectorArg.of(jarsToCheck).mapped(OneVersionCheckActionBuilder::jarAndTargetArg));
CustomCommandLine oneVersionArgs = oneVersionArgsBuilder.build();
ruleContext.registerAction(
new SpawnAction.Builder()
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
index b787ebcaf5..cf15e6082f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
@@ -55,6 +55,7 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -1105,12 +1106,16 @@ public abstract class CompilationSupport {
.addExecPath("--output_archive", prunedJ2ObjcArchive)
.addExecPath("--dummy_archive", dummyArchive)
.addExecPath("--xcrunwrapper", xcrunwrapper(ruleContext).getExecutable())
- .addJoinedExecPaths("--dependency_mapping_files", ",", j2ObjcDependencyMappingFiles)
- .addJoinedExecPaths("--header_mapping_files", ",", j2ObjcHeaderMappingFiles)
- .addJoinedExecPaths(
- "--archive_source_mapping_files", ",", j2ObjcArchiveSourceMappingFiles)
+ .addExecPaths(
+ "--dependency_mapping_files",
+ VectorArg.join(",").each(j2ObjcDependencyMappingFiles))
+ .addExecPaths(
+ "--header_mapping_files", VectorArg.join(",").each(j2ObjcHeaderMappingFiles))
+ .addExecPaths(
+ "--archive_source_mapping_files",
+ VectorArg.join(",").each(j2ObjcArchiveSourceMappingFiles))
.add("--entry_classes")
- .addJoined(",", entryClasses)
+ .addAll(VectorArg.join(",").each(entryClasses))
.build();
ruleContext.registerAction(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java
index 3bdb5d48c0..c90d5a7a62 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java
@@ -34,6 +34,7 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -492,7 +493,8 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
ImmutableList.Builder<Artifact> sourceJarOutputFiles = ImmutableList.builder();
if (!Iterables.isEmpty(sourceJars)) {
sourceJarOutputFiles.addAll(sourceJarOutputs(ruleContext));
- argBuilder.addJoinedExecPaths("--src_jars", ",", ImmutableList.copyOf(sourceJars));
+ argBuilder.addExecPaths(
+ "--src_jars", VectorArg.join(",").each(ImmutableList.copyOf(sourceJars)));
argBuilder.addAll(sourceJarFlags(ruleContext));
}
@@ -504,7 +506,7 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
NestedSet<Artifact> depsHeaderMappingFiles =
depJ2ObjcMappingFileProvider.getHeaderMappingFiles();
if (!depsHeaderMappingFiles.isEmpty()) {
- argBuilder.addJoinedExecPaths("--header-mapping", ",", depsHeaderMappingFiles);
+ argBuilder.addExecPaths("--header-mapping", VectorArg.join(",").each(depsHeaderMappingFiles));
}
boolean experimentalJ2ObjcHeaderMap =
@@ -516,7 +518,7 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
NestedSet<Artifact> depsClassMappingFiles = depJ2ObjcMappingFileProvider.getClassMappingFiles();
if (!depsClassMappingFiles.isEmpty()) {
- argBuilder.addJoinedExecPaths("--mapping", ",", depsClassMappingFiles);
+ argBuilder.addExecPaths("--mapping", VectorArg.join(",").each(depsClassMappingFiles));
}
Artifact archiveSourceMappingFile = j2ObjcOutputArchiveSourceMappingFile(ruleContext);
@@ -538,7 +540,7 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
NestedSet<Artifact> compileTimeJars =
compArgsProvider.getRecursiveJavaCompilationArgs().getCompileTimeJars();
if (!compileTimeJars.isEmpty()) {
- argBuilder.addJoinedExecPaths("-classpath", ":", compileTimeJars);
+ argBuilder.addExecPaths("-classpath", VectorArg.join(":").each(compileTimeJars));
}
argBuilder.addExecPaths(ImmutableList.copyOf(sources));
@@ -584,12 +586,12 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
if (experimentalJ2ObjcHeaderMap) {
CustomCommandLine.Builder headerMapCommandLine = CustomCommandLine.builder();
if (!Iterables.isEmpty(sources)) {
- headerMapCommandLine.addJoinedExecPaths(
- "--source_files", ",", ImmutableList.copyOf(sources));
+ headerMapCommandLine.addExecPaths(
+ "--source_files", VectorArg.join(",").each(ImmutableList.copyOf(sources)));
}
if (!Iterables.isEmpty(sourceJars)) {
- headerMapCommandLine.addJoinedExecPaths(
- "--source_jars", ",", ImmutableList.copyOf(sourceJars));
+ headerMapCommandLine.addExecPaths(
+ "--source_jars", VectorArg.join(",").each(ImmutableList.copyOf(sourceJars)));
}
headerMapCommandLine.addExecPath("--output_mapping_file", outputHeaderMappingFile);
ruleContext.registerAction(new SpawnAction.Builder()
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java
index 52024afae9..4dc2556ce8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java
@@ -51,6 +51,7 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.SpawnActionTemplate;
import com.google.devtools.build.lib.analysis.actions.SpawnActionTemplate.OutputPathMapper;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -305,14 +306,15 @@ public class LegacyCompilationSupport extends CompilationSupport {
.addAll(
commonLinkAndCompileFlagsForClang(objcProvider, objcConfiguration, appleConfiguration))
.addAll(objcConfiguration.getCoptsForCompilationMode())
- .addBeforeEachPath(
- "-iquote", ObjcCommon.userHeaderSearchPaths(objcProvider, buildConfiguration))
- .addBeforeEachExecPath("-include", pchFile.asSet())
- .addBeforeEachPath("-I", ImmutableList.copyOf(priorityHeaders))
- .addBeforeEachPath("-I", objcProvider.get(INCLUDE))
- .addBeforeEachPath("-isystem", objcProvider.get(INCLUDE_SYSTEM))
+ .addPaths(
+ VectorArg.addBefore("-iquote")
+ .each(ObjcCommon.userHeaderSearchPaths(objcProvider, buildConfiguration)))
+ .addExecPaths(VectorArg.addBefore("-include").each(pchFile.asSet()))
+ .addPaths(VectorArg.addBefore("-I").each(ImmutableList.copyOf(priorityHeaders)))
+ .addPaths(VectorArg.addBefore("-I").each(objcProvider.get(INCLUDE)))
+ .addPaths(VectorArg.addBefore("-isystem").each(objcProvider.get(INCLUDE_SYSTEM)))
.addAll(ImmutableList.copyOf(otherFlags))
- .addFormatEach("-D%s", objcProvider.get(DEFINE))
+ .addAll(VectorArg.format("-D%s").each(objcProvider.get(DEFINE)))
.addAll(coverageFlags)
.addAll(ImmutableList.copyOf(getCompileRuleCopts()));
@@ -737,11 +739,13 @@ public class LegacyCompilationSupport extends CompilationSupport {
.add("@executable_path/Frameworks")
.add("-fobjc-link-runtime")
.addAll(DEFAULT_LINKER_FLAGS)
- .addBeforeEach("-framework", frameworkNames(objcProvider))
- .addBeforeEach("-weak_framework", SdkFramework.names(objcProvider.get(WEAK_SDK_FRAMEWORK)))
- .addFormatEach("-l%s", libraryNames)
+ .addAll(VectorArg.addBefore("-framework").each(frameworkNames(objcProvider)))
+ .addAll(
+ VectorArg.addBefore("-weak_framework")
+ .each(SdkFramework.names(objcProvider.get(WEAK_SDK_FRAMEWORK))))
+ .addAll(VectorArg.format("-l%s").each(libraryNames))
.addExecPath("-o", linkedBinary)
- .addBeforeEachExecPath("-force_load", forceLinkArtifacts)
+ .addExecPaths(VectorArg.addBefore("-force_load").each(forceLinkArtifacts))
.addAll(ImmutableList.copyOf(extraLinkArgs))
.addAll(objcProvider.get(ObjcProvider.LINKOPT));
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java
index a5ff7418b1..5d7bb41683 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java
@@ -28,6 +28,7 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.Builder;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.FileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -485,7 +486,7 @@ final class ProtobufSupport {
.addDynamicString(getGenfilesPathString())
.add("--proto-root-dir")
.add(".")
- .addBeforeEachExecPath("--config", portableProtoFilters)
+ .addExecPaths(VectorArg.addBefore("--config").each(portableProtoFilters))
.build();
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
index 89a9577600..265b7d6e31 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
@@ -35,6 +35,7 @@ import com.google.devtools.build.lib.analysis.MakeVariableExpander;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.FileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.cmdline.Label;
@@ -560,14 +561,15 @@ public class ProtoCompileActionBuilder {
CustomCommandLine.Builder commandLine,
@Nullable NestedSet<Artifact> protosInDirectDependencies,
NestedSet<Artifact> transitiveImports) {
- commandLine.addAll(transitiveImports, ProtoCompileActionBuilder::transitiveImportArg);
+ commandLine.addAll(
+ VectorArg.of(transitiveImports).mapped(ProtoCompileActionBuilder::transitiveImportArg));
if (protosInDirectDependencies != null) {
if (!protosInDirectDependencies.isEmpty()) {
- commandLine.addJoined(
+ commandLine.addAll(
"--direct_dependencies",
- ":",
- protosInDirectDependencies,
- ProtoCompileActionBuilder::getPathIgnoringRepository);
+ VectorArg.join(":")
+ .each(protosInDirectDependencies)
+ .mapped(ProtoCompileActionBuilder::getPathIgnoringRepository));
} else {
// The proto compiler requires an empty list to turn on strict deps checking
commandLine.add("--direct_dependencies=");
diff --git a/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java b/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java
index 96da8ef7ab..856158a601 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/CustomCommandLineTest.java
@@ -23,6 +23,7 @@ import com.google.devtools.build.lib.actions.Artifact.SpecialArtifactType;
import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.CustomMultiArgv;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
@@ -165,10 +166,18 @@ public class CustomCommandLineTest {
assertThat(builder().addExecPaths(nestedSet(artifact1, artifact2)).build().arguments())
.containsExactly("dir/file1.txt", "dir/file2.txt")
.inOrder();
- assertThat(builder().addAll(list(foo("1"), foo("2")), Foo::str).build().arguments())
+ assertThat(
+ builder()
+ .addAll(VectorArg.of(list(foo("1"), foo("2"))).mapped(Foo::str))
+ .build()
+ .arguments())
.containsExactly("1", "2")
.inOrder();
- assertThat(builder().addAll(nestedSet(foo("1"), foo("2")), Foo::str).build().arguments())
+ assertThat(
+ builder()
+ .addAll(VectorArg.of(nestedSet(foo("1"), foo("2"))).mapped(Foo::str))
+ .build()
+ .arguments())
.containsExactly("1", "2")
.inOrder();
@@ -199,102 +208,144 @@ public class CustomCommandLineTest {
assertThat(builder().addExecPaths("--arg", nestedSet(artifact1, artifact2)).build().arguments())
.containsExactly("--arg", "dir/file1.txt", "dir/file2.txt")
.inOrder();
- assertThat(builder().addAll("--arg", list(foo("1"), foo("2")), Foo::str).build().arguments())
+ assertThat(
+ builder()
+ .addAll("--arg", VectorArg.of(list(foo("1"), foo("2"))).mapped(Foo::str))
+ .build()
+ .arguments())
.containsExactly("--arg", "1", "2")
.inOrder();
assertThat(
- builder().addAll("--arg", nestedSet(foo("1"), foo("2")), Foo::str).build().arguments())
+ builder()
+ .addAll("--arg", VectorArg.of(nestedSet(foo("1"), foo("2"))).mapped(Foo::str))
+ .build()
+ .arguments())
.containsExactly("--arg", "1", "2")
.inOrder();
}
@Test
public void testAddJoined() throws Exception {
- assertThat(builder().addJoined(":", list("val1", "val2")).build().arguments())
+ assertThat(builder().addAll(VectorArg.join(":").each(list("val1", "val2"))).build().arguments())
.containsExactly("val1:val2")
.inOrder();
- assertThat(builder().addJoined(":", nestedSet("val1", "val2")).build().arguments())
+ assertThat(
+ builder()
+ .addAll(VectorArg.join(":").each(nestedSet("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("val1:val2")
.inOrder();
assertThat(
builder()
- .addJoinedPaths(
- ":", list(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.join(":")
+ .each(list(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("path1:path2")
.inOrder();
assertThat(
builder()
- .addJoinedPaths(
- ":", nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.join(":")
+ .each(
+ nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("path1:path2")
.inOrder();
- assertThat(builder().addJoinedExecPaths(":", list(artifact1, artifact2)).build().arguments())
+ assertThat(
+ builder()
+ .addExecPaths(VectorArg.join(":").each(list(artifact1, artifact2)))
+ .build()
+ .arguments())
.containsExactly("dir/file1.txt:dir/file2.txt")
.inOrder();
assertThat(
- builder().addJoinedExecPaths(":", nestedSet(artifact1, artifact2)).build().arguments())
+ builder()
+ .addExecPaths(VectorArg.join(":").each(nestedSet(artifact1, artifact2)))
+ .build()
+ .arguments())
.containsExactly("dir/file1.txt:dir/file2.txt")
.inOrder();
- assertThat(builder().addJoined(":", list(foo("1"), foo("2")), Foo::str).build().arguments())
+ assertThat(
+ builder()
+ .addAll(VectorArg.join(":").each(list(foo("1"), foo("2"))).mapped(Foo::str))
+ .build()
+ .arguments())
.containsExactly("1:2")
.inOrder();
assertThat(
- builder().addJoined(":", nestedSet(foo("1"), foo("2")), Foo::str).build().arguments())
+ builder()
+ .addAll(VectorArg.join(":").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str))
+ .build()
+ .arguments())
.containsExactly("1:2")
.inOrder();
- assertThat(builder().addJoined("--arg", ":", list("val1", "val2")).build().arguments())
+ assertThat(
+ builder()
+ .addAll("--arg", VectorArg.join(":").each(list("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("--arg", "val1:val2")
.inOrder();
- assertThat(builder().addJoined("--arg", ":", nestedSet("val1", "val2")).build().arguments())
+ assertThat(
+ builder()
+ .addAll("--arg", VectorArg.join(":").each(nestedSet("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("--arg", "val1:val2")
.inOrder();
assertThat(
builder()
- .addJoinedPaths(
- "--arg", ":", list(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ "--arg",
+ VectorArg.join(":")
+ .each(list(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("--arg", "path1:path2")
.inOrder();
assertThat(
builder()
- .addJoinedPaths(
+ .addPaths(
"--arg",
- ":",
- nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))
+ VectorArg.join(":")
+ .each(
+ nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("--arg", "path1:path2")
.inOrder();
assertThat(
builder()
- .addJoinedExecPaths("--arg", ":", list(artifact1, artifact2))
+ .addExecPaths("--arg", VectorArg.join(":").each(list(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("--arg", "dir/file1.txt:dir/file2.txt")
.inOrder();
assertThat(
builder()
- .addJoinedExecPaths("--arg", ":", nestedSet(artifact1, artifact2))
+ .addExecPaths("--arg", VectorArg.join(":").each(nestedSet(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("--arg", "dir/file1.txt:dir/file2.txt")
.inOrder();
assertThat(
builder()
- .addJoined("--arg", ":", list(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ "--arg", VectorArg.join(":").each(list(foo("1"), foo("2"))).mapped(Foo::str))
.build()
.arguments())
.containsExactly("--arg", "1:2")
.inOrder();
assertThat(
builder()
- .addJoined("--arg", ":", nestedSet(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ "--arg",
+ VectorArg.join(":").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str))
.build()
.arguments())
.containsExactly("--arg", "1:2")
@@ -303,102 +354,133 @@ public class CustomCommandLineTest {
@Test
public void testAddFormatEach() throws Exception {
- assertThat(builder().addFormatEach("-D%s", list("val1", "val2")).build().arguments())
+ assertThat(
+ builder()
+ .addAll(VectorArg.format("-D%s").each(list("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("-Dval1", "-Dval2")
.inOrder();
- assertThat(builder().addFormatEach("-D%s", nestedSet("val1", "val2")).build().arguments())
+ assertThat(
+ builder()
+ .addAll(VectorArg.format("-D%s").each(nestedSet("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("-Dval1", "-Dval2")
.inOrder();
assertThat(
builder()
- .addFormatEachPath(
- "-D%s", list(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.format("-D%s")
+ .each(list(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("-Dpath1", "-Dpath2")
.inOrder();
assertThat(
builder()
- .addFormatEachPath(
- "-D%s", nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.format("-D%s")
+ .each(
+ nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("-Dpath1", "-Dpath2")
.inOrder();
assertThat(
- builder().addFormatEachExecPath("-D%s", list(artifact1, artifact2)).build().arguments())
+ builder()
+ .addExecPaths(VectorArg.format("-D%s").each(list(artifact1, artifact2)))
+ .build()
+ .arguments())
.containsExactly("-Ddir/file1.txt", "-Ddir/file2.txt")
.inOrder();
assertThat(
builder()
- .addFormatEachExecPath("-D%s", nestedSet(artifact1, artifact2))
+ .addExecPaths(VectorArg.format("-D%s").each(nestedSet(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("-Ddir/file1.txt", "-Ddir/file2.txt")
.inOrder();
assertThat(
- builder().addFormatEach("-D%s", list(foo("1"), foo("2")), Foo::str).build().arguments())
+ builder()
+ .addAll(VectorArg.format("-D%s").each(list(foo("1"), foo("2"))).mapped(Foo::str))
+ .build()
+ .arguments())
.containsExactly("-D1", "-D2")
.inOrder();
assertThat(
builder()
- .addFormatEach("-D%s", nestedSet(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ VectorArg.format("-D%s").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str))
.build()
.arguments())
.containsExactly("-D1", "-D2")
.inOrder();
- assertThat(builder().addFormatEach("--arg", "-D%s", list("val1", "val2")).build().arguments())
+ assertThat(
+ builder()
+ .addAll("--arg", VectorArg.format("-D%s").each(list("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("--arg", "-Dval1", "-Dval2")
.inOrder();
assertThat(
- builder().addFormatEach("--arg", "-D%s", nestedSet("val1", "val2")).build().arguments())
+ builder()
+ .addAll("--arg", VectorArg.format("-D%s").each(nestedSet("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("--arg", "-Dval1", "-Dval2")
.inOrder();
assertThat(
builder()
- .addFormatEachPath(
+ .addPaths(
"--arg",
- "-D%s",
- list(PathFragment.create("path1"), PathFragment.create("path2")))
+ VectorArg.format("-D%s")
+ .each(list(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("--arg", "-Dpath1", "-Dpath2")
.inOrder();
assertThat(
builder()
- .addFormatEachPath(
+ .addPaths(
"--arg",
- "-D%s",
- nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))
+ VectorArg.format("-D%s")
+ .each(
+ nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("--arg", "-Dpath1", "-Dpath2")
.inOrder();
assertThat(
builder()
- .addFormatEachExecPath("--arg", "-D%s", list(artifact1, artifact2))
+ .addExecPaths("--arg", VectorArg.format("-D%s").each(list(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("--arg", "-Ddir/file1.txt", "-Ddir/file2.txt")
.inOrder();
assertThat(
builder()
- .addFormatEachExecPath("--arg", "-D%s", nestedSet(artifact1, artifact2))
+ .addExecPaths(
+ "--arg", VectorArg.format("-D%s").each(nestedSet(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("--arg", "-Ddir/file1.txt", "-Ddir/file2.txt")
.inOrder();
assertThat(
builder()
- .addFormatEach("--arg", "-D%s", list(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ "--arg",
+ VectorArg.format("-D%s").each(list(foo("1"), foo("2"))).mapped(Foo::str))
.build()
.arguments())
.containsExactly("--arg", "-D1", "-D2")
.inOrder();
assertThat(
builder()
- .addFormatEach("--arg", "-D%s", nestedSet(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ "--arg",
+ VectorArg.format("-D%s").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str))
.build()
.arguments())
.containsExactly("--arg", "-D1", "-D2")
@@ -407,57 +489,74 @@ public class CustomCommandLineTest {
@Test
public void testAddFormatEachJoined() throws Exception {
- assertThat(builder().addFormatEachJoined("-D%s", ":", list("val1", "val2")).build().arguments())
+ assertThat(
+ builder()
+ .addAll(VectorArg.format("-D%s").join(":").each(list("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("-Dval1:-Dval2")
.inOrder();
assertThat(
builder()
- .addFormatEachJoined("-D%s", ":", nestedSet("val1", "val2"))
+ .addAll(VectorArg.format("-D%s").join(":").each(nestedSet("val1", "val2")))
.build()
.arguments())
.containsExactly("-Dval1:-Dval2")
.inOrder();
assertThat(
builder()
- .addFormatEachPathJoined(
- "-D%s", ":", list(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.format("-D%s")
+ .join(":")
+ .each(list(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("-Dpath1:-Dpath2")
.inOrder();
assertThat(
builder()
- .addFormatEachPathJoined(
- "-D%s",
- ":", nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.format("-D%s")
+ .join(":")
+ .each(
+ nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("-Dpath1:-Dpath2")
.inOrder();
assertThat(
builder()
- .addFormatEachExecPathJoined("-D%s", ":", list(artifact1, artifact2))
+ .addExecPaths(VectorArg.format("-D%s").join(":").each(list(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("-Ddir/file1.txt:-Ddir/file2.txt")
.inOrder();
assertThat(
builder()
- .addFormatEachExecPathJoined("-D%s", ":", nestedSet(artifact1, artifact2))
+ .addExecPaths(
+ VectorArg.format("-D%s").join(":").each(nestedSet(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("-Ddir/file1.txt:-Ddir/file2.txt")
.inOrder();
assertThat(
builder()
- .addFormatEachJoined("-D%s", ":", list(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ VectorArg.format("-D%s")
+ .join(":")
+ .each(list(foo("1"), foo("2")))
+ .mapped(Foo::str))
.build()
.arguments())
.containsExactly("-D1:-D2")
.inOrder();
assertThat(
builder()
- .addFormatEachJoined("-D%s", ":", nestedSet(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ VectorArg.format("-D%s")
+ .join(":")
+ .each(nestedSet(foo("1"), foo("2")))
+ .mapped(Foo::str))
.build()
.arguments())
.containsExactly("-D1:-D2")
@@ -465,64 +564,78 @@ public class CustomCommandLineTest {
assertThat(
builder()
- .addFormatEachJoined("--arg", "-D%s", ":", list("val1", "val2"))
+ .addAll("--arg", VectorArg.format("-D%s").join(":").each(list("val1", "val2")))
.build()
.arguments())
.containsExactly("--arg", "-Dval1:-Dval2")
.inOrder();
assertThat(
builder()
- .addFormatEachJoined("--arg", "-D%s", ":", nestedSet("val1", "val2"))
+ .addAll("--arg", VectorArg.format("-D%s").join(":").each(nestedSet("val1", "val2")))
.build()
.arguments())
.containsExactly("--arg", "-Dval1:-Dval2")
.inOrder();
assertThat(
builder()
- .addFormatEachPathJoined(
+ .addPaths(
"--arg",
- "-D%s",
- ":",
- list(PathFragment.create("path1"), PathFragment.create("path2")))
+ VectorArg.format("-D%s")
+ .join(":")
+ .each(list(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("--arg", "-Dpath1:-Dpath2")
.inOrder();
assertThat(
builder()
- .addFormatEachPathJoined(
+ .addPaths(
"--arg",
- "-D%s",
- ":",
- nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))
+ VectorArg.format("-D%s")
+ .join(":")
+ .each(
+ nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("--arg", "-Dpath1:-Dpath2")
.inOrder();
assertThat(
builder()
- .addFormatEachExecPathJoined("--arg", "-D%s", ":", list(artifact1, artifact2))
+ .addExecPaths(
+ "--arg", VectorArg.format("-D%s").join(":").each(list(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("--arg", "-Ddir/file1.txt:-Ddir/file2.txt")
.inOrder();
assertThat(
builder()
- .addFormatEachExecPathJoined("--arg", "-D%s", ":", nestedSet(artifact1, artifact2))
+ .addExecPaths(
+ "--arg",
+ VectorArg.format("-D%s").join(":").each(nestedSet(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("--arg", "-Ddir/file1.txt:-Ddir/file2.txt")
.inOrder();
assertThat(
builder()
- .addFormatEachJoined("--arg", "-D%s", ":", list(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ "--arg",
+ VectorArg.format("-D%s")
+ .join(":")
+ .each(list(foo("1"), foo("2")))
+ .mapped(Foo::str))
.build()
.arguments())
.containsExactly("--arg", "-D1:-D2")
.inOrder();
assertThat(
builder()
- .addFormatEachJoined("--arg", "-D%s", ":", nestedSet(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ "--arg",
+ VectorArg.format("-D%s")
+ .join(":")
+ .each(nestedSet(foo("1"), foo("2")))
+ .mapped(Foo::str))
.build()
.arguments())
.containsExactly("--arg", "-D1:-D2")
@@ -531,46 +644,64 @@ public class CustomCommandLineTest {
@Test
public void testAddBeforeEach() throws Exception {
- assertThat(builder().addBeforeEach("-D", list("val1", "val2")).build().arguments())
+ assertThat(
+ builder()
+ .addAll(VectorArg.addBefore("-D").each(list("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("-D", "val1", "-D", "val2")
.inOrder();
- assertThat(builder().addBeforeEach("-D", nestedSet("val1", "val2")).build().arguments())
+ assertThat(
+ builder()
+ .addAll(VectorArg.addBefore("-D").each(nestedSet("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("-D", "val1", "-D", "val2")
.inOrder();
assertThat(
builder()
- .addBeforeEachPath(
- "-D", list(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.addBefore("-D")
+ .each(list(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("-D", "path1", "-D", "path2")
.inOrder();
assertThat(
builder()
- .addBeforeEachPath(
- "-D", nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.addBefore("-D")
+ .each(
+ nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("-D", "path1", "-D", "path2")
.inOrder();
assertThat(
- builder().addBeforeEachExecPath("-D", list(artifact1, artifact2)).build().arguments())
+ builder()
+ .addExecPaths(VectorArg.addBefore("-D").each(list(artifact1, artifact2)))
+ .build()
+ .arguments())
.containsExactly("-D", "dir/file1.txt", "-D", "dir/file2.txt")
.inOrder();
assertThat(
builder()
- .addBeforeEachExecPath("-D", nestedSet(artifact1, artifact2))
+ .addExecPaths(VectorArg.addBefore("-D").each(nestedSet(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("-D", "dir/file1.txt", "-D", "dir/file2.txt")
.inOrder();
assertThat(
- builder().addBeforeEach("-D", list(foo("1"), foo("2")), Foo::str).build().arguments())
+ builder()
+ .addAll(VectorArg.addBefore("-D").each(list(foo("1"), foo("2"))).mapped(Foo::str))
+ .build()
+ .arguments())
.containsExactly("-D", "1", "-D", "2")
.inOrder();
assertThat(
builder()
- .addBeforeEach("-D", nestedSet(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ VectorArg.addBefore("-D").each(nestedSet(foo("1"), foo("2"))).mapped(Foo::str))
.build()
.arguments())
.containsExactly("-D", "1", "-D", "2")
@@ -580,58 +711,74 @@ public class CustomCommandLineTest {
@Test
public void testAddBeforeEachFormatted() throws Exception {
assertThat(
- builder().addBeforeEachFormatted("-D", "D%s", list("val1", "val2")).build().arguments())
+ builder()
+ .addAll(VectorArg.addBefore("-D").format("D%s").each(list("val1", "val2")))
+ .build()
+ .arguments())
.containsExactly("-D", "Dval1", "-D", "Dval2")
.inOrder();
assertThat(
builder()
- .addBeforeEachFormatted("-D", "D%s", nestedSet("val1", "val2"))
+ .addAll(VectorArg.addBefore("-D").format("D%s").each(nestedSet("val1", "val2")))
.build()
.arguments())
.containsExactly("-D", "Dval1", "-D", "Dval2")
.inOrder();
assertThat(
builder()
- .addBeforeEachPathFormatted(
- "-D", "D%s", list(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.addBefore("-D")
+ .format("D%s")
+ .each(list(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("-D", "Dpath1", "-D", "Dpath2")
.inOrder();
assertThat(
builder()
- .addBeforeEachPathFormatted(
- "-D",
- "D%s",
- nestedSet(PathFragment.create("path1"), PathFragment.create("path2")))
+ .addPaths(
+ VectorArg.addBefore("-D")
+ .format("D%s")
+ .each(
+ nestedSet(PathFragment.create("path1"), PathFragment.create("path2"))))
.build()
.arguments())
.containsExactly("-D", "Dpath1", "-D", "Dpath2")
.inOrder();
assertThat(
builder()
- .addBeforeEachExecPathFormatted("-D", "D%s", list(artifact1, artifact2))
+ .addExecPaths(
+ VectorArg.addBefore("-D").format("D%s").each(list(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("-D", "Ddir/file1.txt", "-D", "Ddir/file2.txt")
.inOrder();
assertThat(
builder()
- .addBeforeEachExecPathFormatted("-D", "D%s", nestedSet(artifact1, artifact2))
+ .addExecPaths(
+ VectorArg.addBefore("-D").format("D%s").each(nestedSet(artifact1, artifact2)))
.build()
.arguments())
.containsExactly("-D", "Ddir/file1.txt", "-D", "Ddir/file2.txt")
.inOrder();
assertThat(
builder()
- .addBeforeEachFormatted("-D", "D%s", list(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ VectorArg.addBefore("-D")
+ .format("D%s")
+ .each(list(foo("1"), foo("2")))
+ .mapped(Foo::str))
.build()
.arguments())
.containsExactly("-D", "D1", "-D", "D2")
.inOrder();
assertThat(
builder()
- .addBeforeEachFormatted("-D", "D%s", nestedSet(foo("1"), foo("2")), Foo::str)
+ .addAll(
+ VectorArg.addBefore("-D")
+ .format("D%s")
+ .each(nestedSet(foo("1"), foo("2")))
+ .mapped(Foo::str))
.build()
.arguments())
.containsExactly("-D", "D1", "-D", "D2")
@@ -695,22 +842,18 @@ public class CustomCommandLineTest {
.addPaths(ImmutableList.of())
.addExecPaths((ImmutableList<Artifact>) null)
.addExecPaths(ImmutableList.of())
- .addAll((ImmutableList<Foo>) null, Foo::str)
- .addAll(ImmutableList.of(), Foo::str)
.addAll((NestedSet<String>) null)
.addAll(NestedSetBuilder.emptySet(Order.STABLE_ORDER))
.addPaths((NestedSet<PathFragment>) null)
.addPaths(NestedSetBuilder.emptySet(Order.STABLE_ORDER))
.addExecPaths((NestedSet<Artifact>) null)
.addExecPaths(NestedSetBuilder.emptySet(Order.STABLE_ORDER))
- .addAll((NestedSet<Foo>) null, Foo::str)
- .addAll(NestedSetBuilder.emptySet(Order.STABLE_ORDER), Foo::str)
+ .addAll(VectorArg.of((NestedSet<String>) null))
+ .addAll(VectorArg.of(NestedSetBuilder.<String>emptySet(Order.STABLE_ORDER)))
.addAll("foo", (ImmutableList<String>) null)
.addAll("foo", ImmutableList.of())
.addPaths("foo", (ImmutableList<PathFragment>) null)
.addPaths("foo", ImmutableList.of())
- .addAll("foo", (ImmutableList<Foo>) null, Foo::str)
- .addAll("foo", ImmutableList.of(), Foo::str)
.addExecPaths("foo", (ImmutableList<Artifact>) null)
.addExecPaths("foo", ImmutableList.of())
.addAll("foo", (NestedSet<String>) null)
@@ -719,8 +862,8 @@ public class CustomCommandLineTest {
.addPaths("foo", NestedSetBuilder.emptySet(Order.STABLE_ORDER))
.addExecPaths("foo", (NestedSet<Artifact>) null)
.addExecPaths("foo", NestedSetBuilder.emptySet(Order.STABLE_ORDER))
- .addAll("foo", (NestedSet<Foo>) null, Foo::str)
- .addAll("foo", NestedSetBuilder.emptySet(Order.STABLE_ORDER), Foo::str)
+ .addAll("foo", VectorArg.of((NestedSet<String>) null))
+ .addAll("foo", VectorArg.of(NestedSetBuilder.<String>emptySet(Order.STABLE_ORDER)))
.addCustomMultiArgv(null)
.addPlaceholderTreeArtifactExecPath("foo", null)
.build();
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
index b48d242c6b..3a7647e172 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
@@ -67,6 +67,7 @@ import com.google.devtools.build.lib.analysis.RunfilesSupport;
import com.google.devtools.build.lib.analysis.actions.BinaryFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.Builder;
+import com.google.devtools.build.lib.analysis.actions.CustomCommandLine.VectorArg;
import com.google.devtools.build.lib.analysis.actions.FileWriteAction;
import com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction;
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
@@ -2217,7 +2218,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
.add("--minimum-deployment-target", minimumOsVersion.toString())
.add("--module")
.add("x")
- .addBeforeEach("--target-device", targetDevices)
+ .addAll(VectorArg.addBefore("--target-device").each(targetDevices))
.add("x/1.storyboard")
.build()
.arguments())
@@ -2238,7 +2239,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
.add("--minimum-deployment-target", minimumOsVersion.toString())
.add("--module")
.add("x")
- .addBeforeEach("--target-device", targetDevices)
+ .addAll(VectorArg.addBefore("--target-device").each(targetDevices))
.add("x/ja.lproj/loc.storyboard")
.build()
.arguments())