use of com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup in project bazel by bazelbuild.
the class AspectCompleteEvent method asStreamProto.
@Override
public BuildEventStreamProtos.BuildEvent asStreamProto(PathConverter pathConverter) {
BuildEventStreamProtos.TargetComplete.Builder builder = BuildEventStreamProtos.TargetComplete.newBuilder();
builder.setSuccess(!failed());
if (artifacts != null) {
for (ArtifactsInOutputGroup artifactsInGroup : artifacts.getAllArtifactsByOutputGroup()) {
OutputGroup.Builder groupBuilder = OutputGroup.newBuilder();
groupBuilder.setName(artifactsInGroup.getOutputGroup());
File.Builder fileBuilder = File.newBuilder();
for (Artifact artifact : artifactsInGroup.getArtifacts()) {
String name = artifact.getFilename();
String uri = pathConverter.apply(artifact.getPath());
groupBuilder.addOutputFile(fileBuilder.setName(name).setUri(uri).build());
}
builder.addOutputGroup(groupBuilder.build());
}
}
return GenericBuildEvent.protoChaining(this).setCompleted(builder.build()).build();
}
use of com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup in project bazel by bazelbuild.
the class TopLevelArtifactHelperTest method artifactsShouldBeSeparateByGroup.
@Test
public void artifactsShouldBeSeparateByGroup() {
setup(asList(Pair.of("foo", 3), Pair.of("bar", 2)));
ArtifactsToBuild allArtifacts = getAllArtifactsToBuild(groupProvider, null, ctx);
assertEquals(5, size(allArtifacts.getAllArtifacts()));
assertEquals(5, size(allArtifacts.getImportantArtifacts()));
NestedSet<ArtifactsInOutputGroup> artifactsByGroup = allArtifacts.getAllArtifactsByOutputGroup();
// Two groups
assertEquals(2, size(artifactsByGroup));
for (ArtifactsInOutputGroup artifacts : artifactsByGroup) {
String outputGroup = artifacts.getOutputGroup();
if ("foo".equals(outputGroup)) {
assertEquals(3, size(artifacts.getArtifacts()));
} else if ("bar".equals(outputGroup)) {
assertEquals(2, size(artifacts.getArtifacts()));
}
}
}
use of com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup in project bazel by bazelbuild.
the class TargetCompleteEvent method getOutputFilesByGroup.
private Iterable<OutputGroup> getOutputFilesByGroup(PathConverter pathConverter) {
ImmutableList.Builder<OutputGroup> groups = ImmutableList.builder();
for (ArtifactsInOutputGroup artifactsInOutputGroup : outputs) {
OutputGroup.Builder groupBuilder = OutputGroup.newBuilder();
groupBuilder.setName(artifactsInOutputGroup.getOutputGroup());
File.Builder fileBuilder = File.newBuilder();
for (Artifact artifact : artifactsInOutputGroup.getArtifacts()) {
String name = artifact.getFilename();
String uri = pathConverter.apply(artifact.getPath());
groupBuilder.addOutputFile(fileBuilder.setName(name).setUri(uri).build());
}
groups.add(groupBuilder.build());
}
return groups.build();
}
use of com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup in project bazel by bazelbuild.
the class TopLevelArtifactHelperTest method emptyGroupsShouldBeIgnored.
@Test
public void emptyGroupsShouldBeIgnored() {
setup(asList(Pair.of("foo", 1), Pair.of("bar", 0)));
ArtifactsToBuild allArtifacts = getAllArtifactsToBuild(groupProvider, null, ctx);
assertEquals(1, size(allArtifacts.getAllArtifacts()));
assertEquals(1, size(allArtifacts.getImportantArtifacts()));
NestedSet<ArtifactsInOutputGroup> artifactsByGroup = allArtifacts.getAllArtifactsByOutputGroup();
// The bar list should not appear here, as it contains no artifacts.
assertEquals(1, size(artifactsByGroup));
assertEquals("foo", artifactsByGroup.toList().get(0).getOutputGroup());
}
Aggregations