aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2017-08-03 20:08:54 +0200
committerGravatar Dmitry Lomov <dslomov@google.com>2017-08-04 17:16:22 +0200
commit0d659c0dd219ae6a73689f4431d2432bc2025ec7 (patch)
treec4e77a022003ce2145983e4e54578624a8556dab /src/main/java/com/google/devtools/build/lib/analysis
parent5e92855c2b26e21336c388aebd6c760bdea1175f (diff)
Use @CompileTimeConstant on SpawnAction.Builder#setProgressMessage.
Add SpawnAction.Builder#setProgressMessageNonLazy for dynamic strings. This should help guide users to the right method. This also helped find a few methods I'd missed previously that could use a constant-string version. RELNOTES: None PiperOrigin-RevId: 164150264
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
index e578483eb2..54f1d9e7f0 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
@@ -59,6 +59,7 @@ import com.google.devtools.build.lib.util.LazyString;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.util.ShellEscaper;
import com.google.devtools.build.lib.vfs.PathFragment;
+import com.google.errorprone.annotations.CompileTimeConstant;
import com.google.errorprone.annotations.FormatMethod;
import com.google.errorprone.annotations.FormatString;
import com.google.protobuf.GeneratedMessage.GeneratedExtension;
@@ -1124,8 +1125,12 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
* <p>If you are formatting the string in any way, prefer one of the overloads that do the
* formatting lazily. This helps save memory by delaying the construction of the progress
* message string.
+ *
+ * <p>If you cannot use simple formatting, try {@link Builder#setProgressMessage(LazyString)}.
+ *
+ * <p>If you must eagerly compute the string, use {@link Builder#setProgressMessageNonLazy}.
*/
- public Builder setProgressMessage(String progressMessage) {
+ public Builder setProgressMessage(@CompileTimeConstant String progressMessage) {
this.progressMessage = progressMessage;
return this;
}
@@ -1222,6 +1227,16 @@ public class SpawnAction extends AbstractAction implements ExecutionInfoSpecifie
return this;
}
+ /**
+ * Sets an eagerly computed progress message.
+ *
+ * <p>Prefer one of the lazy overloads whenever possible, as it will generally save memory.
+ */
+ public Builder setProgressMessageNonLazy(String progressMessage) {
+ this.progressMessage = progressMessage;
+ return this;
+ }
+
public Builder setMnemonic(String mnemonic) {
Preconditions.checkArgument(
!mnemonic.isEmpty() && CharMatcher.javaLetterOrDigit().matchesAllOf(mnemonic),