use of org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadataProvider in project gradle by gradle.
the class AvailableToolChains method findGccs.
private static List<ToolChainCandidate> findGccs(boolean mustFind) {
GccMetadataProvider versionDeterminer = GccMetadataProvider.forGcc(TestFiles.execActionFactory());
Set<File> gppCandidates = ImmutableSet.copyOf(OperatingSystem.current().findAllInPath("g++"));
List<ToolChainCandidate> toolChains = Lists.newArrayList();
if (!gppCandidates.isEmpty()) {
File firstInPath = gppCandidates.iterator().next();
for (File candidate : gppCandidates) {
SearchResult<GccMetadata> version = versionDeterminer.getCompilerMetaData(Collections.emptyList(), spec -> spec.executable(candidate));
if (version.isAvailable()) {
InstalledGcc gcc = new InstalledGcc(ToolFamily.GCC, version.getComponent().getVersion());
if (!candidate.equals(firstInPath)) {
// Not the first g++ in the path, needs the path variable updated
gcc.inPath(candidate.getParentFile());
}
toolChains.add(gcc);
}
}
}
if (mustFind && toolChains.isEmpty()) {
toolChains.add(new UnavailableToolChain(ToolFamily.GCC));
}
toolChains.sort(LATEST_RELEASED_FIRST);
return toolChains;
}
use of org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadataProvider in project gradle by gradle.
the class AvailableToolChains method findClangs.
private static List<ToolChainCandidate> findClangs(boolean mustFind) {
List<ToolChainCandidate> toolChains = Lists.newArrayList();
// We need to search for Clang differently on macOS because we need to know the Xcode version for x86 support.
if (OperatingSystem.current().isMacOsX()) {
toolChains.addAll(findXcodes().stream().map(InstalledXcode::getClang).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()));
} else {
GccMetadataProvider versionDeterminer = GccMetadataProvider.forClang(TestFiles.execActionFactory());
Set<File> clangCandidates = ImmutableSet.copyOf(OperatingSystem.current().findAllInPath("clang"));
if (!clangCandidates.isEmpty()) {
File firstInPath = clangCandidates.iterator().next();
for (File candidate : clangCandidates) {
SearchResult<GccMetadata> version = versionDeterminer.getCompilerMetaData(Collections.emptyList(), spec -> spec.executable(candidate));
if (version.isAvailable()) {
InstalledClang clang = new InstalledClang(version.getComponent().getVersion());
if (!candidate.equals(firstInPath)) {
// Not the first g++ in the path, needs the path variable updated
clang.inPath(candidate.getParentFile());
}
toolChains.add(clang);
}
}
}
}
if (mustFind && toolChains.isEmpty()) {
toolChains.add(new UnavailableToolChain(ToolFamily.CLANG));
}
toolChains.sort(LATEST_RELEASED_FIRST);
return toolChains;
}
Aggregations