Search in sources :

Example 1 with GccMetadataProvider

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;
}
Also used : GccMetadata(org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadata) GccMetadataProvider(org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadataProvider) File(java.io.File) TestFile(org.gradle.test.fixtures.file.TestFile)

Example 2 with GccMetadataProvider

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;
}
Also used : Optional(java.util.Optional) GccMetadata(org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadata) GccMetadataProvider(org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadataProvider) File(java.io.File) TestFile(org.gradle.test.fixtures.file.TestFile)

Aggregations

File (java.io.File)2 GccMetadata (org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadata)2 GccMetadataProvider (org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadataProvider)2 TestFile (org.gradle.test.fixtures.file.TestFile)2 Optional (java.util.Optional)1