Search in sources :

Example 1 with BitbakeNode

use of com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeNode in project synopsys-detect by blackducksoftware.

the class BitbakeDependencyGraphTransformer method buildGraph.

@NotNull
private DependencyGraph buildGraph(BitbakeGraph bitbakeGraph, Map<String, Dependency> namesToExternalIds) {
    DependencyGraph dependencyGraph = new BasicDependencyGraph();
    for (BitbakeNode bitbakeNode : bitbakeGraph.getNodes()) {
        String name = bitbakeNode.getName();
        if (namesToExternalIds.containsKey(name)) {
            Dependency dependency = namesToExternalIds.get(bitbakeNode.getName());
            dependencyGraph.addChildToRoot(dependency);
            for (String child : bitbakeNode.getChildren()) {
                if (namesToExternalIds.containsKey(child)) {
                    Dependency childDependency = namesToExternalIds.get(child);
                    dependencyGraph.addParentWithChild(dependency, childDependency);
                }
            }
        }
    }
    return dependencyGraph;
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BitbakeNode(com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeNode) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with BitbakeNode

use of com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeNode in project synopsys-detect by blackducksoftware.

the class BitbakeDependencyGraphTransformer method generateExternalIds.

@NotNull
private Map<String, Dependency> generateExternalIds(BitbakeGraph bitbakeGraph, Map<String, List<String>> recipeLayerMap, Map<String, String> imageRecipes) {
    Map<String, Dependency> namesToExternalIds = new HashMap<>();
    for (BitbakeNode bitbakeNode : bitbakeGraph.getNodes()) {
        String name = bitbakeNode.getName();
        if (bitbakeNode.getVersion().isPresent()) {
            String version = bitbakeNode.getVersion().get();
            Optional<String> actualLayer = bitbakeNode.getLayer();
            if (dependencyTypeFilter.shouldInclude(BitbakeDependencyType.BUILD) || !isBuildDependency(imageRecipes, name, version)) {
                Optional<Dependency> dependency = generateExternalId(name, version, actualLayer.orElse(null), recipeLayerMap).map(Dependency::new);
                dependency.ifPresent(value -> namesToExternalIds.put(bitbakeNode.getName(), value));
            } else {
                logger.debug("Excluding BUILD dependency: {}:{}", name, version);
            }
        } else if (name.startsWith(VIRTUAL_PREFIX)) {
            logger.debug("Virtual component '{}' found. Excluding from graph.", name);
        } else {
            logger.debug("No version found for component '{}'. It is likely not a real component.", name);
        }
    }
    return namesToExternalIds;
}
Also used : HashMap(java.util.HashMap) BitbakeNode(com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeNode) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)2 BitbakeNode (com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeNode)2 NotNull (org.jetbrains.annotations.NotNull)2 BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)1 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 HashMap (java.util.HashMap)1