use of com.paypal.digraph.parser.GraphParser in project hub-detect by blackducksoftware.
the class GraphParserTransformerTest method transform.
@Test
public void transform() throws IOException {
final GraphParserTransformer graphParserTransformer = new GraphParserTransformer();
final InputStream inputStream = new ClassPathResource("/bitbake/recipe-depends.dot").getInputStream();
final GraphParser graphParser = new GraphParser(inputStream);
final DependencyGraph dependencyGraph = graphParserTransformer.transform(graphParser, "i586-poky-linux");
assert dependencyGraph.getRootDependencies().size() == 480;
}
use of com.paypal.digraph.parser.GraphParser in project hub-detect by blackducksoftware.
the class BitbakeExtractor method extract.
public Extraction extract(final ExtractionId extractionId, final File buildEnvScript, final File sourcePath, String[] packageNames, File bash) {
final File outputDirectory = directoryManager.getExtractionOutputDirectory(extractionId);
final File bitbakeBuildDirectory = new File(outputDirectory, "build");
final List<DetectCodeLocation> detectCodeLocations = new ArrayList<>();
for (final String packageName : packageNames) {
final File dependsFile = executeBitbakeForRecipeDependsFile(outputDirectory, bitbakeBuildDirectory, buildEnvScript, packageName, bash);
final String targetArchitecture = executeBitbakeForTargetArchitecture(outputDirectory, buildEnvScript, packageName, bash);
try {
if (dependsFile == null) {
throw new IntegrationException(String.format("Failed to find %s. This may be due to this project being a version of The Yocto Project earlier than 2.3 (Pyro) which is the minimum version for Detect", RECIPE_DEPENDS_FILE_NAME));
}
if (StringUtils.isBlank(targetArchitecture)) {
throw new IntegrationException("Failed to find a target architecture");
}
logger.debug(FileUtils.readFileToString(dependsFile, Charset.defaultCharset()));
final InputStream recipeDependsInputStream = FileUtils.openInputStream(dependsFile);
final GraphParser graphParser = new GraphParser(recipeDependsInputStream);
final DependencyGraph dependencyGraph = graphParserTransformer.transform(graphParser, targetArchitecture);
final ExternalId externalId = new ExternalId(Forge.YOCTO);
final DetectCodeLocation detectCodeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.BITBAKE, sourcePath.getCanonicalPath(), externalId, dependencyGraph).build();
detectCodeLocations.add(detectCodeLocation);
} catch (final IOException | IntegrationException | NullPointerException e) {
logger.error(String.format("Failed to extract a Code Location while running Bitbake against package '%s'", packageName));
logger.debug(e.getMessage(), e);
}
}
final Extraction extraction;
if (detectCodeLocations.isEmpty()) {
extraction = new Extraction.Builder().failure("No Code Locations were generated during extraction").build();
} else {
extraction = new Extraction.Builder().success(detectCodeLocations).build();
}
return extraction;
}
Aggregations