Skip to content

Commit

Permalink
Refactor ArtifactSkyKey to get rid of an unnecessary wrapper class: a…
Browse files Browse the repository at this point in the history
…ctually essentially promote OwnedArtifact to ArtifactSkyKey and rename it to ArtifactSkyKey. The king is dead...

Also add some other execution-phase codecs.

PiperOrigin-RevId: 184552706
  • Loading branch information
janakdr authored and Copybara-Service committed Feb 5, 2018
1 parent 6d03294 commit 5fd3ff9
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

import com.google.common.collect.ImmutableSortedSet;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;

import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.util.Objects;
import java.util.Set;

/**
* Contains options which control the set of artifacts to build for top-level targets.
*/
/** Contains options which control the set of artifacts to build for top-level targets. */
@Immutable
@AutoCodec
public final class TopLevelArtifactContext {
public static final ObjectCodec<TopLevelArtifactContext> CODEC =
new TopLevelArtifactContext_AutoCodec();

private final boolean runTestsExclusively;
private final ImmutableSortedSet<String> outputGroups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.devtools.build.lib.actions.ActionLookupData;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.pkgcache.PackageProvider;
import com.google.devtools.build.lib.skyframe.ArtifactSkyKey.OwnedArtifact;
import com.google.devtools.build.lib.skyframe.TargetCompletionValue.TargetCompletionKey;
import com.google.devtools.build.lib.skyframe.TestCompletionValue.TestCompletionKey;
import com.google.devtools.build.skyframe.CycleInfo;
Expand Down Expand Up @@ -48,8 +47,8 @@ protected String prettyPrint(SkyKey key) {
}

private String prettyPrint(SkyFunctionName skyFunctionName, Object arg) {
if (arg instanceof OwnedArtifact) {
return "file: " + ((OwnedArtifact) arg).getArtifact().getRootRelativePathString();
if (arg instanceof ArtifactSkyKey) {
return "file: " + ((ArtifactSkyKey) arg).getArtifact().getRootRelativePathString();
} else if (arg instanceof ActionLookupData) {
return "action from: " + arg;
} else if (arg instanceof TargetCompletionKey
Expand All @@ -60,14 +59,14 @@ private String prettyPrint(SkyFunctionName skyFunctionName, Object arg) {
return "test target: " + ((TestCompletionKey) arg).configuredTargetKey().getLabel();
}
throw new IllegalStateException(
"Argument is not Action, TargetCompletion, TestCompletion or OwnedArtifact: " + arg);
"Argument is not Action, TargetCompletion, TestCompletion or ArtifactSkyKey: " + arg);
}

@Override
protected Label getLabel(SkyKey key) {
Object arg = key.argument();
if (arg instanceof OwnedArtifact) {
return ((OwnedArtifact) arg).getArtifact().getOwner();
if (arg instanceof ArtifactSkyKey) {
return ((ArtifactSkyKey) arg).getArtifact().getOwner();
} else if (arg instanceof ActionLookupData) {
return ((ActionLookupData) arg).getLabelForErrors();
} else if (arg instanceof TargetCompletionKey
Expand All @@ -78,7 +77,7 @@ protected Label getLabel(SkyKey key) {
return ((TestCompletionKey) arg).configuredTargetKey().getLabel();
}
throw new IllegalStateException(
"Argument is not Action, TargetCompletion, TestCompletion or OwnedArtifact: " + arg);
"Argument is not Action, TargetCompletion, TestCompletion or ArtifactSkyKey: " + arg);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.skyframe.ArtifactSkyKey.OwnedArtifact;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.RootedPath;
Expand All @@ -54,11 +53,11 @@ class ArtifactFunction implements SkyFunction {
@Override
public SkyValue compute(SkyKey skyKey, Environment env)
throws ArtifactFunctionException, InterruptedException {
OwnedArtifact ownedArtifact = (OwnedArtifact) skyKey.argument();
Artifact artifact = ownedArtifact.getArtifact();
ArtifactSkyKey artifactSkyKey = (ArtifactSkyKey) skyKey.argument();
Artifact artifact = artifactSkyKey.getArtifact();
if (artifact.isSourceArtifact()) {
try {
return createSourceValue(artifact, ownedArtifact.isMandatory(), env);
return createSourceValue(artifact, artifactSkyKey.isMandatory(), env);
} catch (MissingInputFileException e) {
// The error is not necessarily truly transient, but we mark it as such because we have
// the above side effect of posting an event to the EventBus. Importantly, that event
Expand Down Expand Up @@ -306,7 +305,7 @@ private static boolean isAggregatingValue(ActionAnalysisMetadata action) {

@Override
public String extractTag(SkyKey skyKey) {
return Label.print(((OwnedArtifact) skyKey.argument()).getArtifact().getOwner());
return Label.print(((ArtifactSkyKey) skyKey.argument()).getArtifact().getOwner());
}

@VisibleForTesting
Expand Down
Loading

0 comments on commit 5fd3ff9

Please sign in to comment.