Expose an actions provider on RuleConfiguredTarget instances.
Given a target (for example from a skylark aspect), one will be able to access a list of actions that the target generated using "target.actions". This is without additional memory footprint.
Actions themselves are not fully exposed to skylark (and thus there isn't much meaning to gather from them in skylark yet). Access methods will follow soon.
RELNOTES: None.
PiperOrigin-RevId: 188098079
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionTemplateExpansionValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionTemplateExpansionValue.java
index dd60938..3613787 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionTemplateExpansionValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionTemplateExpansionValue.java
@@ -15,8 +15,8 @@
import com.google.common.base.MoreObjects;
import com.google.common.collect.Interner;
-import com.google.devtools.build.lib.actions.ActionLookupValue;
import com.google.devtools.build.lib.actions.Actions.GeneratingActions;
+import com.google.devtools.build.lib.actions.BasicActionLookupValue;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.BlazeInterners;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
@@ -25,7 +25,7 @@
/**
* Value that stores expanded actions from ActionTemplate.
*/
-public final class ActionTemplateExpansionValue extends ActionLookupValue {
+public final class ActionTemplateExpansionValue extends BasicActionLookupValue {
ActionTemplateExpansionValue(
GeneratingActions generatingActions, boolean removeActionsAfterEvaluation) {
super(generatingActions, removeActionsAfterEvaluation);
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 08c8c06..116d186 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
@@ -19,8 +19,8 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Interner;
-import com.google.devtools.build.lib.actions.ActionLookupValue;
import com.google.devtools.build.lib.actions.Actions.GeneratingActions;
+import com.google.devtools.build.lib.actions.BasicActionLookupValue;
import com.google.devtools.build.lib.analysis.ConfiguredAspect;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.Label;
@@ -42,7 +42,7 @@
/**
* An aspect in the context of the Skyframe graph.
*/
-public final class AspectValue extends ActionLookupValue {
+public final class AspectValue extends BasicActionLookupValue {
/**
* A base class for keys that have AspectValue as a Sky value.
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionValue.java
index 485a6a7..9232f7a 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/BuildInfoCollectionValue.java
@@ -15,8 +15,8 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Interner;
-import com.google.devtools.build.lib.actions.ActionLookupValue;
import com.google.devtools.build.lib.actions.Actions.GeneratingActions;
+import com.google.devtools.build.lib.actions.BasicActionLookupValue;
import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoCollection;
import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -30,7 +30,7 @@
* Value that stores {@link BuildInfoCollection}s generated by {@link BuildInfoFactory} instances.
* These collections are used during analysis (see {@code CachingAnalysisEnvironment}).
*/
-public class BuildInfoCollectionValue extends ActionLookupValue {
+public class BuildInfoCollectionValue extends BasicActionLookupValue {
private final BuildInfoCollection collection;
BuildInfoCollectionValue(
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 962f136..42b32c9 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
@@ -37,6 +37,7 @@
import com.google.devtools.build.lib.analysis.config.ConfigurationResolver;
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
import com.google.devtools.build.lib.analysis.configuredtargets.MergedConfiguredTarget.DuplicateException;
+import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget;
import com.google.devtools.build.lib.buildeventstream.BuildEventId;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
@@ -698,14 +699,19 @@
}
Preconditions.checkNotNull(depValueMap);
- ConfiguredTarget configuredTarget =
- view.createConfiguredTarget(
- target,
- configuration,
- analysisEnvironment,
- depValueMap,
- configConditions,
- toolchainContext);
+ ConfiguredTarget configuredTarget;
+ try {
+ configuredTarget =
+ view.createConfiguredTarget(
+ target,
+ configuration,
+ analysisEnvironment,
+ depValueMap,
+ configConditions,
+ toolchainContext);
+ } catch (ActionConflictException e) {
+ throw new ConfiguredTargetFunctionException(e);
+ }
events.replayOn(env.getListener());
if (events.hasErrors()) {
@@ -725,24 +731,34 @@
analysisEnvironment.disable(target);
Preconditions.checkNotNull(configuredTarget, target);
- GeneratingActions generatingActions;
- // Check for conflicting actions within this configured target (that indicates a bug in the
- // rule implementation).
- try {
- generatingActions =
- Actions.filterSharedActionsAndThrowActionConflict(
- analysisEnvironment.getActionKeyContext(),
- analysisEnvironment.getRegisteredActions());
- } catch (ActionConflictException e) {
- throw new ConfiguredTargetFunctionException(e);
+ if (configuredTarget instanceof RuleConfiguredTarget) {
+ RuleConfiguredTarget ruleConfiguredTarget = (RuleConfiguredTarget) configuredTarget;
+ return new RuleConfiguredTargetValue(
+ ruleConfiguredTarget,
+ transitivePackagesForPackageRootResolution == null
+ ? null
+ : transitivePackagesForPackageRootResolution.build(),
+ removeActionsAfterEvaluation.get());
+ } else {
+ GeneratingActions generatingActions;
+ // Check for conflicting actions within this configured target (that indicates a bug in the
+ // rule implementation).
+ try {
+ generatingActions =
+ Actions.filterSharedActionsAndThrowActionConflict(
+ analysisEnvironment.getActionKeyContext(),
+ analysisEnvironment.getRegisteredActions());
+ } catch (ActionConflictException e) {
+ throw new ConfiguredTargetFunctionException(e);
+ }
+ return new NonRuleConfiguredTargetValue(
+ configuredTarget,
+ generatingActions,
+ transitivePackagesForPackageRootResolution == null
+ ? null
+ : transitivePackagesForPackageRootResolution.build(),
+ removeActionsAfterEvaluation.get());
}
- return new ConfiguredTargetValue(
- configuredTarget,
- generatingActions,
- 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 341da8a..b527d59 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
@@ -1,4 +1,4 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
+// Copyright 2018 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -11,109 +11,26 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
+
package com.google.devtools.build.lib.skyframe;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
+import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
-import com.google.devtools.build.lib.actions.ActionLookupValue;
-import com.google.devtools.build.lib.actions.Actions.GeneratingActions;
-import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
-import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
-import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import com.google.devtools.build.lib.packages.Package;
-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.skyframe.SkyKey;
+import com.google.devtools.build.skyframe.SkyValue;
import java.util.List;
-import javax.annotation.Nullable;
-/** A configured target in the context of a Skyframe graph. */
-@AutoCodec
-@Immutable
-@ThreadSafe
-@VisibleForTesting
-public final class ConfiguredTargetValue extends ActionLookupValue {
- // 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;
-
- // May be null either after clearing or because transitive packages are not tracked.
- @Nullable private NestedSet<Package> transitivePackagesForPackageRootResolution;
-
- @AutoCodec.Instantiator
- @VisibleForSerialization
- ConfiguredTargetValue(
- List<ActionAnalysisMetadata> actions,
- ImmutableMap<Artifact, Integer> generatingActionIndex,
- ConfiguredTarget configuredTarget,
- NestedSet<Package> transitivePackagesForPackageRootResolution) {
- super(actions, generatingActionIndex);
- this.configuredTarget = configuredTarget;
- this.transitivePackagesForPackageRootResolution = transitivePackagesForPackageRootResolution;
- }
-
- ConfiguredTargetValue(
- ConfiguredTarget configuredTarget,
- GeneratingActions generatingActions,
- @Nullable NestedSet<Package> transitivePackagesForPackageRootResolution,
- boolean removeActionsAfterEvaluation) {
- super(generatingActions, removeActionsAfterEvaluation);
- this.configuredTarget = Preconditions.checkNotNull(configuredTarget, generatingActions);
- this.transitivePackagesForPackageRootResolution = transitivePackagesForPackageRootResolution;
- }
-
- @VisibleForTesting
- public ConfiguredTarget getConfiguredTarget() {
- Preconditions.checkNotNull(configuredTarget);
- return configuredTarget;
- }
-
- @VisibleForTesting
- public List<ActionAnalysisMetadata> getActions() {
- Preconditions.checkNotNull(configuredTarget, this);
- return actions;
- }
-
- /**
- * 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);
- }
-
- /**
- * Clears configured target data from this value, leaving only the artifact->generating action
- * map.
- *
- * <p>Should only be used when user specifies --discard_analysis_cache. Must be called at most
- * once per value, after which {@link #getConfiguredTarget} and {@link #getActions} cannot be
- * called.
- *
- * @param clearEverything if true, clear the {@link #configuredTarget}. If not, only the {@link
- * #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(transitivePackagesForPackageRootResolution);
- if (clearEverything) {
- configuredTarget = null;
- }
- transitivePackagesForPackageRootResolution = null;
- }
-
- @VisibleForTesting
- public static SkyKey key(Label label, BuildConfiguration configuration) {
+/**
+ * A {@link SkyValue} for a {@link ConfiguredTarget}.
+ */
+public interface ConfiguredTargetValue extends SkyValue {
+ static SkyKey key(Label label, BuildConfiguration configuration) {
return ConfiguredTargetKey.of(label, configuration);
}
@@ -126,17 +43,35 @@
}
/**
- * Returns a label of ConfiguredTargetValue.
+ * Returns the configured target for this value.
*/
- @ThreadSafe
- static Label extractLabel(SkyKey value) {
- Object valueName = value.argument();
- Preconditions.checkState(valueName instanceof ConfiguredTargetKey, valueName);
- return ((ConfiguredTargetKey) valueName).getLabel();
- }
+ ConfiguredTarget getConfiguredTarget();
- @Override
- public String toString() {
- return getStringHelper().add("configuredTarget", configuredTarget).toString();
- }
+ /**
+ * 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.
+ */
+ NestedSet<Package> getTransitivePackagesForPackageRootResolution();
+
+ /**
+ * Returns the actions registered by the configured target for this value.
+ */
+ List<ActionAnalysisMetadata> getActions();
+
+ /**
+ * Returns the number of {@link Action} objects present in this value.
+ */
+ int getNumActions();
+
+ /**
+ * Clears configured target data from this value, leaving only the artifact->generating action
+ * map.
+ *
+ * <p>Should only be used when user specifies --discard_analysis_cache. Must be called at most
+ * once per value, after which {@link #getConfiguredTarget} and {@link #getActions} cannot be
+ * called.
+ */
+ void clear(boolean clearEverything);
}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/CoverageReportValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/CoverageReportValue.java
index e752285..ce7745a 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/CoverageReportValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/CoverageReportValue.java
@@ -14,15 +14,15 @@
package com.google.devtools.build.lib.skyframe;
-import com.google.devtools.build.lib.actions.ActionLookupValue;
import com.google.devtools.build.lib.actions.Actions.GeneratingActions;
+import com.google.devtools.build.lib.actions.BasicActionLookupValue;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.skyframe.SkyFunctionName;
/**
* A SkyValue to store the coverage report Action and Artifacts.
*/
-public class CoverageReportValue extends ActionLookupValue {
+public class CoverageReportValue extends BasicActionLookupValue {
// There should only ever be one CoverageReportValue value in the graph.
@AutoCodec public static final CoverageReportKey COVERAGE_REPORT_KEY = new CoverageReportKey();
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/NonRuleConfiguredTargetValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/NonRuleConfiguredTargetValue.java
new file mode 100644
index 0000000..b36318b
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/NonRuleConfiguredTargetValue.java
@@ -0,0 +1,117 @@
+// Copyright 2014 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.lib.skyframe;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
+import com.google.devtools.build.lib.actions.Actions.GeneratingActions;
+import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.actions.BasicActionLookupValue;
+import com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
+import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
+import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
+import com.google.devtools.build.lib.packages.Package;
+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.skyframe.SkyKey;
+import java.util.ArrayList;
+import javax.annotation.Nullable;
+
+/**
+ * A configured target in the context of a Skyframe graph.
+ */
+@Immutable
+@ThreadSafe
+@AutoCodec
+@VisibleForTesting
+public final class NonRuleConfiguredTargetValue
+ extends BasicActionLookupValue implements ConfiguredTargetValue {
+
+ // 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;
+
+ // May be null either after clearing or because transitive packages are not tracked.
+ @Nullable private NestedSet<Package> transitivePackagesForPackageRootResolution;
+
+ @AutoCodec.Instantiator
+ @VisibleForSerialization
+ NonRuleConfiguredTargetValue(
+ ArrayList<ActionAnalysisMetadata> actions,
+ ImmutableMap<Artifact, Integer> generatingActionIndex,
+ ConfiguredTarget configuredTarget,
+ NestedSet<Package> transitivePackagesForPackageRootResolution) {
+ super(actions, generatingActionIndex, false);
+ this.configuredTarget = configuredTarget;
+ this.transitivePackagesForPackageRootResolution = transitivePackagesForPackageRootResolution;
+ }
+
+ NonRuleConfiguredTargetValue(
+ ConfiguredTarget configuredTarget,
+ GeneratingActions generatingActions,
+ @Nullable NestedSet<Package> transitivePackagesForPackageRootResolution,
+ boolean removeActionsAfterEvaluation) {
+ super(generatingActions, removeActionsAfterEvaluation);
+ this.configuredTarget = Preconditions.checkNotNull(configuredTarget, generatingActions);
+ this.transitivePackagesForPackageRootResolution = transitivePackagesForPackageRootResolution;
+ }
+
+ @VisibleForTesting
+ @Override
+ public ConfiguredTarget getConfiguredTarget() {
+ Preconditions.checkNotNull(configuredTarget);
+ return configuredTarget;
+ }
+
+ @VisibleForTesting
+ @Override
+ public ArrayList<ActionAnalysisMetadata> getActions() {
+ Preconditions.checkNotNull(configuredTarget, this);
+ return actions;
+ }
+
+ @Override
+ public NestedSet<Package> getTransitivePackagesForPackageRootResolution() {
+ return Preconditions.checkNotNull(transitivePackagesForPackageRootResolution);
+ }
+
+ @Override
+ public void clear(boolean clearEverything) {
+ Preconditions.checkNotNull(configuredTarget);
+ Preconditions.checkNotNull(transitivePackagesForPackageRootResolution);
+ if (clearEverything) {
+ configuredTarget = null;
+ }
+ transitivePackagesForPackageRootResolution = null;
+ }
+
+ /**
+ * Returns a label of NonRuleConfiguredTargetValue.
+ */
+ @ThreadSafe
+ static Label extractLabel(SkyKey value) {
+ Object valueName = value.argument();
+ Preconditions.checkState(valueName instanceof ConfiguredTargetKey, valueName);
+ return ((ConfiguredTargetKey) valueName).getLabel();
+ }
+
+ @Override
+ public String toString() {
+ return getStringHelper().add("configuredTarget", configuredTarget).toString();
+ }
+}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RuleConfiguredTargetValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/RuleConfiguredTargetValue.java
new file mode 100644
index 0000000..8eaa016
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/RuleConfiguredTargetValue.java
@@ -0,0 +1,109 @@
+// Copyright 2014 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.lib.skyframe;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
+import com.google.devtools.build.lib.actions.ActionLookupValue;
+import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
+import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
+import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
+import com.google.devtools.build.lib.packages.Package;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
+import java.util.ArrayList;
+import javax.annotation.Nullable;
+
+/**
+ * A configured target in the context of a Skyframe graph.
+ */
+@Immutable
+@ThreadSafe
+@AutoCodec
+@VisibleForTesting
+public final class RuleConfiguredTargetValue extends ActionLookupValue
+ implements ConfiguredTargetValue {
+
+ // This variable is non-final because it may be clear()ed to save memory. It is null only after
+ // clear(true) is called.
+ @Nullable private RuleConfiguredTarget configuredTarget;
+ private final ArrayList<ActionAnalysisMetadata> actions;
+ private final ImmutableMap<Artifact, Integer> generatingActionIndex;
+
+ // May be null either after clearing or because transitive packages are not tracked.
+ @Nullable private NestedSet<Package> transitivePackagesForPackageRootResolution;
+
+ @AutoCodec.Instantiator
+ RuleConfiguredTargetValue(
+ RuleConfiguredTarget configuredTarget,
+ @Nullable NestedSet<Package> transitivePackagesForPackageRootResolution) {
+ this(configuredTarget, transitivePackagesForPackageRootResolution, false);
+ }
+
+ RuleConfiguredTargetValue(
+ RuleConfiguredTarget configuredTarget,
+ @Nullable NestedSet<Package> transitivePackagesForPackageRootResolution,
+ boolean removeActionsAfterEvaluation) {
+ super(removeActionsAfterEvaluation);
+ this.configuredTarget = Preconditions.checkNotNull(configuredTarget);
+ this.transitivePackagesForPackageRootResolution = transitivePackagesForPackageRootResolution;
+ // These are specifically *not* copied to save memory.
+ this.actions = configuredTarget.getActions();
+ this.generatingActionIndex = configuredTarget.getGeneratingActionIndex();
+ // If actions are removed after evaluation, the configured target's account of actions is
+ // incomplete and may be partially nulled-out. Thus, access of these actions via skylark should
+ // be disabled.
+ // TODO(b/70636031): Deprecate and remove this optimization.
+ if (removeActionsAfterEvaluation) {
+ configuredTarget.disableAcccesibleActions();
+ }
+ }
+
+ @VisibleForTesting
+ @Override
+ public ConfiguredTarget getConfiguredTarget() {
+ Preconditions.checkNotNull(configuredTarget);
+ return configuredTarget;
+ }
+
+ @VisibleForTesting
+ @Override
+ public ArrayList<ActionAnalysisMetadata> getActions() {
+ return actions;
+ }
+
+ @Override
+ protected ImmutableMap<Artifact, Integer> getGeneratingActionIndex() {
+ return generatingActionIndex;
+ }
+
+ @Override
+ public NestedSet<Package> getTransitivePackagesForPackageRootResolution() {
+ return Preconditions.checkNotNull(transitivePackagesForPackageRootResolution);
+ }
+
+ @Override
+ public void clear(boolean clearEverything) {
+ Preconditions.checkNotNull(configuredTarget);
+ Preconditions.checkNotNull(transitivePackagesForPackageRootResolution);
+ if (clearEverything) {
+ configuredTarget = null;
+ }
+ transitivePackagesForPackageRootResolution = null;
+ }
+}
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 8d9c151..5d9cde9 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
@@ -30,7 +30,6 @@
import com.google.devtools.build.lib.actions.ArtifactFactory;
import com.google.devtools.build.lib.actions.ArtifactOwner;
import com.google.devtools.build.lib.actions.ArtifactPrefixConflictException;
-import com.google.devtools.build.lib.actions.MutableActionGraph;
import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException;
import com.google.devtools.build.lib.actions.PackageRoots;
import com.google.devtools.build.lib.analysis.AnalysisFailureEvent;
@@ -270,7 +269,7 @@
ConflictException ex = bad.getValue();
try {
ex.rethrowTyped();
- } catch (MutableActionGraph.ActionConflictException ace) {
+ } catch (ActionConflictException ace) {
ace.reportTo(eventHandler);
String errorMsg = "Analysis of target '" + bad.getKey().getOwner().getLabel()
+ "' failed; build aborted";
@@ -294,7 +293,7 @@
if (topLevel.argument() instanceof ConfiguredTargetKey) {
errorMsg =
"Analysis of target '"
- + ConfiguredTargetValue.extractLabel(topLevel)
+ + NonRuleConfiguredTargetValue.extractLabel(topLevel)
+ "' failed; build aborted";
} else if (topLevel.argument() instanceof AspectValueKey) {
AspectValueKey aspectKey = (AspectValueKey) topLevel.argument();
@@ -313,7 +312,7 @@
}
boolean hasLoadingError = false;
- // --keep_going : We notify the error and return a ConfiguredTargetValue
+ // --keep_going : We notify the error and return a NonRuleConfiguredTargetValue
for (Map.Entry<SkyKey, ErrorInfo> errorEntry : result.errorMap().entrySet()) {
// Only handle errors of configured targets, not errors of top-level aspects.
// TODO(ulfjack): this is quadratic - if there are a lot of CTs, this could be rather slow.
@@ -363,7 +362,7 @@
ConflictException ex = bad.getValue();
try {
ex.rethrowTyped();
- } catch (MutableActionGraph.ActionConflictException ace) {
+ } catch (ActionConflictException ace) {
ace.reportTo(eventHandler);
eventHandler
.handle(Event.warn("errors encountered while analyzing target '"
@@ -508,7 +507,7 @@
OrderedSetMultimap<Attribute, ConfiguredTargetAndTarget> prerequisiteMap,
ImmutableMap<Label, ConfigMatchingProvider> configConditions,
@Nullable ToolchainContext toolchainContext)
- throws InterruptedException {
+ throws InterruptedException, ActionConflictException {
Preconditions.checkState(enableAnalysis,
"Already in execution phase %s %s", target, configuration);
Preconditions.checkNotNull(analysisEnvironment);
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceStatusValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceStatusValue.java
index 0bbff1c..0a748f9 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceStatusValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceStatusValue.java
@@ -13,8 +13,8 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
-import com.google.devtools.build.lib.actions.ActionLookupValue;
import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.actions.BasicActionLookupValue;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.skyframe.SkyFunctionName;
@@ -26,7 +26,7 @@
*/
// TODO(bazel-team): This seems to be superfluous now, but it cannot be removed without making
// PrecomputedValue public instead of package-private
-public class WorkspaceStatusValue extends ActionLookupValue {
+public class WorkspaceStatusValue extends BasicActionLookupValue {
private final Artifact stableArtifact;
private final Artifact volatileArtifact;