@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()); }
private void setDeserializedArtifactOwners() throws ViewCreationFailedException { Map<PathFragment, Artifact> deserializedArtifactMap = artifactFactory.getDeserializedArtifacts(); Set<Artifact> deserializedArtifacts = new HashSet<>(); for (Artifact artifact : deserializedArtifactMap.values()) { if (!artifact.getExecPath().getBaseName().endsWith(".gcda")) { // gcda files are classified as generated artifacts, but are not actually generated. All // others need owners. deserializedArtifacts.add(artifact); } } if (deserializedArtifacts.isEmpty()) { // If there are no deserialized artifacts to process, don't pay the price of iterating over // the graph. return; } for (Map.Entry<SkyKey, ActionLookupValue> entry : skyframeExecutor.getActionLookupValueMap().entrySet()) { for (Action action : entry.getValue().getActionsForFindingArtifactOwners()) { for (Artifact output : action.getOutputs()) { Artifact deserializedArtifact = deserializedArtifactMap.get(output.getExecPath()); if (deserializedArtifact != null) { deserializedArtifact.setArtifactOwner((ActionLookupKey) entry.getKey().argument()); deserializedArtifacts.remove(deserializedArtifact); } } } } if (!deserializedArtifacts.isEmpty()) { throw new ViewCreationFailedException( "These artifacts were read in from the FDO profile but" + " have no generating action that could be found. If you are confident that your profile was" + " collected from the same source state at which you're building, please report this:\n" + Artifact.asExecPaths(deserializedArtifacts)); } artifactFactory.clearDeserializedArtifacts(); }