aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar Carmi Grushko <carmi@google.com>2016-11-09 21:51:27 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-11-10 09:21:53 +0000
commit4665e709054dcfe34d1e246caefb8847a560e22a (patch)
tree7166c1f550c6b299f314f2d4cc366ca7381431f1 /src/main/java/com/google/devtools/build/lib
parentf83f70ed3921b5ed347f063b593eae36f6d950f3 (diff)
Migrate ActionOwner to @AutoValue.
-- MOS_MIGRATED_REVID=138680612
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java63
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/BUILD1
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java2
3 files changed, 25 insertions, 41 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 82e67978e0..a7a4aa7bb3 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
@@ -13,11 +13,11 @@
// limitations under the License.
package com.google.devtools.build.lib.actions;
+import com.google.auto.value.AutoValue;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.util.Preconditions;
-
import javax.annotation.Nullable;
/**
@@ -27,76 +27,59 @@ import javax.annotation.Nullable;
* 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.
*/
+@AutoValue
@Immutable
-public final class ActionOwner {
+public abstract 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);
-
- @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;
+ ActionOwner.create(null, null, "system", "empty target kind", "system", null);
- public ActionOwner(
+ public static ActionOwner create(
@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;
+ return new AutoValue_ActionOwner(
+ location,
+ label,
+ mnemonic,
+ Preconditions.checkNotNull(configurationChecksum),
+ targetKind,
+ additionalProgressInfo);
}
/** Returns the location of this ActionOwner, if any; null otherwise. */
@Nullable
- public Location getLocation() {
- return location;
- }
+ public abstract Location getLocation();
- /**
- * Returns the label for this ActionOwner, if any; null otherwise.
- */
+ /** Returns the label for this ActionOwner, if any; null otherwise. */
@Nullable
- public Label getLabel() {
- return label;
- }
+ public abstract Label getLabel();
/** Returns the configuration's mnemonic. */
@Nullable
- public String getConfigurationMnemonic() {
- return mnemonic;
- }
+ public abstract String getConfigurationMnemonic();
/**
* 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. If the
- * underlying configuration is null, this should return "null".
+ * <p>Special action owners that are not targets can return any string here. If the underlying
+ * configuration is null, this should return "null".
*/
- public String getConfigurationChecksum() {
- return configurationChecksum;
- }
+ public abstract String getConfigurationChecksum();
/** Returns the target kind (rule class name) for this ActionOwner, if any; null otherwise. */
@Nullable
- public String getTargetKind() {
- return targetKind;
- }
+ public abstract String getTargetKind();
/**
* Returns additional information that should be displayed in progress messages, or {@code null}
* if nothing should be added.
*/
@Nullable
- String getAdditionalProgressInfo() {
- return additionalProgressInfo;
- }
+ abstract String getAdditionalProgressInfo();
+
+ ActionOwner() {}
}
diff --git a/src/main/java/com/google/devtools/build/lib/actions/BUILD b/src/main/java/com/google/devtools/build/lib/actions/BUILD
index ca91797c12..a81c65070d 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/actions/BUILD
@@ -27,6 +27,7 @@ java_library(
"//src/main/java/com/google/devtools/build/skyframe",
"//src/main/java/com/google/devtools/common/options",
"//src/main/protobuf:extra_actions_base_java_proto",
+ "//third_party:auto_value",
"//third_party:guava",
"//third_party:jsr305",
"//third_party/protobuf",
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
index ecb2e89dd3..8f186d4cfa 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
@@ -399,7 +399,7 @@ public final class RuleContext extends TargetContext
@VisibleForTesting
public static ActionOwner createActionOwner(Rule rule, BuildConfiguration configuration) {
- return new ActionOwner(
+ return ActionOwner.create(
rule.getLabel(),
rule.getLocation(),
configuration.getMnemonic(),