aboutsummaryrefslogtreecommitdiffhomepage
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
parentf83f70ed3921b5ed347f063b593eae36f6d950f3 (diff)
Migrate ActionOwner to @AutoValue.
-- MOS_MIGRATED_REVID=138680612
-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
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java6
5 files changed, 29 insertions, 45 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(),
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
index fed3d9d05c..53b83c682e 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
@@ -189,7 +189,7 @@ public final class ActionsTestUtil {
Root.asSourceRoot(new InMemoryFileSystem().getRootDirectory()));
public static final ActionOwner NULL_ACTION_OWNER =
- new ActionOwner(
+ ActionOwner.create(
NULL_LABEL, null, "dummy-configuration-mnemonic", null, "dummy-configuration", null);
public static final ArtifactOwner NULL_ARTIFACT_OWNER =
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
index a0f41d523d..5594a32734 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
@@ -390,7 +390,7 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase {
"/home/user/bazel/out/abcdef/some/very/very/long/path/for/some/library/directory/foo.jar");
Label label =
Label.parseAbsolute("//some/very/very/long/path/for/some/library/directory:libfoo");
- ActionOwner owner = new ActionOwner(label, null, null, null, "fedcba", null);
+ ActionOwner owner = ActionOwner.create(label, null, null, null, "fedcba", null);
when(action.getOwner()).thenReturn(owner);
clock.advanceMillis(TimeUnit.SECONDS.toMillis(3));
@@ -517,7 +517,7 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase {
Label labelFooTest = Label.parseAbsolute("//foo/bar:footest");
ConfiguredTarget targetFooTest = Mockito.mock(ConfiguredTarget.class);
when(targetFooTest.getLabel()).thenReturn(labelFooTest);
- ActionOwner fooOwner = new ActionOwner(labelFooTest, null, null, null, "abcdef", null);
+ ActionOwner fooOwner = ActionOwner.create(labelFooTest, null, null, null, "abcdef", null);
Label labelBarTest = Label.parseAbsolute("//baz:bartest");
ConfiguredTarget targetBarTest = Mockito.mock(ConfiguredTarget.class);
@@ -525,7 +525,7 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase {
TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class);
when(filteringComplete.getTestTargets())
.thenReturn(ImmutableSet.of(targetFooTest, targetBarTest));
- ActionOwner barOwner = new ActionOwner(labelBarTest, null, null, null, "fedcba", null);
+ ActionOwner barOwner = ActionOwner.create(labelBarTest, null, null, null, "fedcba", null);
stateTracker.testFilteringComplete(filteringComplete);