aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java88
1 files changed, 61 insertions, 27 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java b/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
index b82b02505a..b0b163e396 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java
@@ -15,52 +15,86 @@ package com.google.devtools.build.lib.actions;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.Location;
+import com.google.devtools.build.lib.util.Preconditions;
+
+import javax.annotation.Nullable;
/**
- * The owner of an action is responsible for reporting conflicts in the action
- * graph (two actions attempting to generate the same artifact).
+ * Contains metadata used for reporting the progress and status of an action.
*
- * Typically an action's owner is the RuleConfiguredTarget instance responsible
- * for creating it, but to avoid coupling between the view and actions
- * packages, the RuleConfiguredTarget is hidden behind this interface, which
- * exposes only the error reporting functionality.
+ * <p>Morally an action's owner is the RuleConfiguredTarget instance responsible for creating it,
+ * but to avoid storing heavyweight analysis objects in actions, and to avoid coupling between the
+ * analysis and actions packages, the RuleConfiguredTarget provides an instance of this class.
*/
-public interface ActionOwner {
+public final class ActionOwner {
+ /** An action owner for special cases. Usage is strongly discouraged. */
+ public static final ActionOwner SYSTEM_ACTION_OWNER =
+ new ActionOwner(null, null, "system", "empty target kind", "system", null);
- /**
- * Returns the location of this ActionOwner, if any; null otherwise.
- */
- Location getLocation();
+ @Nullable private final Label label;
+ @Nullable private final Location location;
+ @Nullable private final String mnemonic;
+ @Nullable private final String targetKind;
+ private final String configurationChecksum;
+ @Nullable private final String additionalProgressInfo;
+
+ public ActionOwner(
+ @Nullable Label label,
+ @Nullable Location location,
+ @Nullable String mnemonic,
+ @Nullable String targetKind,
+ String configurationChecksum,
+ @Nullable String additionalProgressInfo) {
+ this.label = label;
+ this.location = location;
+ this.mnemonic = mnemonic;
+ this.targetKind = targetKind;
+ this.configurationChecksum = Preconditions.checkNotNull(configurationChecksum);
+ this.additionalProgressInfo = additionalProgressInfo;
+ }
+
+ /** Returns the location of this ActionOwner, if any; null otherwise. */
+ @Nullable
+ public Location getLocation() {
+ return location;
+ }
/**
* Returns the label for this ActionOwner, if any; null otherwise.
*/
- Label getLabel();
+ @Nullable
+ public Label getLabel() {
+ return label;
+ }
- /**
- * Returns the configuration's mnemonic.
- */
- String getConfigurationMnemonic();
+ /** Returns the configuration's mnemonic. */
+ @Nullable
+ public String getConfigurationMnemonic() {
+ return mnemonic;
+ }
/**
* Returns the short cache key for the configuration of the action owner.
*
- * <p>Special action owners that are not targets can return any string here as long as it is
- * constant. If the configuration is null, this should return "null".
- *
- * <p>These requirements exist so that {@link ActionOwner} instances are consistent with
- * {@code BuildView.ActionOwnerIdentity(ConfiguredTargetValue)}.
+ * <p>Special action owners that are not targets can return any string here. If the
+ * underlying configuration is null, this should return "null".
*/
- String getConfigurationChecksum();
+ public String getConfigurationChecksum() {
+ return configurationChecksum;
+ }
- /**
- * Returns the target kind (rule class name) for this ActionOwner, if any; null otherwise.
- */
- String getTargetKind();
+ /** Returns the target kind (rule class name) for this ActionOwner, if any; null otherwise. */
+ @Nullable
+ public String getTargetKind() {
+ return targetKind;
+ }
/**
* Returns additional information that should be displayed in progress messages, or {@code null}
* if nothing should be added.
*/
- String getAdditionalProgressInfo();
+ @Nullable
+ String getAdditionalProgressInfo() {
+ return additionalProgressInfo;
+ }
}