Search in sources :

Example 6 with NativePlatformInternal

use of org.gradle.nativeplatform.platform.internal.NativePlatformInternal in project gradle by gradle.

the class AbstractLinkTask method createCompiler.

@SuppressWarnings("unchecked")
private Compiler<LinkerSpec> createCompiler() {
    NativePlatformInternal targetPlatform = Cast.cast(NativePlatformInternal.class, this.targetPlatform.get());
    NativeToolChainInternal toolChain = Cast.cast(NativeToolChainInternal.class, getToolChain().get());
    PlatformToolProvider toolProvider = toolChain.select(targetPlatform);
    Class<LinkerSpec> linkerSpecType = (Class<LinkerSpec>) createLinkerSpec().getClass();
    return toolProvider.newCompiler(linkerSpecType);
}
Also used : LinkerSpec(org.gradle.nativeplatform.internal.LinkerSpec) NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal)

Example 7 with NativePlatformInternal

use of org.gradle.nativeplatform.platform.internal.NativePlatformInternal in project gradle by gradle.

the class CreateStaticLibrary method createCompiler.

private Compiler<StaticLibraryArchiverSpec> createCompiler() {
    NativePlatformInternal targetPlatform = Cast.cast(NativePlatformInternal.class, this.targetPlatform.get());
    NativeToolChainInternal toolChain = Cast.cast(NativeToolChainInternal.class, getToolChain().get());
    PlatformToolProvider toolProvider = toolChain.select(targetPlatform);
    return toolProvider.newCompiler(StaticLibraryArchiverSpec.class);
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal)

Example 8 with NativePlatformInternal

use of org.gradle.nativeplatform.platform.internal.NativePlatformInternal in project gradle by gradle.

the class ExtractSymbols method createCompiler.

private Compiler<SymbolExtractorSpec> createCompiler() {
    NativePlatformInternal targetPlatform = Cast.cast(NativePlatformInternal.class, this.targetPlatform.get());
    NativeToolChainInternal toolChain = Cast.cast(NativeToolChainInternal.class, getToolChain().get());
    PlatformToolProvider toolProvider = toolChain.select(targetPlatform);
    return toolProvider.newCompiler(SymbolExtractorSpec.class);
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal)

Example 9 with NativePlatformInternal

use of org.gradle.nativeplatform.platform.internal.NativePlatformInternal 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 10 with NativePlatformInternal

use of org.gradle.nativeplatform.platform.internal.NativePlatformInternal in project gradle by gradle.

the class SwiftCompile method compile.

@TaskAction
void compile(IncrementalTaskInputs inputs) {
    final List<File> removedFiles = Lists.newArrayList();
    final Set<File> changedFiles = Sets.newHashSet();
    boolean isIncremental = inputs.isIncremental();
    // which files changed and marking the compilation incremental or not.
    if (isIncremental) {
        inputs.outOfDate(new Action<InputFileDetails>() {

            @Override
            public void execute(InputFileDetails inputFileDetails) {
                if (inputFileDetails.isModified()) {
                    changedFiles.add(inputFileDetails.getFile());
                }
            }
        });
        inputs.removed(new Action<InputFileDetails>() {

            @Override
            public void execute(InputFileDetails removed) {
                removedFiles.add(removed.getFile());
            }
        });
        Set<File> allSourceFiles = getSource().getFiles();
        if (!allSourceFiles.containsAll(changedFiles)) {
            // If a non-source file changed, the compilation cannot be incremental
            // due to the way the Swift compiler detects changes from other modules
            isIncremental = false;
        }
    }
    BuildOperationLogger operationLogger = getServices().get(BuildOperationLoggerFactory.class).newOperationLogger(getName(), getTemporaryDir());
    NativePlatformInternal targetPlatform = Cast.cast(NativePlatformInternal.class, this.targetPlatform.get());
    SwiftCompileSpec spec = createSpec(operationLogger, isIncremental, changedFiles, removedFiles, targetPlatform);
    Compiler<SwiftCompileSpec> baseCompiler = new IncrementalSwiftCompiler(createCompiler(), getOutputs(), compilerOutputFileNamingSchemeFactory);
    Compiler<SwiftCompileSpec> loggingCompiler = BuildOperationLoggingCompilerDecorator.wrap(baseCompiler);
    WorkResult result = loggingCompiler.execute(spec);
    setDidWork(result.getDidWork());
}
Also used : BuildOperationLoggerFactory(org.gradle.internal.operations.logging.BuildOperationLoggerFactory) BuildOperationLogger(org.gradle.internal.operations.logging.BuildOperationLogger) InputFileDetails(org.gradle.api.tasks.incremental.InputFileDetails) DefaultSwiftCompileSpec(org.gradle.language.swift.tasks.internal.DefaultSwiftCompileSpec) SwiftCompileSpec(org.gradle.nativeplatform.toolchain.internal.compilespec.SwiftCompileSpec) IncrementalSwiftCompiler(org.gradle.nativeplatform.toolchain.internal.swift.IncrementalSwiftCompiler) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal) WorkResult(org.gradle.api.tasks.WorkResult) OutputFile(org.gradle.api.tasks.OutputFile) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

NativePlatformInternal (org.gradle.nativeplatform.platform.internal.NativePlatformInternal)11 NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)10 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)8 TaskAction (org.gradle.api.tasks.TaskAction)4 BuildOperationLogger (org.gradle.internal.operations.logging.BuildOperationLogger)4 WorkResult (org.gradle.api.tasks.WorkResult)3 NativeCompileSpec (org.gradle.nativeplatform.toolchain.internal.NativeCompileSpec)2 File (java.io.File)1 Nullable (javax.annotation.Nullable)1 Nested (org.gradle.api.tasks.Nested)1 Optional (org.gradle.api.tasks.Optional)1 OutputFile (org.gradle.api.tasks.OutputFile)1 InputFileDetails (org.gradle.api.tasks.incremental.InputFileDetails)1 BuildOperationLoggerFactory (org.gradle.internal.operations.logging.BuildOperationLoggerFactory)1 DefaultAssembleSpec (org.gradle.language.assembler.internal.DefaultAssembleSpec)1 VersionAwareCompiler (org.gradle.language.base.internal.compile.VersionAwareCompiler)1 SimpleStaleClassCleaner (org.gradle.language.base.internal.tasks.SimpleStaleClassCleaner)1 DefaultWindowsResourceCompileSpec (org.gradle.language.rc.internal.DefaultWindowsResourceCompileSpec)1 DefaultSwiftCompileSpec (org.gradle.language.swift.tasks.internal.DefaultSwiftCompileSpec)1 LinkerSpec (org.gradle.nativeplatform.internal.LinkerSpec)1