Search in sources :

Example 6 with BuildOperationQueue

use of org.gradle.internal.operations.BuildOperationQueue in project gradle by gradle.

the class SwiftCompiler method newInvocationAction.

@Override
protected Action<BuildOperationQueue<CommandLineToolInvocation>> newInvocationAction(final SwiftCompileSpec spec, final List<String> genericArgs) {
    final File objectDir = spec.getObjectFileDir();
    return new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

        @Override
        public void execute(BuildOperationQueue<CommandLineToolInvocation> buildQueue) {
            buildQueue.setLogLocation(spec.getOperationLogger().getLogLocation());
            OutputFileMap outputFileMap = new OutputFileMap();
            File moduleSwiftDeps = new File(objectDir, "module.swiftdeps");
            outputFileMap.root().swiftDependenciesFile(moduleSwiftDeps);
            for (File sourceFile : spec.getSourceFiles()) {
                outputFileMap.newEntry(sourceFile.getAbsolutePath()).dependencyFile(getOutputFileDir(sourceFile, objectDir, ".d")).diagnosticsFile(getOutputFileDir(sourceFile, objectDir, ".dia")).objectFile(getOutputFileDir(sourceFile, objectDir, objectFileExtension)).swiftModuleFile(getOutputFileDir(sourceFile, objectDir, "~partial.swiftmodule")).swiftDependenciesFile(getOutputFileDir(sourceFile, objectDir, ".swiftdeps"));
                genericArgs.add(sourceFile.getAbsolutePath());
            }
            if (null != spec.getModuleName()) {
                genericArgs.add("-module-name");
                genericArgs.add(spec.getModuleName());
                genericArgs.add("-emit-module-path");
                genericArgs.add(spec.getModuleFile().getAbsolutePath());
            }
            boolean canSafelyCompileIncrementally = swiftDepsHandler.adjustTimestampsFor(moduleSwiftDeps, spec.getChangedFiles());
            if (canSafelyCompileIncrementally) {
                genericArgs.add("-incremental");
                genericArgs.add("-emit-dependencies");
            }
            genericArgs.add("-emit-object");
            File outputFileMapFile = new File(spec.getObjectFileDir(), "output-file-map.json");
            outputFileMap.writeToFile(outputFileMapFile);
            List<String> outputArgs = Lists.newArrayList();
            outputArgs.add("-output-file-map");
            outputArgs.add(outputFileMapFile.getAbsolutePath());
            List<String> importRootArgs = Lists.newArrayList();
            for (File importRoot : spec.getIncludeRoots()) {
                importRootArgs.add("-I");
                importRootArgs.add(importRoot.getAbsolutePath());
            }
            if (spec.isDebuggable()) {
                genericArgs.add("-g");
            }
            if (spec.isOptimized()) {
                genericArgs.add("-O");
            }
            genericArgs.addAll(CollectionUtils.collect(spec.getMacros().keySet(), new Transformer<String, String>() {

                @Override
                public String transform(String macro) {
                    return "-D" + macro;
                }
            }));
            genericArgs.add("-swift-version");
            genericArgs.add(String.valueOf(spec.getSourceCompatibility().getVersion()));
            CommandLineToolInvocation perFileInvocation = newInvocation("compiling swift file(s)", objectDir, Iterables.concat(genericArgs, outputArgs, importRootArgs), spec.getOperationLogger());
            perFileInvocation.getEnvironment().put("TMPDIR", spec.getTempDir().getAbsolutePath());
            buildQueue.add(perFileInvocation);
        }
    };
}
Also used : Action(org.gradle.api.Action) Transformer(org.gradle.api.Transformer) ArgsTransformer(org.gradle.nativeplatform.toolchain.internal.ArgsTransformer) CommandLineToolInvocation(org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue) File(java.io.File)

Example 7 with BuildOperationQueue

use of org.gradle.internal.operations.BuildOperationQueue in project gradle by gradle.

the class NativeCompiler method newInvocationAction.

// TODO(daniel): Should support in a better way multi file invocation.
protected Action<BuildOperationQueue<CommandLineToolInvocation>> newInvocationAction(final T spec, final List<String> genericArgs) {
    final File objectDir = spec.getObjectFileDir();
    return new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

        @Override
        public void execute(BuildOperationQueue<CommandLineToolInvocation> buildQueue) {
            buildQueue.setLogLocation(spec.getOperationLogger().getLogLocation());
            for (File sourceFile : spec.getSourceFiles()) {
                CommandLineToolInvocation perFileInvocation = createPerFileInvocation(genericArgs, sourceFile, objectDir, spec);
                buildQueue.add(perFileInvocation);
            }
        }
    };
}
Also used : Action(org.gradle.api.Action) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue) File(java.io.File)

Example 8 with BuildOperationQueue

use of org.gradle.internal.operations.BuildOperationQueue in project gradle by gradle.

the class ArStaticLibraryArchiver method newInvocationAction.

@Override
protected Action<BuildOperationQueue<CommandLineToolInvocation>> newInvocationAction(final StaticLibraryArchiverSpec spec, List<String> args) {
    final CommandLineToolInvocation invocation = newInvocation("archiving " + spec.getOutputFile().getName(), spec.getOutputFile().getParentFile(), args, spec.getOperationLogger());
    return new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

        @Override
        public void execute(BuildOperationQueue<CommandLineToolInvocation> buildQueue) {
            buildQueue.setLogLocation(spec.getOperationLogger().getLogLocation());
            buildQueue.add(invocation);
        }
    };
}
Also used : Action(org.gradle.api.Action) CommandLineToolInvocation(org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue)

Example 9 with BuildOperationQueue

use of org.gradle.internal.operations.BuildOperationQueue in project gradle by gradle.

the class LibExeStaticLibraryArchiver method newInvocationAction.

@Override
protected Action<BuildOperationQueue<CommandLineToolInvocation>> newInvocationAction(final StaticLibraryArchiverSpec spec, List<String> args) {
    final CommandLineToolInvocation invocation = newInvocation("archiving " + spec.getOutputFile().getName(), spec.getOutputFile().getParentFile(), args, spec.getOperationLogger());
    return new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

        @Override
        public void execute(BuildOperationQueue<CommandLineToolInvocation> buildQueue) {
            buildQueue.setLogLocation(spec.getOperationLogger().getLogLocation());
            buildQueue.add(invocation);
        }
    };
}
Also used : Action(org.gradle.api.Action) CommandLineToolInvocation(org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue)

Example 10 with BuildOperationQueue

use of org.gradle.internal.operations.BuildOperationQueue in project gradle by gradle.

the class LinkExeLinker method newInvocationAction.

@Override
protected Action<BuildOperationQueue<CommandLineToolInvocation>> newInvocationAction(final LinkerSpec spec, List<String> args) {
    final CommandLineToolInvocation invocation = invocationContext.createInvocation("linking " + spec.getOutputFile().getName(), args, spec.getOperationLogger());
    return new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

        @Override
        public void execute(BuildOperationQueue<CommandLineToolInvocation> buildQueue) {
            buildQueue.setLogLocation(spec.getOperationLogger().getLogLocation());
            buildQueue.add(invocation);
        }
    };
}
Also used : Action(org.gradle.api.Action) CommandLineToolInvocation(org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue)

Aggregations

BuildOperationQueue (org.gradle.internal.operations.BuildOperationQueue)15 Action (org.gradle.api.Action)10 CommandLineToolInvocation (org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation)9 File (java.io.File)5 SimpleWorkResult (org.gradle.api.internal.tasks.SimpleWorkResult)5 IOException (java.io.IOException)2 GradleException (org.gradle.api.GradleException)2 BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)2 RunnableBuildOperation (org.gradle.internal.operations.RunnableBuildOperation)2 HtmlReportBuilder (org.gradle.reporting.HtmlReportBuilder)2 HtmlReportRenderer (org.gradle.reporting.HtmlReportRenderer)2 FilenameFilter (java.io.FilenameFilter)1 Transformer (org.gradle.api.Transformer)1 Timer (org.gradle.internal.time.Timer)1 LinkerSpec (org.gradle.nativeplatform.internal.LinkerSpec)1 SharedLibraryLinkerSpec (org.gradle.nativeplatform.internal.SharedLibraryLinkerSpec)1 StaticLibraryArchiverSpec (org.gradle.nativeplatform.internal.StaticLibraryArchiverSpec)1 ArgsTransformer (org.gradle.nativeplatform.toolchain.internal.ArgsTransformer)1