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
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AspectResolver.java b/src/main/java/com/google/devtools/build/lib/analysis/AspectResolver.java
index 87a942d..d5e1f00 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/AspectResolver.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/AspectResolver.java
@@ -30,7 +30,6 @@
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.ValueOrException2;
-
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -52,7 +51,7 @@
SkyFunction.Environment env,
Map<SkyKey, ConfiguredTarget> configuredTargetMap,
Iterable<Dependency> deps,
- NestedSetBuilder<Package> transitivePackages)
+ @Nullable NestedSetBuilder<Package> transitivePackages)
throws AspectFunction.AspectCreationException, InterruptedException {
OrderedSetMultimap<Dependency, ConfiguredAspect> result = OrderedSetMultimap.create();
Set<SkyKey> allAspectKeys = new HashSet<>();
@@ -97,7 +96,10 @@
}
result.put(dep, aspectValue.getConfiguredAspect());
- transitivePackages.addTransitive(aspectValue.getTransitivePackages());
+ if (transitivePackages != null) {
+ transitivePackages.addTransitive(
+ aspectValue.getTransitivePackagesForPackageRootResolution());
+ }
}
}
return result;
@@ -168,4 +170,4 @@
}
return dep.satisfies(aspect.getDefinition().getRequiredProviders());
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
index dab170e..adc0b34 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
@@ -93,14 +93,23 @@
private final BuildViewProvider buildViewProvider;
private final RuleClassProvider ruleClassProvider;
private final Supplier<Boolean> removeActionsAfterEvaluation;
+ /**
+ * Indicates whether the set of packages transitively loaded for a given {@link AspectValue} will
+ * be needed for package root resolution later in the build. If not, they are not collected and
+ * stored.
+ */
+ private final boolean storeTransitivePackagesForPackageRootResolution;
AspectFunction(
BuildViewProvider buildViewProvider,
RuleClassProvider ruleClassProvider,
- Supplier<Boolean> removeActionsAfterEvaluation) {
+ Supplier<Boolean> removeActionsAfterEvaluation,
+ boolean storeTransitivePackagesForPackageRootResolution) {
this.buildViewProvider = buildViewProvider;
this.ruleClassProvider = ruleClassProvider;
this.removeActionsAfterEvaluation = Preconditions.checkNotNull(removeActionsAfterEvaluation);
+ this.storeTransitivePackagesForPackageRootResolution =
+ storeTransitivePackagesForPackageRootResolution;
}
/**
@@ -145,7 +154,6 @@
public SkyValue compute(SkyKey skyKey, Environment env)
throws AspectFunctionException, InterruptedException {
SkyframeBuildView view = buildViewProvider.getSkyframeBuildView();
- NestedSetBuilder<Package> transitivePackages = NestedSetBuilder.stableOrder();
NestedSetBuilder<Label> transitiveRootCauses = NestedSetBuilder.stableOrder();
AspectKey key = (AspectKey) skyKey.argument();
ConfiguredAspectFactory aspectFactory;
@@ -259,6 +267,8 @@
aspectPathBuilder.add(aspect);
SkyframeDependencyResolver resolver = view.createDependencyResolver(env);
+ NestedSetBuilder<Package> transitivePackagesForPackageRootResolution =
+ storeTransitivePackagesForPackageRootResolution ? NestedSetBuilder.stableOrder() : null;
// When getting the dependencies of this hybrid aspect+base target, use the aspect's
// configuration. The configuration of the aspect will always be a superset of the target's
@@ -273,8 +283,12 @@
// Get the configuration targets that trigger this rule's configurable attributes.
ImmutableMap<Label, ConfigMatchingProvider> configConditions =
ConfiguredTargetFunction.getConfigConditions(
- target, env, resolver, originalTargetAndAspectConfiguration,
- transitivePackages, transitiveRootCauses);
+ target,
+ env,
+ resolver,
+ originalTargetAndAspectConfiguration,
+ transitivePackagesForPackageRootResolution,
+ transitiveRootCauses);
if (configConditions == null) {
// Those targets haven't yet been resolved.
return null;
@@ -312,7 +326,7 @@
toolchainContext,
ruleClassProvider,
view.getHostConfiguration(originalTargetAndAspectConfiguration.getConfiguration()),
- transitivePackages,
+ transitivePackagesForPackageRootResolution,
transitiveRootCauses);
} catch (ConfiguredTargetFunctionException e) {
throw new AspectCreationException(e.getMessage());
@@ -337,7 +351,7 @@
configConditions,
toolchainContext,
depValueMap,
- transitivePackages);
+ transitivePackagesForPackageRootResolution);
} catch (DependencyEvaluationException e) {
if (e.getCause() instanceof ConfiguredValueCreationException) {
ConfiguredValueCreationException cause = (ConfiguredValueCreationException) e.getCause();
@@ -434,10 +448,13 @@
return null;
}
- NestedSet<Package> transitivePackages = NestedSetBuilder.<Package>stableOrder()
- .addTransitive(real.getTransitivePackages())
- .add(originalTarget.getPackage())
- .build();
+ NestedSet<Package> transitivePackagesForPackageRootResolution =
+ storeTransitivePackagesForPackageRootResolution
+ ? NestedSetBuilder.<Package>stableOrder()
+ .addTransitive(real.getTransitivePackagesForPackageRootResolution())
+ .add(originalTarget.getPackage())
+ .build()
+ : null;
return new AspectValue(
originalKey,
@@ -447,7 +464,7 @@
ConfiguredAspect.forAlias(real.getConfiguredAspect()),
actionKeyContext,
ImmutableList.of(),
- transitivePackages,
+ transitivePackagesForPackageRootResolution,
removeActionsAfterEvaluation.get());
}
@@ -464,7 +481,7 @@
ImmutableMap<Label, ConfigMatchingProvider> configConditions,
ToolchainContext toolchainContext,
OrderedSetMultimap<Attribute, ConfiguredTarget> directDeps,
- NestedSetBuilder<Package> transitivePackages)
+ @Nullable NestedSetBuilder<Package> transitivePackagesForPackageRootResolution)
throws AspectFunctionException, InterruptedException {
SkyframeBuildView view = buildViewProvider.getSkyframeBuildView();
@@ -524,7 +541,9 @@
configuredAspect,
actionKeyContext,
ImmutableList.copyOf(analysisEnvironment.getRegisteredActions()),
- transitivePackages.build(),
+ transitivePackagesForPackageRootResolution == null
+ ? null
+ : transitivePackagesForPackageRootResolution.build(),
removeActionsAfterEvaluation.get());
}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java
index fb81622..a6ecc98 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java
@@ -308,15 +308,15 @@
}
}
-
// These variables are only non-final because they may be clear()ed to save memory. They are null
- // only after they are cleared.
+ // only after they are cleared except for transitivePackagesForPackageRootResolution.
@Nullable private Label label;
@Nullable private Aspect aspect;
@Nullable private Location location;
@Nullable private AspectKey key;
@Nullable private ConfiguredAspect configuredAspect;
- @Nullable private NestedSet<Package> transitivePackages;
+ // May be null either after clearing or because transitive packages are not tracked.
+ @Nullable private NestedSet<Package> transitivePackagesForPackageRootResolution;
public AspectValue(
AspectKey key,
@@ -326,7 +326,7 @@
ConfiguredAspect configuredAspect,
ActionKeyContext actionKeyContext,
List<ActionAnalysisMetadata> actions,
- NestedSet<Package> transitivePackages,
+ NestedSet<Package> transitivePackagesForPackageRootResolution,
boolean removeActionsAfterEvaluation) {
super(actionKeyContext, actions, removeActionsAfterEvaluation);
this.label = Preconditions.checkNotNull(label, actions);
@@ -334,7 +334,7 @@
this.location = Preconditions.checkNotNull(location, label);
this.key = Preconditions.checkNotNull(key, label);
this.configuredAspect = Preconditions.checkNotNull(configuredAspect, label);
- this.transitivePackages = Preconditions.checkNotNull(transitivePackages, label);
+ this.transitivePackagesForPackageRootResolution = transitivePackagesForPackageRootResolution;
}
public ConfiguredAspect getConfiguredAspect() {
@@ -363,7 +363,7 @@
Preconditions.checkNotNull(location, this);
Preconditions.checkNotNull(key, this);
Preconditions.checkNotNull(configuredAspect, this);
- Preconditions.checkNotNull(transitivePackages, this);
+ Preconditions.checkNotNull(transitivePackagesForPackageRootResolution, this);
if (clearEverything) {
label = null;
aspect = null;
@@ -371,11 +371,17 @@
key = null;
configuredAspect = null;
}
- transitivePackages = null;
+ transitivePackagesForPackageRootResolution = null;
}
- 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
+ * AspectFunction#AspectFunction}), calling this will crash.
+ */
+ public NestedSet<Package> getTransitivePackagesForPackageRootResolution() {
+ return Preconditions.checkNotNull(transitivePackagesForPackageRootResolution);
}
// TODO(janakr): Add a nice toString after cl/150542180 is submitted.
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
index 8a34fdd..51584f2 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
@@ -112,23 +112,33 @@
private final RuleClassProvider ruleClassProvider;
private final Semaphore cpuBoundSemaphore;
private final Supplier<Boolean> removeActionsAfterEvaluation;
+ /**
+ * Indicates whether the set of packages transitively loaded for a given {@link
+ * ConfiguredTargetValue} will be needed for package root resolution later in the build. If not,
+ * they are not collected and stored.
+ */
+ private final boolean storeTransitivePackagesForPackageRootResolution;
ConfiguredTargetFunction(
BuildViewProvider buildViewProvider,
RuleClassProvider ruleClassProvider,
Semaphore cpuBoundSemaphore,
- Supplier<Boolean> removeActionsAfterEvaluation) {
+ Supplier<Boolean> removeActionsAfterEvaluation,
+ boolean storeTransitivePackagesForPackageRootResolution) {
this.buildViewProvider = buildViewProvider;
this.ruleClassProvider = ruleClassProvider;
this.cpuBoundSemaphore = cpuBoundSemaphore;
this.removeActionsAfterEvaluation = Preconditions.checkNotNull(removeActionsAfterEvaluation);
+ this.storeTransitivePackagesForPackageRootResolution =
+ storeTransitivePackagesForPackageRootResolution;
}
@Override
public SkyValue compute(SkyKey key, Environment env) throws ConfiguredTargetFunctionException,
InterruptedException {
SkyframeBuildView view = buildViewProvider.getSkyframeBuildView();
- NestedSetBuilder<Package> transitivePackages = NestedSetBuilder.stableOrder();
+ NestedSetBuilder<Package> transitivePackagesForPackageRootResolution =
+ storeTransitivePackagesForPackageRootResolution ? NestedSetBuilder.stableOrder() : null;
NestedSetBuilder<Label> transitiveLoadingRootCauses = NestedSetBuilder.stableOrder();
ConfiguredTargetKey configuredTargetKey = (ConfiguredTargetKey) key.argument();
LabelAndConfiguration lc = LabelAndConfiguration.of(
@@ -155,7 +165,9 @@
if (pkg.containsErrors()) {
transitiveLoadingRootCauses.add(lc.getLabel());
}
- transitivePackages.add(pkg);
+ if (transitivePackagesForPackageRootResolution != null) {
+ transitivePackagesForPackageRootResolution.add(pkg);
+ }
// TODO(bazel-team): This is problematic - we create the right key, but then end up with a value
// that doesn't match; we can even have the same value multiple times. However, I think it's
// only triggered in tests (i.e., in normal operation, the configuration passed in is already
@@ -187,9 +199,14 @@
cpuBoundSemaphore.acquire();
try {
// Get the configuration targets that trigger this rule's configurable attributes.
- ImmutableMap<Label, ConfigMatchingProvider> configConditions = getConfigConditions(
- ctgValue.getTarget(), env, resolver, ctgValue, transitivePackages,
- transitiveLoadingRootCauses);
+ ImmutableMap<Label, ConfigMatchingProvider> configConditions =
+ getConfigConditions(
+ ctgValue.getTarget(),
+ env,
+ resolver,
+ ctgValue,
+ transitivePackagesForPackageRootResolution,
+ transitiveLoadingRootCauses);
if (env.valuesMissing()) {
return null;
}
@@ -231,7 +248,7 @@
toolchainContext,
ruleClassProvider,
view.getHostConfiguration(configuration),
- transitivePackages,
+ transitivePackagesForPackageRootResolution,
transitiveLoadingRootCauses);
if (env.valuesMissing()) {
return null;
@@ -250,7 +267,7 @@
depValueMap,
configConditions,
toolchainContext,
- transitivePackages);
+ transitivePackagesForPackageRootResolution);
return ans;
} catch (DependencyEvaluationException e) {
if (e.getCause() instanceof ConfiguredValueCreationException) {
@@ -350,7 +367,7 @@
@Nullable ToolchainContext toolchainContext,
RuleClassProvider ruleClassProvider,
BuildConfiguration hostConfiguration,
- NestedSetBuilder<Package> transitivePackages,
+ @Nullable NestedSetBuilder<Package> transitivePackagesForPackageRootResolution,
NestedSetBuilder<Label> transitiveLoadingRootCauses)
throws DependencyEvaluationException, ConfiguredTargetFunctionException,
AspectCreationException, InterruptedException {
@@ -391,16 +408,20 @@
}
// Resolve configured target dependencies and handle errors.
- Map<SkyKey, ConfiguredTarget> depValues = resolveConfiguredTargetDependencies(env,
- depValueNames.values(), transitivePackages, transitiveLoadingRootCauses);
+ Map<SkyKey, ConfiguredTarget> depValues =
+ resolveConfiguredTargetDependencies(
+ env,
+ depValueNames.values(),
+ transitivePackagesForPackageRootResolution,
+ transitiveLoadingRootCauses);
if (depValues == null) {
return null;
}
// Resolve required aspects.
OrderedSetMultimap<Dependency, ConfiguredAspect> depAspects =
- AspectResolver.resolveAspectDependencies(env, depValues, depValueNames.values(),
- transitivePackages);
+ AspectResolver.resolveAspectDependencies(
+ env, depValues, depValueNames.values(), transitivePackagesForPackageRootResolution);
if (depAspects == null) {
return null;
}
@@ -430,7 +451,7 @@
Environment env,
SkyframeDependencyResolver resolver,
TargetAndConfiguration ctgValue,
- NestedSetBuilder<Package> transitivePackages,
+ @Nullable NestedSetBuilder<Package> transitivePackagesForPackageRootResolution,
NestedSetBuilder<Label> transitiveLoadingRootCauses)
throws DependencyEvaluationException, InterruptedException {
if (!(target instanceof Rule)) {
@@ -477,8 +498,12 @@
}
configValueNames = staticConfigs.build();
- Map<SkyKey, ConfiguredTarget> configValues = resolveConfiguredTargetDependencies(
- env, configValueNames, transitivePackages, transitiveLoadingRootCauses);
+ Map<SkyKey, ConfiguredTarget> configValues =
+ resolveConfiguredTargetDependencies(
+ env,
+ configValueNames,
+ transitivePackagesForPackageRootResolution,
+ transitiveLoadingRootCauses);
if (configValues == null) {
return null;
}
@@ -514,7 +539,7 @@
private static Map<SkyKey, ConfiguredTarget> resolveConfiguredTargetDependencies(
Environment env,
Collection<Dependency> deps,
- NestedSetBuilder<Package> transitivePackages,
+ @Nullable NestedSetBuilder<Package> transitivePackagesForPackageRootResolution,
NestedSetBuilder<Label> transitiveLoadingRootCauses)
throws DependencyEvaluationException, InterruptedException {
boolean missedValues = env.valuesMissing();
@@ -533,7 +558,10 @@
missedValues = true;
} else {
result.put(entry.getKey(), depValue.getConfiguredTarget());
- transitivePackages.addTransitive(depValue.getTransitivePackages());
+ if (transitivePackagesForPackageRootResolution != null) {
+ transitivePackagesForPackageRootResolution.addTransitive(
+ depValue.getTransitivePackagesForPackageRootResolution());
+ }
}
} catch (ConfiguredValueCreationException e) {
// TODO(ulfjack): If there is an analysis root cause, we drop all loading root causes.
@@ -569,7 +597,7 @@
OrderedSetMultimap<Attribute, ConfiguredTarget> depValueMap,
ImmutableMap<Label, ConfigMatchingProvider> configConditions,
@Nullable ToolchainContext toolchainContext,
- NestedSetBuilder<Package> transitivePackages)
+ @Nullable NestedSetBuilder<Package> transitivePackagesForPackageRootResolution)
throws ConfiguredTargetFunctionException, InterruptedException {
StoredEventHandler events = new StoredEventHandler();
BuildConfiguration ownerConfig =
@@ -624,7 +652,9 @@
return new ConfiguredTargetValue(
configuredTarget,
generatingActions,
- transitivePackages.build(),
+ transitivePackagesForPackageRootResolution == null
+ ? null
+ : transitivePackagesForPackageRootResolution.build(),
removeActionsAfterEvaluation.get());
}
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 8cfee6a..a11e27a 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 @@
@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 @@
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 @@
* 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
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java
index a1ba4e5..74c1cba 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java
@@ -218,7 +218,9 @@
skyframeExecutor.findArtifactConflicts();
Collection<AspectValue> goodAspects = Lists.newArrayListWithCapacity(values.size());
- NestedSetBuilder<Package> packages = NestedSetBuilder.stableOrder();
+ Path singleSourceRoot = skyframeExecutor.getForcedSingleSourceRootIfNoExecrootSymlinkCreation();
+ NestedSetBuilder<Package> packages =
+ singleSourceRoot == null ? NestedSetBuilder.stableOrder() : null;
for (AspectValueKey aspectKey : aspectKeys) {
AspectValue value = (AspectValue) result.get(aspectKey.getSkyKey());
if (value == null) {
@@ -226,7 +228,9 @@
continue;
}
goodAspects.add(value);
- packages.addTransitive(value.getTransitivePackages());
+ if (packages != null) {
+ packages.addTransitive(value.getTransitivePackagesForPackageRootResolution());
+ }
}
// Filter out all CTs that have a bad action and convert to a list of configured targets. This
@@ -240,9 +244,10 @@
continue;
}
goodCts.add(ctValue.getConfiguredTarget());
- packages.addTransitive(ctValue.getTransitivePackages());
+ if (packages != null) {
+ packages.addTransitive(ctValue.getTransitivePackagesForPackageRootResolution());
+ }
}
- Path singleSourceRoot = skyframeExecutor.getForcedSingleSourceRootIfNoExecrootSymlinkCreation();
PackageRoots packageRoots =
singleSourceRoot == null
? new MapAsPackageRoots(
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
index b23f49f..96fbd0b 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -415,11 +415,15 @@
new BuildViewProvider(),
ruleClassProvider,
cpuBoundSemaphore,
- removeActionsAfterEvaluation));
+ removeActionsAfterEvaluation,
+ shouldStoreTransitivePackagesInLoadingAndAnalysis()));
map.put(
SkyFunctions.ASPECT,
new AspectFunction(
- new BuildViewProvider(), ruleClassProvider, removeActionsAfterEvaluation));
+ new BuildViewProvider(),
+ ruleClassProvider,
+ removeActionsAfterEvaluation,
+ shouldStoreTransitivePackagesInLoadingAndAnalysis()));
map.put(SkyFunctions.LOAD_SKYLARK_ASPECT, new ToplevelSkylarkAspectFunction());
map.put(SkyFunctions.POST_CONFIGURED_TARGET,
new PostConfiguredTargetFunction(new BuildViewProvider(), ruleClassProvider));
@@ -703,11 +707,22 @@
return true;
}
+ /**
+ * If not null, this is the only source root in the build, corresponding to the single element in
+ * a single-element package path. Such a single-source-root build need not plant the execroot
+ * symlink forest, and can trivially resolve source artifacts from exec paths. As a consequence,
+ * builds where this is not null do not need to track a package -> source root map, and so do not
+ * need to track all loaded packages.
+ */
@Nullable
protected Path getForcedSingleSourceRootIfNoExecrootSymlinkCreation() {
return null;
}
+ private boolean shouldStoreTransitivePackagesInLoadingAndAnalysis() {
+ return getForcedSingleSourceRootIfNoExecrootSymlinkCreation() == null;
+ }
+
@VisibleForTesting
protected abstract Injectable injectable();