Add BundledFileSystem
This is an InMemoryFileSystem whose contents are guaranteed to not change during Skyframe evaluation. It produces fake, constant digest values, and ExternalFilesHelper identifies its files as FileType.BUNDLED rather than as external files.
Work toward #11437.
PiperOrigin-RevId: 363245300
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java b/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java
index c4e85d1..da07b4d 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java
@@ -16,6 +16,7 @@
import com.google.common.base.Preconditions;
import com.google.common.flogger.GoogleLogger;
import com.google.devtools.build.lib.analysis.BlazeDirectories;
+import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.BundledFileSystem;
import com.google.devtools.build.lib.cmdline.LabelConstants;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible;
@@ -151,6 +152,13 @@
/** Classification of a path encountered by Bazel. */
public enum FileType {
+ /**
+ * A path to a file located inside of Bazel, e.g. the bundled builtins_bzl root (for {@code
+ * --experimental_builtins_bzl_root=%bundled%}) that live in an InMemoryFileSystem. These files
+ * must not change throughout the lifetime of the server.
+ */
+ BUNDLED,
+
/** A path inside the package roots. */
INTERNAL,
@@ -259,7 +267,14 @@
return Pair.of(fileType, null);
}
+ /**
+ * Returns the classification of a path, and updates this instance's state regarding what kinds of
+ * paths have been seen.
+ */
private FileType detectFileType(RootedPath rootedPath) {
+ if (rootedPath.getRoot().getFileSystem() instanceof BundledFileSystem) {
+ return FileType.BUNDLED;
+ }
PathPackageLocator packageLocator = pkgLocator.get();
if (packageLocator.getPathEntries().contains(rootedPath.getRoot())) {
return FileType.INTERNAL;
@@ -305,6 +320,7 @@
externalFileAction);
RepositoryFunction.addManagedDirectoryDependencies(pair.getSecond(), env);
break;
+ case BUNDLED:
case INTERNAL:
break;
case EXTERNAL: