diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/actions/CustomCommandLine.java | 27 |
1 files changed, 27 insertions, 0 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 e6f9792637..601229bd14 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 @@ -18,6 +18,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander; @@ -196,6 +197,21 @@ public final class CustomCommandLine extends CommandLine { } } + private static final class ParamFileArgument extends ArgvFragment { + private final String paramFilePrefix; + private final PathFragment path; + + private ParamFileArgument(String paramFilePrefix, PathFragment path) { + this.paramFilePrefix = paramFilePrefix; + this.path = path; + } + + @Override + void eval(ImmutableList.Builder<String> builder) { + builder.add(paramFilePrefix + path); + } + } + /** * An argument object that evaluates to a formatted string for {@link TreeFileArtifact} exec * paths, enclosing the associated string format template and {@link TreeFileArtifact}s. @@ -555,6 +571,17 @@ public final class CustomCommandLine extends CommandLine { } /** + * Adds a param file as an argument. + * + * @param paramFilePrefix The character that denotes a param file, commonly '@' + * @param paramFile The param file artifact + */ + public Builder addParamFile(String paramFilePrefix, Artifact paramFile) { + arguments.add(new ParamFileArgument(paramFilePrefix, paramFile.getExecPath())); + return this; + } + + /** * Adds a formatted string containing the exec path of a placeholder TreeArtifact. When the * command line is used in an action template, the placeholder will be replaced by the exec path * of a {@link TreeFileArtifact} inside the TreeArtifact at execution time for each expanded |