Search in sources :

Example 1 with NativeLanguage

use of org.gradle.nativeplatform.toolchain.internal.NativeLanguage 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 NativeLanguage

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

the class DefaultToolChainSelector method select.

public Result<SwiftPlatform> select(SwiftPlatform 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.SWIFT;
    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);
    SwiftVersion sourceCompatibility = requestPlatform.getSourceCompatibility();
    if (sourceCompatibility == null && toolProvider.isAvailable()) {
        sourceCompatibility = toSwiftVersion(toolProvider.getCompilerMetadata(ToolType.SWIFT_COMPILER).getVersion());
    }
    SwiftPlatform targetPlatform = new DefaultSwiftPlatform(requestPlatform.getTargetMachine(), sourceCompatibility, targetNativePlatform);
    return new DefaultResult<SwiftPlatform>(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) SwiftVersion(org.gradle.language.swift.SwiftVersion) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) DefaultNativePlatform(org.gradle.nativeplatform.platform.internal.DefaultNativePlatform) SwiftPlatform(org.gradle.language.swift.SwiftPlatform) DefaultSwiftPlatform(org.gradle.language.swift.internal.DefaultSwiftPlatform)

Example 3 with NativeLanguage

use of org.gradle.nativeplatform.toolchain.internal.NativeLanguage 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)

Aggregations

DefaultNativePlatform (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform)3 NativeLanguage (org.gradle.nativeplatform.toolchain.internal.NativeLanguage)3 NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)3 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)3 DefaultCppPlatform (org.gradle.language.cpp.internal.DefaultCppPlatform)2 SwiftPlatform (org.gradle.language.swift.SwiftPlatform)2 DefaultSwiftPlatform (org.gradle.language.swift.internal.DefaultSwiftPlatform)2 CppPlatform (org.gradle.language.cpp.CppPlatform)1 SwiftVersion (org.gradle.language.swift.SwiftVersion)1 NativeToolChainRegistryInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal)1