Search in sources :

Example 21 with NativeToolChainInternal

use of org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal in project gradle by gradle.

the class AbstractNativeSourceCompileTask method getCompilerVersion.

/**
 * The compiler used, including the type and the version.
 *
 * @since 4.4
 */
@Nullable
@Optional
@Nested
protected CompilerVersion getCompilerVersion() {
    NativeToolChainInternal toolChain = (NativeToolChainInternal) getToolChain().get();
    NativePlatformInternal targetPlatform = (NativePlatformInternal) getTargetPlatform().get();
    PlatformToolProvider toolProvider = toolChain.select(targetPlatform);
    Compiler<? extends NativeCompileSpec> compiler = toolProvider.newCompiler(createCompileSpec().getClass());
    if (!(compiler instanceof VersionAwareCompiler)) {
        return null;
    }
    return ((VersionAwareCompiler) compiler).getVersion();
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) VersionAwareCompiler(org.gradle.language.base.internal.compile.VersionAwareCompiler) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal) Optional(org.gradle.api.tasks.Optional) Nested(org.gradle.api.tasks.Nested) Nullable(javax.annotation.Nullable)

Example 22 with NativeToolChainInternal

use of org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal in project gradle by gradle.

the class DefaultToolChainSelector method select.

public Result<CppPlatform> select(CppPlatform requestPlatform) {
    DefaultNativePlatform targetNativePlatform = newNativePlatform(requestPlatform.getTargetMachine());
    // TODO - push all this stuff down to the tool chain and let it create the specific platform and provider
    NativeLanguage sourceLanguage = NativeLanguage.CPP;
    NativeToolChainInternal toolChain = getToolChain(sourceLanguage, targetNativePlatform);
    // TODO - don't select again here, as the selection is already performed to select the toolchain
    PlatformToolProvider toolProvider = toolChain.select(sourceLanguage, targetNativePlatform);
    CppPlatform targetPlatform = new DefaultCppPlatform(requestPlatform.getTargetMachine(), targetNativePlatform);
    return new DefaultResult<CppPlatform>(toolChain, toolProvider, targetPlatform);
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) CppPlatform(org.gradle.language.cpp.CppPlatform) DefaultCppPlatform(org.gradle.language.cpp.internal.DefaultCppPlatform) NativeLanguage(org.gradle.nativeplatform.toolchain.internal.NativeLanguage) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) DefaultNativePlatform(org.gradle.nativeplatform.platform.internal.DefaultNativePlatform) DefaultCppPlatform(org.gradle.language.cpp.internal.DefaultCppPlatform)

Example 23 with NativeToolChainInternal

use of org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal in project gradle by gradle.

the class DefaultToolChainSelector method getToolChain.

private NativeToolChainInternal getToolChain(NativeLanguage sourceLanguage, NativePlatformInternal targetNativePlatform) {
    NativeToolChainRegistryInternal registry = modelRegistry.realize("toolChains", NativeToolChainRegistryInternal.class);
    NativeToolChainInternal toolChain = registry.getForPlatform(sourceLanguage, targetNativePlatform);
    toolChain.assertSupported();
    return toolChain;
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) NativeToolChainRegistryInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal)

Aggregations

NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)23 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)20 NativePlatformInternal (org.gradle.nativeplatform.platform.internal.NativePlatformInternal)12 File (java.io.File)6 TaskAction (org.gradle.api.tasks.TaskAction)5 BuildOperationLogger (org.gradle.internal.operations.logging.BuildOperationLogger)5 DefaultNativePlatform (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform)5 Project (org.gradle.api.Project)4 NativeCompileSpec (org.gradle.nativeplatform.toolchain.internal.NativeCompileSpec)4 NativeToolChainRegistryInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal)4 LinkedHashSet (java.util.LinkedHashSet)3 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)3 MinimalFileSet (org.gradle.api.internal.file.collections.MinimalFileSet)3 WorkResult (org.gradle.api.tasks.WorkResult)3 Names (org.gradle.language.nativeplatform.internal.Names)3 SwiftPlatform (org.gradle.language.swift.SwiftPlatform)3 DefaultSwiftPlatform (org.gradle.language.swift.internal.DefaultSwiftPlatform)3 NativeLanguage (org.gradle.nativeplatform.toolchain.internal.NativeLanguage)3 List (java.util.List)2 Callable (java.util.concurrent.Callable)2