aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2018-08-02 11:49:08 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-02 11:50:28 -0700
commit04e9281ad2353ffa75f05c3e67c55d6fa2130a1c (patch)
treea0d1a11b9e3b5cdfb776029fa9795cdb0f22c643 /src/main/java/com/google/devtools/build/lib/analysis
parentd1a203bbdd2033ec8049b39242189e1cc76a9e8e (diff)
Thread a path resolver through target/aspect complete event.
At the moment, an identity path resolver is passed. This will later be replaced by a contextual path resolver. RELNOTES: None PiperOrigin-RevId: 207138772
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/AspectCompleteEvent.java21
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java48
2 files changed, 46 insertions, 23 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AspectCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/AspectCompleteEvent.java
index 6cd519fd3a..f7d0b70733 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/AspectCompleteEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/AspectCompleteEvent.java
@@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.actions.ArtifactPathResolver;
import com.google.devtools.build.lib.actions.EventReportingArtifacts;
import com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup;
import com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsToBuild;
@@ -43,10 +44,14 @@ public class AspectCompleteEvent
private final AspectValue aspectValue;
private final NestedSet<Cause> rootCauses;
private final Collection<BuildEventId> postedAfter;
+ private final ArtifactPathResolver pathResolver;
private final ArtifactsToBuild artifacts;
private AspectCompleteEvent(
- AspectValue aspectValue, NestedSet<Cause> rootCauses, ArtifactsToBuild artifacts) {
+ AspectValue aspectValue,
+ NestedSet<Cause> rootCauses,
+ ArtifactPathResolver pathResolver,
+ ArtifactsToBuild artifacts) {
this.aspectValue = aspectValue;
this.rootCauses =
(rootCauses == null) ? NestedSetBuilder.<Cause>emptySet(Order.STABLE_ORDER) : rootCauses;
@@ -55,13 +60,14 @@ public class AspectCompleteEvent
postedAfterBuilder.add(BuildEventId.fromCause(cause));
}
this.postedAfter = postedAfterBuilder.build();
+ this.pathResolver = pathResolver;
this.artifacts = artifacts;
}
/** Construct a successful target completion event. */
public static AspectCompleteEvent createSuccessful(
- AspectValue value, ArtifactsToBuild artifacts) {
- return new AspectCompleteEvent(value, null, artifacts);
+ AspectValue value, ArtifactPathResolver pathResolver, ArtifactsToBuild artifacts) {
+ return new AspectCompleteEvent(value, null, pathResolver, artifacts);
}
/**
@@ -69,7 +75,7 @@ public class AspectCompleteEvent
*/
public static AspectCompleteEvent createFailed(AspectValue value, NestedSet<Cause> rootCauses) {
Preconditions.checkArgument(!Iterables.isEmpty(rootCauses));
- return new AspectCompleteEvent(value, rootCauses, null);
+ return new AspectCompleteEvent(value, rootCauses, ArtifactPathResolver.IDENTITY, null);
}
/**
@@ -108,15 +114,14 @@ public class AspectCompleteEvent
}
@Override
- public Collection<NestedSet<Artifact>> reportedArtifacts() {
- ImmutableSet.Builder<NestedSet<Artifact>> builder =
- new ImmutableSet.Builder<NestedSet<Artifact>>();
+ public ReportedArtifacts reportedArtifacts() {
+ ImmutableSet.Builder<NestedSet<Artifact>> builder = ImmutableSet.builder();
if (artifacts != null) {
for (ArtifactsInOutputGroup artifactsInGroup : artifacts.getAllArtifactsByOutputGroup()) {
builder.add(artifactsInGroup.getArtifacts());
}
}
- return builder.build();
+ return new ReportedArtifacts(builder.build(), pathResolver);
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
index 53a3f16e7e..e1dfa5e5f7 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.actions.ArtifactPathResolver;
import com.google.devtools.build.lib.actions.EventReportingArtifacts;
import com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -101,6 +102,7 @@ public final class TargetCompleteEvent
private final ConfiguredTargetKey configuredTargetKey;
private final NestedSet<Cause> rootCauses;
private final ImmutableList<BuildEventId> postedAfter;
+ private final ArtifactPathResolver pathResolver;
private final NestedSet<ArtifactsInOutputGroup> outputs;
private final NestedSet<Artifact> baselineCoverageArtifacts;
private final Label aliasLabel;
@@ -115,6 +117,7 @@ public final class TargetCompleteEvent
private TargetCompleteEvent(
ConfiguredTargetAndData targetAndData,
NestedSet<Cause> rootCauses,
+ ArtifactPathResolver pathResolver,
NestedSet<ArtifactsInOutputGroup> outputs,
boolean isTest) {
this.rootCauses =
@@ -136,6 +139,7 @@ public final class TargetCompleteEvent
postedAfterBuilder.add(BuildEventId.fromCause(cause));
}
this.postedAfter = postedAfterBuilder.build();
+ this.pathResolver = pathResolver;
this.outputs = outputs;
this.isTest = isTest;
this.testTimeoutSeconds = isTest ? getTestTimeoutSeconds(targetAndData) : null;
@@ -175,14 +179,18 @@ public final class TargetCompleteEvent
/** Construct a successful target completion event. */
public static TargetCompleteEvent successfulBuild(
- ConfiguredTargetAndData ct, NestedSet<ArtifactsInOutputGroup> outputs) {
- return new TargetCompleteEvent(ct, null, outputs, false);
+ ConfiguredTargetAndData ct,
+ ArtifactPathResolver pathResolver,
+ NestedSet<ArtifactsInOutputGroup> outputs) {
+ return new TargetCompleteEvent(ct, null, pathResolver, outputs, false);
}
/** Construct a successful target completion event for a target that will be tested. */
public static TargetCompleteEvent successfulBuildSchedulingTest(
- ConfiguredTargetAndData ct, NestedSet<ArtifactsInOutputGroup> outputs) {
- return new TargetCompleteEvent(ct, null, outputs, true);
+ ConfiguredTargetAndData ct,
+ ArtifactPathResolver pathResolver,
+ NestedSet<ArtifactsInOutputGroup> outputs) {
+ return new TargetCompleteEvent(ct, null, pathResolver, outputs, true);
}
/**
@@ -192,7 +200,11 @@ public final class TargetCompleteEvent
ConfiguredTargetAndData ct, NestedSet<Cause> rootCauses) {
Preconditions.checkArgument(!Iterables.isEmpty(rootCauses));
return new TargetCompleteEvent(
- ct, rootCauses, NestedSetBuilder.emptySet(Order.STABLE_ORDER), false);
+ ct,
+ rootCauses,
+ ArtifactPathResolver.IDENTITY,
+ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
+ false);
}
/** Returns the label of the target associated with the event. */
@@ -260,20 +272,23 @@ public final class TargetCompleteEvent
// TODO(aehlig): remove as soon as we managed to get rid of the deprecated "important_output"
// field.
private static void addImportantOutputs(
+ ArtifactPathResolver pathResolver,
BuildEventStreamProtos.TargetComplete.Builder builder,
BuildEventContext converters,
Iterable<Artifact> artifacts) {
- addImportantOutputs(builder, Artifact::getRootRelativePathString, converters, artifacts);
+ addImportantOutputs(
+ pathResolver, builder, Artifact::getRootRelativePathString, converters, artifacts);
}
private static void addImportantOutputs(
+ ArtifactPathResolver pathResolver,
BuildEventStreamProtos.TargetComplete.Builder builder,
Function<Artifact, String> artifactNameFunction,
BuildEventContext converters,
Iterable<Artifact> artifacts) {
for (Artifact artifact : artifacts) {
String name = artifactNameFunction.apply(artifact);
- String uri = converters.pathConverter().apply(artifact.getPath());
+ String uri = converters.pathConverter().apply(pathResolver.toPath(artifact));
if (uri != null) {
builder.addImportantOutput(File.newBuilder().setName(name).setUri(uri).build());
}
@@ -288,7 +303,7 @@ public final class TargetCompleteEvent
for (Artifact artifact : group.getArtifacts()) {
builder.add(
new LocalFile(
- artifact.getPath(),
+ pathResolver.toPath(artifact),
artifact.isSourceArtifact() ? LocalFileType.SOURCE : LocalFileType.OUTPUT));
}
}
@@ -297,7 +312,7 @@ public final class TargetCompleteEvent
for (Artifact artifact : baselineCoverageArtifacts) {
builder.add(
new LocalFile(
- artifact.getPath(),
+ pathResolver.toPath(artifact),
artifact.isSourceArtifact() ? LocalFileType.SOURCE : LocalFileType.OUTPUT));
}
}
@@ -320,10 +335,14 @@ public final class TargetCompleteEvent
// TODO(aehlig): remove direct reporting of artifacts as soon as clients no longer
// need it.
if (converters.getOptions().legacyImportantOutputs) {
- addImportantOutputs(builder, converters, getLegacyFilteredImportantArtifacts());
+ addImportantOutputs(pathResolver, builder, converters, getLegacyFilteredImportantArtifacts());
if (baselineCoverageArtifacts != null) {
addImportantOutputs(
- builder, (artifact -> BASELINE_COVERAGE), converters, baselineCoverageArtifacts);
+ pathResolver,
+ builder,
+ (artifact -> BASELINE_COVERAGE),
+ converters,
+ baselineCoverageArtifacts);
}
}
@@ -337,16 +356,15 @@ public final class TargetCompleteEvent
}
@Override
- public Collection<NestedSet<Artifact>> reportedArtifacts() {
- ImmutableSet.Builder<NestedSet<Artifact>> builder =
- new ImmutableSet.Builder<NestedSet<Artifact>>();
+ public ReportedArtifacts reportedArtifacts() {
+ ImmutableSet.Builder<NestedSet<Artifact>> builder = ImmutableSet.builder();
for (ArtifactsInOutputGroup artifactsInGroup : outputs) {
builder.add(artifactsInGroup.getArtifacts());
}
if (baselineCoverageArtifacts != null) {
builder.add(baselineCoverageArtifacts);
}
- return builder.build();
+ return new ReportedArtifacts(builder.build(), pathResolver);
}
@Override