Search in sources :

Example 1 with NativeToolChainRegistryInternal

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

the class DefaultToolChainSelector method select.

@Override
public <T extends NativePlatform> Result<T> select(Class<T> platformType) {
    DefaultNativePlatform targetMachine = host;
    // TODO - push all this stuff down to the tool chain and let it create the specific platform and provider
    NativeLanguage sourceLanguage = platformType == SwiftPlatform.class ? NativeLanguage.SWIFT : NativeLanguage.CPP;
    NativeToolChainRegistryInternal registry = modelRegistry.realize("toolChains", NativeToolChainRegistryInternal.class);
    NativeToolChainInternal toolChain = registry.getForPlatform(sourceLanguage, targetMachine);
    // TODO - don't select again here, as the selection is already performed to select the toolchain
    PlatformToolProvider toolProvider = toolChain.select(sourceLanguage, targetMachine);
    if (!toolProvider.isAvailable() && targetMachine.getOperatingSystem().isWindows() && targetMachine.getArchitecture().isAmd64()) {
        // Try building x86 on Windows. Don't do this for other operating systems (yet)
        DefaultNativePlatform x86platformRequest = targetMachine.withArchitecture(Architectures.of(Architectures.X86));
        NativeToolChainInternal x86ToolChain = registry.getForPlatform(sourceLanguage, x86platformRequest);
        // TODO - don't select again here, as the selection is already performed to select the toolchain
        PlatformToolProvider x86ToolProvider = x86ToolChain.select(sourceLanguage, x86platformRequest);
        if (x86ToolProvider.isAvailable()) {
            targetMachine = x86platformRequest;
            toolChain = x86ToolChain;
            toolProvider = x86ToolProvider;
        }
    }
    // TODO - use a better name for the platforms, rather than "current"
    T targetPlatform = null;
    if (CppPlatform.class.isAssignableFrom(platformType)) {
        targetPlatform = platformType.cast(new DefaultCppPlatform("host", targetMachine));
    } else if (SwiftPlatform.class.isAssignableFrom(platformType)) {
        targetPlatform = platformType.cast(new DefaultSwiftPlatform("host", targetMachine));
    }
    return new DefaultResult<T>(toolChain, toolProvider, targetPlatform);
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) NativeLanguage(org.gradle.nativeplatform.toolchain.internal.NativeLanguage) DefaultSwiftPlatform(org.gradle.language.swift.internal.DefaultSwiftPlatform) NativeToolChainRegistryInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) DefaultNativePlatform(org.gradle.nativeplatform.platform.internal.DefaultNativePlatform) DefaultCppPlatform(org.gradle.language.cpp.internal.DefaultCppPlatform) SwiftPlatform(org.gradle.language.swift.SwiftPlatform) DefaultSwiftPlatform(org.gradle.language.swift.internal.DefaultSwiftPlatform)

Example 2 with NativeToolChainRegistryInternal

use of org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal 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)2 NativeToolChainRegistryInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal)2 DefaultCppPlatform (org.gradle.language.cpp.internal.DefaultCppPlatform)1 SwiftPlatform (org.gradle.language.swift.SwiftPlatform)1 DefaultSwiftPlatform (org.gradle.language.swift.internal.DefaultSwiftPlatform)1 DefaultNativePlatform (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform)1 NativeLanguage (org.gradle.nativeplatform.toolchain.internal.NativeLanguage)1 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)1