Search in sources :

Example 1 with ArtifactsInOutputGroup

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();
}
Also used : ArtifactsInOutputGroup(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup) OutputGroup(com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.OutputGroup) ArtifactsInOutputGroup(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup) File(com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.File) Artifact(com.google.devtools.build.lib.actions.Artifact)

Example 2 with ArtifactsInOutputGroup

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()));
        }
    }
}
Also used : ArtifactsInOutputGroup(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup) TopLevelArtifactHelper.getAllArtifactsToBuild(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.getAllArtifactsToBuild) ArtifactsToBuild(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsToBuild) Test(org.junit.Test)

Example 3 with ArtifactsInOutputGroup

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();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ArtifactsInOutputGroup(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup) OutputGroup(com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.OutputGroup) ArtifactsInOutputGroup(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup) File(com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.File) Artifact(com.google.devtools.build.lib.actions.Artifact)

Example 4 with ArtifactsInOutputGroup

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());
}
Also used : ArtifactsInOutputGroup(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup) TopLevelArtifactHelper.getAllArtifactsToBuild(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.getAllArtifactsToBuild) ArtifactsToBuild(com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsToBuild) Test(org.junit.Test)

Aggregations

ArtifactsInOutputGroup (com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsInOutputGroup)4 Artifact (com.google.devtools.build.lib.actions.Artifact)2 ArtifactsToBuild (com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.ArtifactsToBuild)2 TopLevelArtifactHelper.getAllArtifactsToBuild (com.google.devtools.build.lib.analysis.TopLevelArtifactHelper.getAllArtifactsToBuild)2 File (com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.File)2 OutputGroup (com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.OutputGroup)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1