@@ -470,7 +470,25 @@ public final String getMnemonic() {
470470 @ Override
471471 protected String getRawProgressMessage () {
472472 if (progressMessage != null ) {
473- return progressMessage .toString ();
473+ if (progressMessage instanceof String ) {
474+ String progressMessageStr = (String ) progressMessage ;
475+ if (progressMessageStr .contains ("%{label}" ) && getOwner ().getLabel () != null ) {
476+ progressMessageStr =
477+ progressMessageStr .replace ("%{label}" , getOwner ().getLabel ().toString ());
478+ }
479+ if (progressMessageStr .contains ("%{output}" ) && getPrimaryOutput () != null ) {
480+ progressMessageStr =
481+ progressMessageStr .replace ("%{output}" , getPrimaryOutput ().getExecPathString ());
482+ }
483+ if (progressMessageStr .contains ("%{input}" ) && getPrimaryInput () != null ) {
484+ progressMessageStr =
485+ progressMessageStr .replace ("%{input}" , getPrimaryInput ().getExecPathString ());
486+ }
487+ return progressMessageStr ;
488+ } else {
489+ // handles OnDemandString
490+ return progressMessage .toString ();
491+ }
474492 }
475493 return super .getRawProgressMessage ();
476494 }
@@ -1172,14 +1190,9 @@ public Builder addCommandLine(CommandLine commandLine, @Nullable ParamFileInfo p
11721190 /**
11731191 * Sets the progress message.
11741192 *
1175- * <p>If you are formatting the string in any way, prefer one of the overloads that do the
1176- * formatting lazily. This helps save memory by delaying the construction of the progress
1177- * message string.
1178- *
1179- * <p>If you cannot use simple formatting, try {@link
1180- * Builder#setProgressMessage(OnDemandString)}.
1181- *
1182- * <p>If you must eagerly compute the string, use {@link Builder#setProgressMessageNonLazy}.
1193+ * <p>The message may contain <code>%{label}</code>, <code>%{input}</code> or <code>%{output}
1194+ * </code> patterns, which are substituted with label string, first input or output's path,
1195+ * respectively.
11831196 */
11841197 public Builder setProgressMessage (@ CompileTimeConstant String progressMessage ) {
11851198 this .progressMessage = progressMessage ;
@@ -1191,8 +1204,10 @@ public Builder setProgressMessage(@CompileTimeConstant String progressMessage) {
11911204 *
11921205 * @param progressMessage The message to display
11931206 * @param subject Passed to {@link String#format}
1207+ * @deprecated Use {@link #setProgressMessage(String)} with provided patterns.
11941208 */
11951209 @ FormatMethod
1210+ @ Deprecated
11961211 public Builder setProgressMessage (@ FormatString String progressMessage , Object subject ) {
11971212 return setProgressMessage (
11981213 new OnDemandString () {
@@ -1209,8 +1224,10 @@ public String toString() {
12091224 * @param progressMessage The message to display
12101225 * @param subject0 Passed to {@link String#format}
12111226 * @param subject1 Passed to {@link String#format}
1227+ * @deprecated Use {@link #setProgressMessage(String)} with provided patterns.
12121228 */
12131229 @ FormatMethod
1230+ @ Deprecated
12141231 public Builder setProgressMessage (
12151232 @ FormatString String progressMessage , Object subject0 , Object subject1 ) {
12161233 return setProgressMessage (
@@ -1229,8 +1246,10 @@ public String toString() {
12291246 * @param subject0 Passed to {@link String#format}
12301247 * @param subject1 Passed to {@link String#format}
12311248 * @param subject2 Passed to {@link String#format}
1249+ * @deprecated Use {@link #setProgressMessage(String)} with provided patterns.
12321250 */
12331251 @ FormatMethod
1252+ @ Deprecated
12341253 public Builder setProgressMessage (
12351254 @ FormatString String progressMessage , Object subject0 , Object subject1 , Object subject2 ) {
12361255 return setProgressMessage (
@@ -1250,8 +1269,10 @@ public String toString() {
12501269 * @param subject1 Passed to {@link String#format}
12511270 * @param subject2 Passed to {@link String#format}
12521271 * @param subject3 Passed to {@link String#format}
1272+ * @deprecated Use {@link #setProgressMessage(String)} with provided patterns.
12531273 */
12541274 @ FormatMethod
1275+ @ Deprecated
12551276 public Builder setProgressMessage (
12561277 @ FormatString String progressMessage ,
12571278 Object subject0 ,
@@ -1273,17 +1294,18 @@ public String toString() {
12731294 * <p>When possible, prefer use of one of the overloads that use {@link String#format}. If you
12741295 * do use this overload, take care not to capture anything expensive.
12751296 */
1276- public Builder setProgressMessage (OnDemandString progressMessage ) {
1297+ private Builder setProgressMessage (OnDemandString progressMessage ) {
12771298 this .progressMessage = progressMessage ;
12781299 return this ;
12791300 }
12801301
12811302 /**
1282- * Sets an eagerly computed progress message.
1303+ * Sets the progress message.
12831304 *
1284- * <p>Prefer one of the lazy overloads whenever possible, as it will generally save memory.
1305+ * <p>Same as {@link #setProgressMessage(String)}, except that it may be used with non compile
1306+ * time constants (needed for Starlark literals).
12851307 */
1286- public Builder setProgressMessageNonLazy (String progressMessage ) {
1308+ public Builder setProgressMessageFromStarlark (String progressMessage ) {
12871309 this .progressMessage = progressMessage ;
12881310 return this ;
12891311 }
0 commit comments