use of com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeEnvironment in project synopsys-detect by blackducksoftware.
the class BuildFileFinderTest method testFindingBasedOnLicenseDir.
@Test
void testFindingBasedOnLicenseDir() {
Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);
File buildDir = FunctionalTestFiles.asFile("/bitbake/builddir_env");
File licenseDir = FunctionalTestFiles.asFile("/bitbake/builddir_env/envprovidedpath/licenses");
File lastModifiedManifestFile = new File(licenseDir, "targetimage-last-modified-architecture/license.manifest");
File wrongManifestFile = new File(licenseDir, "targetimage-wrong-architecture/license.manifest");
long currentTime = System.currentTimeMillis();
assertTrue(lastModifiedManifestFile.setLastModified(currentTime), "The test needs to be able to set the last modified.");
assertTrue(wrongManifestFile.setLastModified(currentTime - 1000), "The test needs to be able to set the last modified.");
// This test adds license directory
BitbakeEnvironment bitbakeEnvironment = new BitbakeEnvironment(null, licenseDir.getAbsolutePath());
Optional<File> licensesManifestFile = finder.findLicenseManifestFile(buildDir, "targetimage", bitbakeEnvironment);
assertTrue(licensesManifestFile.isPresent());
assertTrue(licensesManifestFile.get().isFile());
assertEquals(licenseDir.getAbsolutePath() + "/targetimage-last-modified-architecture/license.manifest", licensesManifestFile.get().getAbsolutePath());
}
use of com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeEnvironment in project synopsys-detect by blackducksoftware.
the class BuildFileFinderTest method testFindingInDefaultAndCustom.
@ParameterizedTest
@ValueSource(strings = { "/bitbake/builddir_default", "/bitbake/builddir_custom" })
void testFindingInDefaultAndCustom(String directoryPath) {
File buildDir = FunctionalTestFiles.asFile(directoryPath);
BitbakeEnvironment bitbakeEnvironment = new BitbakeEnvironment(null, null);
Optional<File> licensesManifestFile = finder.findLicenseManifestFile(buildDir, "targetimage", bitbakeEnvironment);
assertTrue(licensesManifestFile.isPresent());
assertTrue(licensesManifestFile.get().isFile());
}
use of com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeEnvironment in project synopsys-detect by blackducksoftware.
the class BitbakeEnvironmentParserTest method testParseEnvironment.
@Test
void testParseEnvironment() {
BitbakeEnvironmentParser parser = new BitbakeEnvironmentParser();
BitbakeEnvironment environment = parser.parseArchitecture(lines);
assertTrue(environment.getMachineArch().isPresent());
assertEquals(ARCH, environment.getMachineArch().get());
assertTrue(environment.getLicensesDirPath().isPresent());
assertEquals(LICENSES_DIR, environment.getLicensesDirPath().get());
}
use of com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeEnvironment in project synopsys-detect by blackducksoftware.
the class BitbakeEnvironmentParser method parseArchitecture.
public BitbakeEnvironment parseArchitecture(List<String> bitbakeEnvironmentCmdOutput) {
Optional<String> architecture = bitbakeEnvironmentCmdOutput.stream().filter(isArchitectureLine).map(line -> isolateVariableValue(line, ARCHITECTURE_VARIABLE_NAME)).map(s -> StringUtils.strip(s, QUOTE_CHARS)).findFirst();
Optional<String> licensesDirPath = bitbakeEnvironmentCmdOutput.stream().filter(isLicensesDirLine).map(line -> isolateVariableValue(line, LICENSES_DIR_VARIABLE_NAME)).map(s -> StringUtils.strip(s, QUOTE_CHARS)).findFirst();
BitbakeEnvironment bitbakeEnvironment = new BitbakeEnvironment(architecture.orElse(null), licensesDirPath.orElse(null));
logger.debug("Bitbake environment: {}", bitbakeEnvironment);
return bitbakeEnvironment;
}
use of com.synopsys.integration.detectable.detectables.bitbake.data.BitbakeEnvironment 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);
}
}
Aggregations