Search in sources :

Example 6 with WorkResult

use of org.gradle.api.tasks.WorkResult in project gradle by gradle.

the class WindowsResourceCompile method compile.

@TaskAction
public void compile(IncrementalTaskInputs inputs) {
    BuildOperationLogger operationLogger = getOperationLoggerFactory().newOperationLogger(getName(), getTemporaryDir());
    NativeCompileSpec spec = new DefaultWindowsResourceCompileSpec();
    spec.setTempDir(getTemporaryDir());
    spec.setObjectFileDir(getOutputDir());
    spec.include(getIncludes());
    spec.source(getSource());
    spec.setMacros(getMacros());
    spec.args(getCompilerArgs());
    spec.setIncrementalCompile(inputs.isIncremental());
    spec.setOperationLogger(operationLogger);
    NativeToolChainInternal nativeToolChain = (NativeToolChainInternal) toolChain.get();
    NativePlatformInternal nativePlatform = (NativePlatformInternal) targetPlatform.get();
    PlatformToolProvider platformToolProvider = nativeToolChain.select(nativePlatform);
    WorkResult result = doCompile(spec, platformToolProvider);
    setDidWork(result.getDidWork());
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) BuildOperationLogger(org.gradle.internal.operations.logging.BuildOperationLogger) DefaultWindowsResourceCompileSpec(org.gradle.language.rc.internal.DefaultWindowsResourceCompileSpec) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) NativeCompileSpec(org.gradle.nativeplatform.toolchain.internal.NativeCompileSpec) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal) WorkResult(org.gradle.api.tasks.WorkResult) TaskAction(org.gradle.api.tasks.TaskAction)

Example 7 with WorkResult

use of org.gradle.api.tasks.WorkResult in project gradle by gradle.

the class IncrementalSwiftCompiler method execute.

@Override
public WorkResult execute(SwiftCompileSpec spec) {
    final boolean didRemove;
    if (spec.isIncrementalCompile()) {
        didRemove = deleteOutputsForRemovedSources(spec);
    } else {
        didRemove = cleanPreviousOutputs(spec);
    }
    WorkResult compileResult = compile(spec);
    return WorkResults.didWork(didRemove || compileResult.getDidWork());
}
Also used : WorkResult(org.gradle.api.tasks.WorkResult)

Example 8 with WorkResult

use of org.gradle.api.tasks.WorkResult in project gradle by gradle.

the class AbstractLinkTask method link.

@TaskAction
public void link() {
    SimpleStaleClassCleaner cleaner = new SimpleStaleClassCleaner(getOutputs());
    cleaner.setDestinationDir(getDestinationDirectory().get().getAsFile());
    cleaner.execute();
    if (getSource().isEmpty()) {
        setDidWork(cleaner.getDidWork());
        return;
    }
    LinkerSpec spec = createLinkerSpec();
    spec.setTargetPlatform(getTargetPlatform().get());
    spec.setTempDir(getTemporaryDir());
    spec.setOutputFile(getLinkedFile().get().getAsFile());
    spec.objectFiles(getSource());
    spec.libraries(getLibs());
    spec.args(getLinkerArgs().get());
    spec.setDebuggable(getDebuggable().get());
    BuildOperationLogger operationLogger = getOperationLoggerFactory().newOperationLogger(getName(), getTemporaryDir());
    spec.setOperationLogger(operationLogger);
    Compiler<LinkerSpec> compiler = createCompiler();
    compiler = BuildOperationLoggingCompilerDecorator.wrap(compiler);
    WorkResult result = compiler.execute(spec);
    setDidWork(result.getDidWork());
}
Also used : LinkerSpec(org.gradle.nativeplatform.internal.LinkerSpec) BuildOperationLogger(org.gradle.internal.operations.logging.BuildOperationLogger) WorkResult(org.gradle.api.tasks.WorkResult) SimpleStaleClassCleaner(org.gradle.language.base.internal.tasks.SimpleStaleClassCleaner) TaskAction(org.gradle.api.tasks.TaskAction)

Example 9 with WorkResult

use of org.gradle.api.tasks.WorkResult in project gradle by gradle.

the class ExtractSymbols method extractSymbols.

// TODO: Need to track version/implementation of symbol extraction tool.
@TaskAction
public void extractSymbols() {
    BuildOperationLogger operationLogger = getServices().get(BuildOperationLoggerFactory.class).newOperationLogger(getName(), getTemporaryDir());
    SymbolExtractorSpec spec = new DefaultSymbolExtractorSpec();
    spec.setBinaryFile(binaryFile.get().getAsFile());
    spec.setSymbolFile(symbolFile.get().getAsFile());
    spec.setOperationLogger(operationLogger);
    Compiler<SymbolExtractorSpec> symbolExtractor = createCompiler();
    symbolExtractor = BuildOperationLoggingCompilerDecorator.wrap(symbolExtractor);
    WorkResult result = symbolExtractor.execute(spec);
    setDidWork(result.getDidWork());
}
Also used : DefaultSymbolExtractorSpec(org.gradle.nativeplatform.internal.DefaultSymbolExtractorSpec) BuildOperationLoggerFactory(org.gradle.internal.operations.logging.BuildOperationLoggerFactory) BuildOperationLogger(org.gradle.internal.operations.logging.BuildOperationLogger) WorkResult(org.gradle.api.tasks.WorkResult) SymbolExtractorSpec(org.gradle.nativeplatform.internal.SymbolExtractorSpec) DefaultSymbolExtractorSpec(org.gradle.nativeplatform.internal.DefaultSymbolExtractorSpec) TaskAction(org.gradle.api.tasks.TaskAction)

Example 10 with WorkResult

use of org.gradle.api.tasks.WorkResult in project gradle by gradle.

the class NormalizingCopyActionDecorator method execute.

public WorkResult execute(final CopyActionProcessingStream stream) {
    final Set<RelativePath> visitedDirs = new HashSet<RelativePath>();
    final ListMultimap<RelativePath, FileCopyDetailsInternal> pendingDirs = ArrayListMultimap.create();
    WorkResult result = delegate.execute(new CopyActionProcessingStream() {

        public void process(final CopyActionProcessingStreamAction action) {
            stream.process(new CopyActionProcessingStreamAction() {

                public void processFile(FileCopyDetailsInternal details) {
                    if (details.isDirectory()) {
                        RelativePath path = details.getRelativePath();
                        if (!visitedDirs.contains(path)) {
                            pendingDirs.put(path, details);
                        }
                    } else {
                        maybeVisit(details.getRelativePath().getParent(), details.isIncludeEmptyDirs(), action);
                        action.processFile(details);
                    }
                }
            });
            for (RelativePath path : new LinkedHashSet<RelativePath>(pendingDirs.keySet())) {
                List<FileCopyDetailsInternal> detailsList = new ArrayList<FileCopyDetailsInternal>(pendingDirs.get(path));
                for (FileCopyDetailsInternal details : detailsList) {
                    if (details.isIncludeEmptyDirs()) {
                        maybeVisit(path, details.isIncludeEmptyDirs(), action);
                    }
                }
            }
            visitedDirs.clear();
            pendingDirs.clear();
        }

        private void maybeVisit(RelativePath path, boolean includeEmptyDirs, CopyActionProcessingStreamAction delegateAction) {
            if (path == null || path.getParent() == null || !visitedDirs.add(path)) {
                return;
            }
            maybeVisit(path.getParent(), includeEmptyDirs, delegateAction);
            List<FileCopyDetailsInternal> detailsForPath = pendingDirs.removeAll(path);
            FileCopyDetailsInternal dir;
            if (detailsForPath.isEmpty()) {
                // TODO - this is pretty nasty, look at avoiding using a time bomb stub here
                dir = new StubbedFileCopyDetails(path, includeEmptyDirs, chmod);
            } else {
                dir = detailsForPath.get(0);
            }
            delegateAction.processFile(dir);
        }
    });
    return result;
}
Also used : RelativePath(org.gradle.api.file.RelativePath) WorkResult(org.gradle.api.tasks.WorkResult) CopyActionProcessingStreamAction(org.gradle.api.internal.file.CopyActionProcessingStreamAction)

Aggregations

WorkResult (org.gradle.api.tasks.WorkResult)17 TaskAction (org.gradle.api.tasks.TaskAction)8 BuildOperationLogger (org.gradle.internal.operations.logging.BuildOperationLogger)7 BuildOperationLoggerFactory (org.gradle.internal.operations.logging.BuildOperationLoggerFactory)3 NativePlatformInternal (org.gradle.nativeplatform.platform.internal.NativePlatformInternal)3 RelativePath (org.gradle.api.file.RelativePath)2 CopyActionProcessingStreamAction (org.gradle.api.internal.file.CopyActionProcessingStreamAction)2 SimpleStaleClassCleaner (org.gradle.language.base.internal.tasks.SimpleStaleClassCleaner)2 NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)2 File (java.io.File)1 HashSet (java.util.HashSet)1 FileTree (org.gradle.api.file.FileTree)1 MinimalFileTree (org.gradle.api.internal.file.collections.MinimalFileTree)1 DefaultGroovyJavaJointCompileSpec (org.gradle.api.internal.tasks.compile.DefaultGroovyJavaJointCompileSpec)1 OutputFile (org.gradle.api.tasks.OutputFile)1 InputFileDetails (org.gradle.api.tasks.incremental.InputFileDetails)1 PatternFilterable (org.gradle.api.tasks.util.PatternFilterable)1 PatternSet (org.gradle.api.tasks.util.PatternSet)1 DefaultAssembleSpec (org.gradle.language.assembler.internal.DefaultAssembleSpec)1 DefaultWindowsResourceCompileSpec (org.gradle.language.rc.internal.DefaultWindowsResourceCompileSpec)1