Search in sources :

Example 1 with PackageDetailsResult

use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult in project synopsys-detect by blackducksoftware.

the class ClangExtractor method extract.

public Extraction extract(ClangPackageManager currentPackageManager, ClangPackageManagerRunner packageManagerRunner, File sourceDirectory, File outputDirectory, File jsonCompilationDatabaseFile, boolean cleanup) {
    try {
        logger.debug(String.format("Analyzing %s", jsonCompilationDatabaseFile.getAbsolutePath()));
        logger.debug(String.format("extract() called; compileCommandsJsonFilePath: %s", jsonCompilationDatabaseFile.getAbsolutePath()));
        List<CompileCommand> compileCommands = compileCommandDatabaseParser.parseCompileCommandDatabase(jsonCompilationDatabaseFile);
        Set<File> dependencyFileDetails = dependencyFileDetailGenerator.fromCompileCommands(compileCommands, outputDirectory, cleanup);
        PackageDetailsResult results = packageManagerRunner.getAllPackages(currentPackageManager, sourceDirectory, executableRunner, dependencyFileDetails);
        logger.trace("Found : " + results.getFoundPackages() + " packages.");
        logger.trace("Found : " + results.getUnRecognizedDependencyFiles() + " non-package files.");
        List<Forge> packageForges = forgeChooser.determineForges(currentPackageManager);
        CodeLocation codeLocation = clangPackageDetailsTransformer.toCodeLocation(packageForges, results.getFoundPackages());
        logFileCollection("Unrecognized dependency files (all)", results.getUnRecognizedDependencyFiles());
        List<File> unrecognizedIncludeFiles = results.getUnRecognizedDependencyFiles().stream().filter(file -> !isFileUnderDir(sourceDirectory, file)).collect(Collectors.toList());
        logFileCollection(String.format("Unrecognized dependency files that are outside the compile_commands.json directory (%s) and will be collected", sourceDirectory), unrecognizedIncludeFiles);
        return new Extraction.Builder().unrecognizedPaths(unrecognizedIncludeFiles).success(codeLocation).build();
    } catch (Exception e) {
        return new Extraction.Builder().exception(e).build();
    }
}
Also used : Logger(org.slf4j.Logger) Forge(com.synopsys.integration.bdio.model.Forge) PackageDetailsResult(com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult) Extraction(com.synopsys.integration.detectable.extraction.Extraction) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) ClangPackageManagerRunner(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerRunner) Set(java.util.Set) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ClangPackageDetailsTransformer(com.synopsys.integration.detectable.detectables.clang.dependencyfile.ClangPackageDetailsTransformer) File(java.io.File) ArrayList(java.util.ArrayList) CompileCommandDatabaseParser(com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommandDatabaseParser) CompileCommand(com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommand) List(java.util.List) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) DetectableExecutableRunner(com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner) ClangPackageManager(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManager) DependencyFileDetailGenerator(com.synopsys.integration.detectable.detectables.clang.dependencyfile.DependencyFileDetailGenerator) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) Forge(com.synopsys.integration.bdio.model.Forge) IOException(java.io.IOException) CompileCommand(com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommand) Extraction(com.synopsys.integration.detectable.extraction.Extraction) PackageDetailsResult(com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult) File(java.io.File)

Example 2 with PackageDetailsResult

use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult in project synopsys-detect by blackducksoftware.

the class ClangPackageManagerRunnerTest method testSuccessCase.

private void testSuccessCase(ClangPackageManagerInfo packageManagerInfo, ClangPackageManagerResolver packageResolver, String pkgName, String pkgArchitecture, boolean archBuried, String pkgVersion, String pkgMgrQueryResultPattern, String pkgMgrDetailsQueryResultPattern) throws ExecutableRunnerException {
    // Test
    PackageDetailsResult result = runTest(packageManagerInfo, packageResolver, pkgName, pkgArchitecture, archBuried, pkgMgrQueryResultPattern, pkgMgrDetailsQueryResultPattern, dependencyFile);
    // Verify
    assertEquals(0, result.getUnRecognizedDependencyFiles().size());
    assertEquals(1, result.getFoundPackages().size());
    PackageDetails foundPkgDetails = result.getFoundPackages().iterator().next();
    assertEquals(pkgName, foundPkgDetails.getPackageName());
    assertEquals(pkgArchitecture, foundPkgDetails.getPackageArch());
    assertEquals(pkgVersion, foundPkgDetails.getPackageVersion());
}
Also used : PackageDetailsResult(com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult) PackageDetails(com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails)

Example 3 with PackageDetailsResult

use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult in project synopsys-detect by blackducksoftware.

the class ClangPackageManagerRunnerTest method testNonPkgOwnedIncludeFile.

private void testNonPkgOwnedIncludeFile(ClangPackageManagerInfo packageManagerInfo, ClangPackageManagerResolver packageResolver, String pkgMgrOwnerQueryResultPattern) throws ExecutableRunnerException {
    // Test
    PackageDetailsResult result = runTest(packageManagerInfo, packageResolver, null, null, false, pkgMgrOwnerQueryResultPattern, null, dependencyFile);
    // Verify
    assertEquals(1, result.getUnRecognizedDependencyFiles().size());
    assertEquals(dependencyFile, result.getUnRecognizedDependencyFiles().iterator().next());
}
Also used : PackageDetailsResult(com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult)

Example 4 with PackageDetailsResult

use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult in project synopsys-detect by blackducksoftware.

the class ClangPackageManagerRunnerTest method testNoResultsCase.

private void testNoResultsCase(ClangPackageManagerInfo packageManagerInfo, ClangPackageManagerResolver packageResolver, String pkgName, String pkgArchitecture, String pkgMgrQueryResultPattern, String pkgMgrDetailsQueryResultPattern) throws ExecutableRunnerException {
    // Test
    PackageDetailsResult result = runTest(packageManagerInfo, packageResolver, pkgName, pkgArchitecture, false, pkgMgrQueryResultPattern, pkgMgrDetailsQueryResultPattern, dependencyFile);
    // Verify
    assertEquals(0, result.getUnRecognizedDependencyFiles().size());
    assertEquals(0, result.getFoundPackages().size());
}
Also used : PackageDetailsResult(com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult)

Aggregations

PackageDetailsResult (com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult)4 Forge (com.synopsys.integration.bdio.model.Forge)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 DetectableExecutableRunner (com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner)1 CompileCommand (com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommand)1 CompileCommandDatabaseParser (com.synopsys.integration.detectable.detectables.clang.compilecommand.CompileCommandDatabaseParser)1 ClangPackageDetailsTransformer (com.synopsys.integration.detectable.detectables.clang.dependencyfile.ClangPackageDetailsTransformer)1 DependencyFileDetailGenerator (com.synopsys.integration.detectable.detectables.clang.dependencyfile.DependencyFileDetailGenerator)1 ClangPackageManager (com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManager)1 ClangPackageManagerRunner (com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerRunner)1 PackageDetails (com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails)1 Extraction (com.synopsys.integration.detectable.extraction.Extraction)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1