Search in sources :

Example 1 with CommandLineToolSearchResult

use of org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult in project gradle by gradle.

the class GccPlatformToolProvider method getGccMetadata.

private SearchResult<GccMetadata> getGccMetadata(ToolType compilerType) {
    GccCommandLineToolConfigurationInternal compiler = toolRegistry.getTool(compilerType);
    if (compiler == null) {
        return new ComponentNotFound<GccMetadata>("Tool " + compilerType.getToolName() + " is not available");
    }
    CommandLineToolSearchResult searchResult = toolSearchPath.locate(compiler.getToolType(), compiler.getExecutable());
    String language = LANGUAGE_FOR_COMPILER.get(compilerType);
    List<String> languageArgs = language == null ? Collections.<String>emptyList() : ImmutableList.of("-x", language);
    return metadataProvider.getCompilerMetaData(toolSearchPath.getPath(), spec -> spec.executable(searchResult.getTool()).args(languageArgs));
}
Also used : ComponentNotFound(org.gradle.platform.base.internal.toolchain.ComponentNotFound) CommandLineToolSearchResult(org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult) GccCommandLineToolConfigurationInternal(org.gradle.nativeplatform.toolchain.internal.tools.GccCommandLineToolConfigurationInternal)

Example 2 with CommandLineToolSearchResult

use of org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult in project gradle by gradle.

the class SwiftcToolChain method createPlatformToolProvider.

private PlatformToolProvider createPlatformToolProvider(NativePlatformInternal targetPlatform) {
    DefaultSwiftcPlatformToolChain configurableToolChain = instantiator.newInstance(DefaultSwiftcPlatformToolChain.class, targetPlatform);
    addDefaultTools(configurableToolChain);
    configureActions.execute(configurableToolChain);
    // TODO: this is an approximation as we know swift currently supports only 64-bit runtimes - eventually, we'll want to query for this
    if (!isCurrentArchitecture(targetPlatform)) {
        return new UnsupportedPlatformToolProvider(targetPlatform.getOperatingSystem(), String.format("Don't know how to build for %s.", targetPlatform.getDisplayName()));
    }
    CommandLineToolSearchResult compiler = toolSearchPath.locate(ToolType.SWIFT_COMPILER, "swiftc");
    ToolChainAvailability result = new ToolChainAvailability();
    result.mustBeAvailable(compiler);
    if (!result.isAvailable()) {
        return new UnavailablePlatformToolProvider(targetPlatform.getOperatingSystem(), result);
    }
    SearchResult<SwiftcMetadata> swiftcMetaData = compilerMetaDataProvider.getCompilerMetaData(toolSearchPath.getPath(), spec -> spec.executable(compiler.getTool()));
    result.mustBeAvailable(swiftcMetaData);
    if (!result.isAvailable()) {
        return new UnavailablePlatformToolProvider(targetPlatform.getOperatingSystem(), result);
    }
    return new SwiftPlatformToolProvider(buildOperationExecutor, targetPlatform.getOperatingSystem(), toolSearchPath, configurableToolChain, execActionFactory, compilerOutputFileNamingSchemeFactory, workerLeaseService, swiftcMetaData.getComponent());
}
Also used : UnavailablePlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.UnavailablePlatformToolProvider) ToolChainAvailability(org.gradle.platform.base.internal.toolchain.ToolChainAvailability) CommandLineToolSearchResult(org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult) SwiftcMetadata(org.gradle.nativeplatform.toolchain.internal.swift.metadata.SwiftcMetadata) UnsupportedPlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.UnsupportedPlatformToolProvider)

Example 3 with CommandLineToolSearchResult

use of org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult in project gradle by gradle.

the class AbstractGccCompatibleToolChain method initTools.

protected void initTools(DefaultGccPlatformToolChain platformToolChain, ToolChainAvailability availability) {
    // Attempt to determine whether the compiler is the correct implementation
    for (GccCommandLineToolConfigurationInternal tool : platformToolChain.getCompilers()) {
        CommandLineToolSearchResult compiler = locate(tool);
        if (compiler.isAvailable()) {
            SearchResult<GccMetadata> gccMetadata = getMetaDataProvider().getCompilerMetaData(toolSearchPath.getPath(), spec -> spec.executable(compiler.getTool()).args(platformToolChain.getCompilerProbeArgs()));
            availability.mustBeAvailable(gccMetadata);
            if (!gccMetadata.isAvailable()) {
                return;
            }
            // Assume all the other compilers are ok, if they happen to be installed
            LOGGER.debug("Found {} with version {}", tool.getToolType().getToolName(), gccMetadata);
            initForImplementation(platformToolChain, gccMetadata.getComponent());
            break;
        }
    }
}
Also used : GccMetadata(org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadata) CommandLineToolSearchResult(org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult) GccCommandLineToolConfigurationInternal(org.gradle.nativeplatform.toolchain.internal.tools.GccCommandLineToolConfigurationInternal)

Example 4 with CommandLineToolSearchResult

use of org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult in project gradle by gradle.

the class CppModelBuilder method binariesFor.

private List<DefaultCppBinaryModel> binariesFor(CppComponent component, Iterable<File> headerDirs, DefaultProjectIdentifier projectIdentifier, CompilerOutputFileNamingSchemeFactory namingSchemeFactory) {
    List<File> headerDirsCopy = ImmutableList.copyOf(headerDirs);
    List<DefaultCppBinaryModel> binaries = new ArrayList<DefaultCppBinaryModel>();
    for (CppBinary binary : component.getBinaries().get()) {
        DefaultCppBinary cppBinary = (DefaultCppBinary) binary;
        PlatformToolProvider platformToolProvider = cppBinary.getPlatformToolProvider();
        CppCompile compileTask = binary.getCompileTask().get();
        List<DefaultSourceFile> sourceFiles = sourceFiles(namingSchemeFactory, platformToolProvider, compileTask.getObjectFileDir().get().getAsFile(), binary.getCppSource().getFiles());
        List<File> systemIncludes = ImmutableList.copyOf(compileTask.getSystemIncludes().getFiles());
        List<File> userIncludes = ImmutableList.copyOf(compileTask.getIncludes().getFiles());
        List<DefaultMacroDirective> macroDefines = macroDefines(compileTask);
        List<String> additionalArgs = args(compileTask.getCompilerArgs().get());
        CommandLineToolSearchResult compilerLookup = platformToolProvider.locateTool(ToolType.CPP_COMPILER);
        File compilerExe = compilerLookup.isAvailable() ? compilerLookup.getTool() : null;
        LaunchableGradleTask compileTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, compileTask);
        DefaultCompilationDetails compilationDetails = new DefaultCompilationDetails(compileTaskModel, compilerExe, compileTask.getObjectFileDir().get().getAsFile(), sourceFiles, headerDirsCopy, systemIncludes, userIncludes, macroDefines, additionalArgs);
        if (binary instanceof CppExecutable || binary instanceof CppTestExecutable) {
            ComponentWithExecutable componentWithExecutable = (ComponentWithExecutable) binary;
            LinkExecutable linkTask = componentWithExecutable.getLinkTask().get();
            LaunchableGradleTask linkTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, componentWithExecutable.getExecutableFileProducer().get());
            DefaultLinkageDetails linkageDetails = new DefaultLinkageDetails(linkTaskModel, componentWithExecutable.getExecutableFile().get().getAsFile(), args(linkTask.getLinkerArgs().get()));
            binaries.add(new DefaultCppExecutableModel(binary.getName(), cppBinary.getIdentity().getName(), binary.getBaseName().get(), compilationDetails, linkageDetails));
        } else if (binary instanceof CppSharedLibrary) {
            CppSharedLibrary sharedLibrary = (CppSharedLibrary) binary;
            LinkSharedLibrary linkTask = sharedLibrary.getLinkTask().get();
            LaunchableGradleTask linkTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, sharedLibrary.getLinkFileProducer().get());
            DefaultLinkageDetails linkageDetails = new DefaultLinkageDetails(linkTaskModel, sharedLibrary.getLinkFile().get().getAsFile(), args(linkTask.getLinkerArgs().get()));
            binaries.add(new DefaultCppSharedLibraryModel(binary.getName(), cppBinary.getIdentity().getName(), binary.getBaseName().get(), compilationDetails, linkageDetails));
        } else if (binary instanceof CppStaticLibrary) {
            CppStaticLibrary staticLibrary = (CppStaticLibrary) binary;
            LaunchableGradleTask createTaskModel = ToolingModelBuilderSupport.buildFromTask(new LaunchableGradleTask(), projectIdentifier, staticLibrary.getLinkFileProducer().get());
            DefaultLinkageDetails linkageDetails = new DefaultLinkageDetails(createTaskModel, staticLibrary.getLinkFile().get().getAsFile(), Collections.<String>emptyList());
            binaries.add(new DefaultCppStaticLibraryModel(binary.getName(), cppBinary.getIdentity().getName(), binary.getBaseName().get(), compilationDetails, linkageDetails));
        }
    }
    return binaries;
}
Also used : ArrayList(java.util.ArrayList) LinkSharedLibrary(org.gradle.nativeplatform.tasks.LinkSharedLibrary) CppStaticLibrary(org.gradle.language.cpp.CppStaticLibrary) CommandLineToolSearchResult(org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult) CppSharedLibrary(org.gradle.language.cpp.CppSharedLibrary) ComponentWithExecutable(org.gradle.language.nativeplatform.ComponentWithExecutable) DefaultCppBinary(org.gradle.language.cpp.internal.DefaultCppBinary) CppBinary(org.gradle.language.cpp.CppBinary) CppExecutable(org.gradle.language.cpp.CppExecutable) DefaultCppBinary(org.gradle.language.cpp.internal.DefaultCppBinary) LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) LinkExecutable(org.gradle.nativeplatform.tasks.LinkExecutable) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) CppCompile(org.gradle.language.cpp.tasks.CppCompile) File(java.io.File) CppTestExecutable(org.gradle.nativeplatform.test.cpp.CppTestExecutable)

Aggregations

CommandLineToolSearchResult (org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult)4 GccCommandLineToolConfigurationInternal (org.gradle.nativeplatform.toolchain.internal.tools.GccCommandLineToolConfigurationInternal)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 CppBinary (org.gradle.language.cpp.CppBinary)1 CppExecutable (org.gradle.language.cpp.CppExecutable)1 CppSharedLibrary (org.gradle.language.cpp.CppSharedLibrary)1 CppStaticLibrary (org.gradle.language.cpp.CppStaticLibrary)1 DefaultCppBinary (org.gradle.language.cpp.internal.DefaultCppBinary)1 CppCompile (org.gradle.language.cpp.tasks.CppCompile)1 ComponentWithExecutable (org.gradle.language.nativeplatform.ComponentWithExecutable)1 LinkExecutable (org.gradle.nativeplatform.tasks.LinkExecutable)1 LinkSharedLibrary (org.gradle.nativeplatform.tasks.LinkSharedLibrary)1 CppTestExecutable (org.gradle.nativeplatform.test.cpp.CppTestExecutable)1 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)1 UnavailablePlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.UnavailablePlatformToolProvider)1 UnsupportedPlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.UnsupportedPlatformToolProvider)1 GccMetadata (org.gradle.nativeplatform.toolchain.internal.gcc.metadata.GccMetadata)1 SwiftcMetadata (org.gradle.nativeplatform.toolchain.internal.swift.metadata.SwiftcMetadata)1 ComponentNotFound (org.gradle.platform.base.internal.toolchain.ComponentNotFound)1