Search in sources :

Example 1 with CommandLineToolInvocation

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

the class ArStaticLibraryArchiver method execute.

@Override
public WorkResult execute(final StaticLibraryArchiverSpec spec) {
    deletePreviousOutput(spec);
    List<String> args = argsTransformer.transform(spec);
    invocationContext.getArgAction().execute(args);
    final CommandLineToolInvocation invocation = invocationContext.createInvocation("archiving " + spec.getOutputFile().getName(), args, spec.getOperationLogger());
    buildOperationProcessor.run(commandLineToolInvocationWorker, new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

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

Example 2 with CommandLineToolInvocation

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

the class GccLinker method execute.

@Override
public WorkResult execute(final LinkerSpec spec) {
    List<String> args = argsTransformer.transform(spec);
    invocationContext.getArgAction().execute(args);
    if (useCommandFile) {
        new GccOptionsFileArgsWriter(spec.getTempDir()).execute(args);
    }
    final CommandLineToolInvocation invocation = invocationContext.createInvocation("linking " + spec.getOutputFile().getName(), args, spec.getOperationLogger());
    buildOperationProcessor.run(commandLineToolInvocationWorker, new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

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

Example 3 with CommandLineToolInvocation

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

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

use of org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation 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)9 CommandLineToolInvocation (org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation)9 Action (org.gradle.api.Action)6 SimpleWorkResult (org.gradle.api.internal.tasks.SimpleWorkResult)3 File (java.io.File)1 Transformer (org.gradle.api.Transformer)1 StaticLibraryArchiverSpec (org.gradle.nativeplatform.internal.StaticLibraryArchiverSpec)1 ArgsTransformer (org.gradle.nativeplatform.toolchain.internal.ArgsTransformer)1