Remove SourceManifestAction.Builder

This Builder class is superfluous - it simply wraps Runfiles.Builder,
and forwards all calls to that. Instead, update all callers to construct
a Runfiles object directly and pass that in.

This is in preparation for changing SymlinkTreeAction to also take a
Runfiles object instead of reading the manifest back in from disk. This
makes it possible to remove the manifests if they aren't needed, as well
as fixing the handling of whitespace in runfiles paths.

PiperOrigin-RevId: 281018764
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java b/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java
index 1334daa..7d5f40a 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java
@@ -354,7 +354,7 @@
     context
         .getAnalysisEnvironment()
         .registerAction(
-            SourceManifestAction.forRunfiles(
+            new SourceManifestAction(
                 ManifestType.SOURCE_SYMLINKS, context.getActionOwner(), inputManifest, runfiles));
 
     if (!createSymlinks) {
@@ -402,7 +402,7 @@
     context
         .getAnalysisEnvironment()
         .registerAction(
-            SourceManifestAction.forRunfiles(
+            new SourceManifestAction(
                 ManifestType.SOURCES_ONLY, context.getActionOwner(), sourceOnlyManifest, runfiles));
     return sourceOnlyManifest;
   }
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
index d9ae7c2..26b045a 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
@@ -26,7 +26,6 @@
 import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
 import com.google.devtools.build.lib.events.EventHandler;
 import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
-import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
 import com.google.devtools.build.lib.util.Fingerprint;
 import com.google.devtools.build.lib.vfs.PathFragment;
 import java.io.BufferedWriter;
@@ -109,8 +108,7 @@
    * @param primaryOutput the file to which to write the manifest
    * @param runfiles runfiles
    */
-  @VisibleForSerialization
-  SourceManifestAction(
+  public SourceManifestAction(
       ManifestWriter manifestWriter, ActionOwner owner, Artifact primaryOutput, Runfiles runfiles) {
     super(owner, getDependencies(runfiles), primaryOutput, false);
     this.manifestWriter = manifestWriter;
@@ -285,100 +283,4 @@
       }
     }
   }
-
-  /** Creates an action for the given runfiles. */
-  public static SourceManifestAction forRunfiles(ManifestType manifestType, ActionOwner owner,
-      Artifact output, Runfiles runfiles) {
-    return new SourceManifestAction(manifestType, owner, output, runfiles);
-  }
-
-  /**
-   * Builder class to construct {@link SourceManifestAction} instances.
-   */
-  public static final class Builder {
-    private final ManifestWriter manifestWriter;
-    private final ActionOwner owner;
-    private final Artifact output;
-    private final Runfiles.Builder runfilesBuilder;
-
-    public Builder(String prefix, ManifestType manifestType, ActionOwner owner, Artifact output,
-                   boolean legacyExternalRunfiles) {
-      this(manifestType, owner, output, new Runfiles.Builder(prefix, legacyExternalRunfiles));
-    }
-
-    public Builder(
-        ManifestType manifestType,
-        ActionOwner owner,
-        Artifact output,
-        Runfiles.Builder runfilesBuilder) {
-      this.manifestWriter = manifestType;
-      this.owner = owner;
-      this.output = output;
-      this.runfilesBuilder = runfilesBuilder;
-    }
-
-    @VisibleForTesting  // Only used for testing.
-    Builder(String prefix, ManifestWriter manifestWriter, ActionOwner owner, Artifact output) {
-      this.runfilesBuilder = new Runfiles.Builder(prefix, false);
-      this.manifestWriter = manifestWriter;
-      this.owner = owner;
-      this.output = output;
-    }
-
-    public SourceManifestAction build() {
-      return new SourceManifestAction(manifestWriter, owner, output, runfilesBuilder.build());
-    }
-
-    /**
-     * Adds a set of symlinks from the artifacts' root-relative paths to the
-     * artifacts themselves.
-     */
-    public Builder addSymlinks(Iterable<Artifact> artifacts) {
-      runfilesBuilder.addArtifacts(artifacts);
-      return this;
-    }
-
-    /**
-     * Adds a map of symlinks.
-     */
-    public Builder addSymlinks(Map<PathFragment, Artifact> symlinks) {
-      runfilesBuilder.addSymlinks(symlinks);
-      return this;
-    }
-
-    /**
-     * Adds a single symlink.
-     */
-    public Builder addSymlink(PathFragment link, Artifact target) {
-      runfilesBuilder.addSymlink(link, target);
-      return this;
-    }
-
-    /**
-     * <p>Adds a mapping of Artifacts to the directory above the normal symlink
-     * forest base.
-     */
-    public Builder addRootSymlinks(Map<PathFragment, Artifact> rootSymlinks) {
-      runfilesBuilder.addRootSymlinks(rootSymlinks);
-      return this;
-    }
-
-    /**
-     * Set the empty files supplier for the manifest, see {@link Runfiles.EmptyFilesSupplier}
-     * for more details.
-     */
-    public Builder setEmptyFilesSupplier(Runfiles.EmptyFilesSupplier supplier) {
-      runfilesBuilder.setEmptyFilesSupplier(supplier);
-      return this;
-    }
-
-    /**
-     * Adds a runfiles pruning manifest.
-     */
-    @VisibleForTesting
-    Builder addPruningManifest(Runfiles.PruningManifest manifest) {
-      runfilesBuilder.addPruningManifest(manifest);
-      return this;
-    }
-  }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/NativeLibs.java b/src/main/java/com/google/devtools/build/lib/rules/android/NativeLibs.java
index 1af81ff..f142033 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/NativeLibs.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/NativeLibs.java
@@ -166,23 +166,22 @@
       return null;
     }
 
-    Runfiles.Builder runfiles =
+    Runfiles runfiles =
         new Runfiles.Builder(
-            ruleContext.getWorkspaceName(),
-            ruleContext.getConfiguration().legacyExternalRunfiles());
-    runfiles.addRootSymlinks(symlinks);
+                ruleContext.getWorkspaceName(),
+                ruleContext.getConfiguration().legacyExternalRunfiles())
+            .addRootSymlinks(symlinks)
+            .build();
     if (!ruleContext.getConfiguration().buildRunfilesManifests()) {
-      return new ManifestAndRunfiles(/*manifest=*/ null, runfiles.build());
+      return new ManifestAndRunfiles(/*manifest=*/ null, runfiles);
     }
 
     Artifact inputManifest = AndroidBinary.getDxArtifact(ruleContext, "native_symlinks.manifest");
-    SourceManifestAction sourceManifestAction =
-        new SourceManifestAction.Builder(
-                ManifestType.SOURCE_SYMLINKS, ruleContext.getActionOwner(), inputManifest, runfiles)
-            .build();
-    ruleContext.registerAction(sourceManifestAction);
-    Artifact outputManifest = AndroidBinary.getDxArtifact(ruleContext, "native_symlinks/MANIFEST");
+    ruleContext.registerAction(
+        new SourceManifestAction(
+            ManifestType.SOURCE_SYMLINKS, ruleContext.getActionOwner(), inputManifest, runfiles));
 
+    Artifact outputManifest = AndroidBinary.getDxArtifact(ruleContext, "native_symlinks/MANIFEST");
     ruleContext.registerAction(
         new SymlinkTreeAction(
             ruleContext.getActionOwner(),
@@ -191,7 +190,7 @@
             false,
             ruleContext.getConfiguration().getActionEnvironment(),
             ruleContext.getConfiguration().runfilesEnabled()));
-    return new ManifestAndRunfiles(outputManifest, sourceManifestAction.getGeneratedRunfiles());
+    return new ManifestAndRunfiles(outputManifest, runfiles);
   }
 
   /**