@Test
  public void testCppLinkActionExtraActionInfoWithSharedLibraries() throws Exception {
    ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
    Artifact sharedObject =
        FileType.filter(getFilesToBuild(hello), CppFileTypes.SHARED_LIBRARY).iterator().next();
    CppLinkAction action = (CppLinkAction) getGeneratingAction(sharedObject);

    ExtraActionInfo.Builder builder = action.getExtraActionInfo();
    ExtraActionInfo info = builder.build();
    assertEquals("CppLink", info.getMnemonic());

    CppLinkInfo cppLinkInfo = info.getExtension(CppLinkInfo.cppLinkInfo);
    assertNotNull(cppLinkInfo);

    Iterable<String> inputs =
        Artifact.asExecPaths(
            LinkerInputs.toLibraryArtifacts(action.getLinkCommandLine().getLinkerInputs()));
    assertThat(cppLinkInfo.getInputFileList()).containsExactlyElementsIn(inputs);
    assertEquals(action.getPrimaryOutput().getExecPathString(), cppLinkInfo.getOutputFile());
    Artifact interfaceOutput = action.getLinkCommandLine().getInterfaceOutput();
    assertEquals(interfaceOutput.getExecPathString(), cppLinkInfo.getInterfaceOutputFile());
    assertEquals(
        action.getLinkCommandLine().getLinkTargetType().name(), cppLinkInfo.getLinkTargetType());
    assertEquals(
        action.getLinkCommandLine().getLinkStaticness().name(), cppLinkInfo.getLinkStaticness());
    Iterable<String> linkstamps =
        Artifact.asExecPaths(action.getLinkCommandLine().getLinkstamps().values());
    assertThat(cppLinkInfo.getLinkStampList()).containsExactlyElementsIn(linkstamps);
    Iterable<String> buildInfoHeaderArtifacts =
        Artifact.asExecPaths(action.getLinkCommandLine().getBuildInfoHeaderArtifacts());
    assertThat(cppLinkInfo.getBuildInfoHeaderArtifactList())
        .containsExactlyElementsIn(buildInfoHeaderArtifacts);
    assertThat(cppLinkInfo.getLinkOptList())
        .containsExactlyElementsIn(action.getLinkCommandLine().getLinkopts());
  }
Exemple #2
0
 @Override
 public ExtraActionInfo.Builder getExtraActionInfo() {
   return ExtraActionInfo.newBuilder()
       .setOwner(getOwner().getLabel().toString())
       .setId(getKey())
       .setMnemonic(getMnemonic());
 }