Have GlobFunction make use of the assumption that the glob's package exists by having it not declare a dep on the PackageLookupValue for the package. This optimization means that a BUILD file edit doesn't (necessarily) invalidate all the globs in the package; the PackageLookupValue node would get change-pruned but we still pay the very small cost of invalidating unnecessarily.
Also slightly improve variable naming in GlobFunctionTest.
--
MOS_MIGRATED_REVID=113799936
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/GlobValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/GlobValue.java
index 127db0c..5e877bd 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/GlobValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/GlobValue.java
@@ -20,6 +20,7 @@
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import com.google.devtools.build.lib.util.Preconditions;
+import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.UnixGlob;
import com.google.devtools.build.skyframe.SkyKey;
@@ -79,9 +80,8 @@
* @throws InvalidGlobPatternException if the pattern is not valid.
*/
@ThreadSafe
- public static SkyKey key(PackageIdentifier packageId, String pattern, boolean excludeDirs,
- PathFragment subdir)
- throws InvalidGlobPatternException {
+ public static SkyKey key(PackageIdentifier packageId, Path packageRoot, String pattern,
+ boolean excludeDirs, PathFragment subdir) throws InvalidGlobPatternException {
if (pattern.indexOf('?') != -1) {
throw new InvalidGlobPatternException(pattern, "wildcard ? forbidden");
}
@@ -91,7 +91,7 @@
throw new InvalidGlobPatternException(pattern, error);
}
- return internalKey(packageId, subdir, pattern, excludeDirs);
+ return internalKey(packageId, packageRoot, subdir, pattern, excludeDirs);
}
/**
@@ -100,10 +100,10 @@
* <p>Do not use outside {@code GlobFunction}.
*/
@ThreadSafe
- static SkyKey internalKey(PackageIdentifier packageId, PathFragment subdir, String pattern,
- boolean excludeDirs) {
+ static SkyKey internalKey(PackageIdentifier packageId, Path packageRoot, PathFragment subdir,
+ String pattern, boolean excludeDirs) {
return new SkyKey(SkyFunctions.GLOB,
- new GlobDescriptor(packageId, subdir, pattern, excludeDirs));
+ new GlobDescriptor(packageId, packageRoot, subdir, pattern, excludeDirs));
}
/**
@@ -113,7 +113,7 @@
*/
@ThreadSafe
static SkyKey internalKey(GlobDescriptor glob, String subdirName) {
- return internalKey(glob.packageId, glob.subdir.getRelative(subdirName),
+ return internalKey(glob.packageId, glob.packageRoot, glob.subdir.getRelative(subdirName),
glob.pattern, glob.excludeDirs);
}