Search in sources :

Example 1 with ShowRecipesResults

use of com.synopsys.integration.detectable.detectables.bitbake.data.ShowRecipesResults in project synopsys-detect by blackducksoftware.

the class BitbakeRecipesParserTest method test.

@Test
void test() {
    BitbakeRecipesParser parser = new BitbakeRecipesParser();
    ShowRecipesResults results = parser.parseShowRecipes(showRecipesOutputLines);
    assertEquals(3, results.getLayerNames().size());
    assertTrue(results.getLayerNames().contains("meta"));
    assertEquals(4, results.getRecipesWithLayers().size());
    assertTrue(results.getRecipesWithLayers().containsKey("adcli"));
}
Also used : BitbakeRecipesParser(com.synopsys.integration.detectable.detectables.bitbake.parse.BitbakeRecipesParser) ShowRecipesResults(com.synopsys.integration.detectable.detectables.bitbake.data.ShowRecipesResults) Test(org.junit.jupiter.api.Test)

Example 2 with ShowRecipesResults

use of com.synopsys.integration.detectable.detectables.bitbake.data.ShowRecipesResults in project synopsys-detect by blackducksoftware.

the class BitbakeRecipesParser method parseShowRecipes.

/**
 * @param showRecipeLines is the executable output.
 * @return Recipe names mapped to a recipe's the layer names.
 */
public ShowRecipesResults parseShowRecipes(List<String> showRecipeLines) {
    Map<String, List<String>> bitbakeRecipes = new HashMap<>();
    Set<String> layerNames = new HashSet<>();
    boolean started = false;
    BitbakeRecipe currentRecipe = null;
    for (String line : showRecipeLines) {
        if (StringUtils.isBlank(line)) {
            continue;
        }
        if (!started && line.trim().startsWith("=== Available recipes: ===")) {
            started = true;
        } else if (started) {
            currentRecipe = parseLine(line, currentRecipe, bitbakeRecipes, layerNames);
        }
    }
    finishCurrentRecipe(bitbakeRecipes, layerNames, currentRecipe);
    return new ShowRecipesResults(layerNames, bitbakeRecipes);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ShowRecipesResults(com.synopsys.integration.detectable.detectables.bitbake.data.ShowRecipesResults) BitbakeRecipe(com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeRecipe) HashSet(java.util.HashSet)

Example 3 with ShowRecipesResults

use of com.synopsys.integration.detectable.detectables.bitbake.data.ShowRecipesResults in project synopsys-detect by blackducksoftware.

the class BitbakeExtractor method extract.

public Extraction extract(File sourceDirectory, ExecutableTarget bashExecutable, File buildEnvironmentFile) throws ExecutableFailedException, IOException {
    toolVersionLogger.log(() -> bitbakeCommandRunner.runBitbakeVersion(sourceDirectory, bashExecutable, buildEnvironmentFile));
    File buildDirectory = determineBuildDirectory(sourceDirectory, bashExecutable, buildEnvironmentFile);
    BitbakeEnvironment bitbakeEnvironment = executeBitbakeForEnvironment(sourceDirectory, bashExecutable, buildEnvironmentFile);
    ShowRecipesResults showRecipesResults = executeBitbakeForRecipeLayerCatalog(sourceDirectory, bashExecutable, buildEnvironmentFile);
    List<CodeLocation> codeLocations = packageNames.stream().map(targetPackage -> generateCodeLocationForTargetPackage(targetPackage, sourceDirectory, bashExecutable, buildEnvironmentFile, buildDirectory, showRecipesResults, bitbakeEnvironment)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
    if (codeLocations.isEmpty()) {
        return Extraction.failure("No Code Locations were generated during extraction");
    } else {
        return Extraction.success(codeLocations);
    }
}
Also used : BitbakeEnvironment(com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeEnvironment) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) IntegrationException(com.synopsys.integration.exception.IntegrationException) Extraction(com.synopsys.integration.detectable.extraction.Extraction) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) BitbakeDependencyGraphTransformer(com.synopsys.integration.detectable.detectables.bitbake.transform.BitbakeDependencyGraphTransformer) ToolVersionLogger(com.synopsys.integration.detectable.util.ToolVersionLogger) ExecutableTarget(com.synopsys.integration.detectable.ExecutableTarget) PwdOutputParser(com.synopsys.integration.detectable.detectables.bitbake.parse.PwdOutputParser) Charset(java.nio.charset.Charset) Map(java.util.Map) ExecutableFailedException(com.synopsys.integration.detectable.detectable.executable.ExecutableFailedException) BitbakeGraph(com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph) Logger(org.slf4j.Logger) EnumListFilter(com.synopsys.integration.detectable.detectable.util.EnumListFilter) BitbakeGraphTransformer(com.synopsys.integration.detectable.detectables.bitbake.transform.BitbakeGraphTransformer) GraphParser(com.paypal.digraph.parser.GraphParser) BuildFileFinder(com.synopsys.integration.detectable.detectables.bitbake.collect.BuildFileFinder) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) BitbakeEnvironmentParser(com.synopsys.integration.detectable.detectables.bitbake.parse.BitbakeEnvironmentParser) BitbakeEnvironment(com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeEnvironment) BitbakeCommandRunner(com.synopsys.integration.detectable.detectables.bitbake.collect.BitbakeCommandRunner) List(java.util.List) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) ShowRecipesResults(com.synopsys.integration.detectable.detectables.bitbake.data.ShowRecipesResults) Optional(java.util.Optional) BitbakeRecipesParser(com.synopsys.integration.detectable.detectables.bitbake.parse.BitbakeRecipesParser) LicenseManifestParser(com.synopsys.integration.detectable.detectables.bitbake.parse.LicenseManifestParser) InputStream(java.io.InputStream) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) Optional(java.util.Optional) ShowRecipesResults(com.synopsys.integration.detectable.detectables.bitbake.data.ShowRecipesResults) File(java.io.File)

Aggregations

ShowRecipesResults (com.synopsys.integration.detectable.detectables.bitbake.data.ShowRecipesResults)3 BitbakeRecipesParser (com.synopsys.integration.detectable.detectables.bitbake.parse.BitbakeRecipesParser)2 HashMap (java.util.HashMap)2 List (java.util.List)2 GraphParser (com.paypal.digraph.parser.GraphParser)1 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 ExecutableTarget (com.synopsys.integration.detectable.ExecutableTarget)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 ExecutableFailedException (com.synopsys.integration.detectable.detectable.executable.ExecutableFailedException)1 EnumListFilter (com.synopsys.integration.detectable.detectable.util.EnumListFilter)1 BitbakeCommandRunner (com.synopsys.integration.detectable.detectables.bitbake.collect.BitbakeCommandRunner)1 BuildFileFinder (com.synopsys.integration.detectable.detectables.bitbake.collect.BuildFileFinder)1 BitbakeEnvironment (com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeEnvironment)1 BitbakeRecipe (com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeRecipe)1 BitbakeGraph (com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph)1 BitbakeEnvironmentParser (com.synopsys.integration.detectable.detectables.bitbake.parse.BitbakeEnvironmentParser)1 LicenseManifestParser (com.synopsys.integration.detectable.detectables.bitbake.parse.LicenseManifestParser)1 PwdOutputParser (com.synopsys.integration.detectable.detectables.bitbake.parse.PwdOutputParser)1 BitbakeDependencyGraphTransformer (com.synopsys.integration.detectable.detectables.bitbake.transform.BitbakeDependencyGraphTransformer)1 BitbakeGraphTransformer (com.synopsys.integration.detectable.detectables.bitbake.transform.BitbakeGraphTransformer)1