diff options
Diffstat (limited to 'src/main')
17 files changed, 104 insertions, 573 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="); |