use of com.google.devtools.build.lib.actions.extra.CppLinkInfo in project bazel by bazelbuild.
the class CcLibraryConfiguredTargetTest method testCppLinkActionExtraActionInfoWithSharedLibraries.
@Test
public void testCppLinkActionExtraActionInfoWithSharedLibraries() throws Exception {
useConfiguration("--cpu=k8");
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());
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().getRawLinkArgv());
}
use of com.google.devtools.build.lib.actions.extra.CppLinkInfo in project bazel by bazelbuild.
the class CcLibraryConfiguredTargetTest method testCppLinkActionExtraActionInfoWithoutSharedLibraries.
@Test
public void testCppLinkActionExtraActionInfoWithoutSharedLibraries() throws Exception {
useConfiguration("--nointerface_shared_objects");
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
Artifact sharedObject = getOnlyElement(FileType.filter(getFilesToBuild(hello), CppFileTypes.SHARED_LIBRARY));
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());
assertFalse(cppLinkInfo.hasInterfaceOutputFile());
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().getRawLinkArgv());
}
Aggregations