aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2017-12-15 13:48:29 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-12-15 13:49:50 -0800
commit931d285e6002197af1fda0d910de07148b617c98 (patch)
tree635ecfb58381918ac77b7e90ddd027f62f5bd3e0 /src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
parent39ff208b0e6ee18f4d684db458e8599f60e08dd4 (diff)
Optionally allow loaded packages to not be tracked.
If we are running with a single source root and not going to set up the execroot (since we know how to resolve all packages), we can avoid tracking loaded packages, since they're only used to set up the execroot. PiperOrigin-RevId: 179234932
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
index 8cfee6a5ee..a11e27a092 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java
@@ -38,20 +38,21 @@ import javax.annotation.Nullable;
@VisibleForTesting
public final class ConfiguredTargetValue extends ActionLookupValue {
- // These variables are only non-final because they may be clear()ed to save memory. They are null
- // only after they are cleared.
+ // These variables are only non-final because they may be clear()ed to save memory.
+ // configuredTarget is null only after it is cleared.
@Nullable private ConfiguredTarget configuredTarget;
- @Nullable private NestedSet<Package> transitivePackages;
+ // May be null either after clearing or because transitive packages are not tracked.
+ @Nullable private NestedSet<Package> transitivePackagesForPackageRootResolution;
ConfiguredTargetValue(
ConfiguredTarget configuredTarget,
GeneratingActions generatingActions,
- NestedSet<Package> transitivePackages,
+ @Nullable NestedSet<Package> transitivePackagesForPackageRootResolution,
boolean removeActionsAfterEvaluation) {
super(generatingActions, removeActionsAfterEvaluation);
this.configuredTarget = Preconditions.checkNotNull(configuredTarget, generatingActions);
- this.transitivePackages = Preconditions.checkNotNull(transitivePackages, generatingActions);
+ this.transitivePackagesForPackageRootResolution = transitivePackagesForPackageRootResolution;
}
@VisibleForTesting
@@ -66,8 +67,14 @@ public final class ConfiguredTargetValue extends ActionLookupValue {
return actions;
}
- public NestedSet<Package> getTransitivePackages() {
- return Preconditions.checkNotNull(transitivePackages);
+ /**
+ * Returns the set of packages transitively loaded by this value. Must only be used for
+ * constructing the package -> source root map needed for some builds. If the caller has not
+ * specified that this map needs to be constructed (via the constructor argument in {@link
+ * ConfiguredTargetFunction#ConfiguredTargetFunction}), calling this will crash.
+ */
+ public NestedSet<Package> getTransitivePackagesForPackageRootResolution() {
+ return Preconditions.checkNotNull(transitivePackagesForPackageRootResolution);
}
/**
@@ -79,16 +86,16 @@ public final class ConfiguredTargetValue extends ActionLookupValue {
* called.
*
* @param clearEverything if true, clear the {@link #configuredTarget}. If not, only the {@link
- * #transitivePackages} field is cleared. Top-level targets need their {@link
- * #configuredTarget} preserved, so should pass false here.
+ * #transitivePackagesForPackageRootResolution} field is cleared. Top-level targets need their
+ * {@link #configuredTarget} preserved, so should pass false here.
*/
public void clear(boolean clearEverything) {
Preconditions.checkNotNull(configuredTarget);
- Preconditions.checkNotNull(transitivePackages);
+ Preconditions.checkNotNull(transitivePackagesForPackageRootResolution);
if (clearEverything) {
configuredTarget = null;
}
- transitivePackages = null;
+ transitivePackagesForPackageRootResolution = null;
}
@VisibleForTesting