protoc: allow customization of mnemonic for proto compile actions.

PiperOrigin-RevId: 410893744
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 34c81e3..a56600b 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
@@ -52,12 +52,12 @@
 
 /** Constructs actions to run the protocol compiler to generate sources from .proto files. */
 public class ProtoCompileActionBuilder {
+  private static final String DEFAULT_MNEMONIC = "GenProto";
+
   @VisibleForTesting
   public static final String STRICT_DEPS_FLAG_TEMPLATE =
       "--direct_dependencies_violation_msg=" + ProtoConstants.STRICT_PROTO_DEPS_VIOLATION_MESSAGE;
 
-  private static final String MNEMONIC = "GenProto";
-
   private final RuleContext ruleContext;
   private final ProtoInfo protoInfo;
   private final FilesToRunProvider protoCompiler;
@@ -71,6 +71,7 @@
   private Iterable<String> additionalCommandLineArguments;
   private Iterable<FilesToRunProvider> additionalTools;
   private boolean checkStrictImportPublic;
+  private String mnemonic;
 
   public ProtoCompileActionBuilder allowServices(boolean hasServices) {
     this.hasServices = hasServices;
@@ -87,6 +88,11 @@
     return this;
   }
 
+  public ProtoCompileActionBuilder setMnemonic(String mnemonic) {
+    this.mnemonic = mnemonic;
+    return this;
+  }
+
   public ProtoCompileActionBuilder setLangPluginParameter(Supplier<String> langPluginParameter) {
     this.langPluginParameter = langPluginParameter;
     return this;
@@ -122,6 +128,7 @@
     this.language = language;
     this.langPrefix = langPrefix;
     this.outputs = outputs;
+    this.mnemonic = DEFAULT_MNEMONIC;
   }
 
   /** Static class to avoid keeping a reference to this builder after build() is called. */
@@ -238,7 +245,7 @@
             createProtoCompilerCommandLine().build(),
             ParamFileInfo.builder(ParameterFileType.UNQUOTED).build())
         .setProgressMessage("Generating %s proto_library %s", language, ruleContext.getLabel())
-        .setMnemonic(MNEMONIC);
+        .setMnemonic(mnemonic);
 
     return result;
   }
@@ -470,8 +477,7 @@
                 protoToolchain.getCompilerOptions(),
                 siblingRepositoryLayout),
             ParamFileInfo.builder(ParameterFileType.UNQUOTED).build())
-        .setProgressMessage("Generating %s proto_library %s", flavorName, ruleContext.getLabel())
-        .setMnemonic(MNEMONIC);
+        .setProgressMessage("Generating %s proto_library %s", flavorName, ruleContext.getLabel());
 
     return result;
   }