use of org.gradle.nativeplatform.toolchain.internal.PreCompiledHeader in project gradle by gradle.
the class PCHCompileTaskConfig method configureCompileTask.
@Override
protected void configureCompileTask(AbstractNativeCompileTask task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal languageSourceSet) {
// Note that the sourceSet is the sourceSet this pre-compiled header will be used with - it's not an
// input sourceSet to the compile task.
final DependentSourceSetInternal sourceSet = (DependentSourceSetInternal) languageSourceSet;
task.setDescription("Compiles a pre-compiled header for the " + sourceSet + " of " + binary);
// Add the source of the source set to the include paths to resolve any headers that may be in source directories
task.includes(sourceSet.getSource().getSourceDirectories());
final Project project = task.getProject();
task.source(sourceSet.getPrefixHeaderFile());
task.getObjectFileDir().set(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), languageSourceSet.getProjectScopedName() + "PCH"));
task.dependsOn(project.getTasks().withType(PrefixHeaderFileGenerateTask.class).matching(new Spec<PrefixHeaderFileGenerateTask>() {
@Override
public boolean isSatisfiedBy(PrefixHeaderFileGenerateTask prefixHeaderFileGenerateTask) {
return prefixHeaderFileGenerateTask.getPrefixHeaderFile().equals(sourceSet.getPrefixHeaderFile());
}
}));
// This is so that VisualCpp has the object file of the generated source file available at link time
binary.binaryInputs(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o")));
PreCompiledHeader pch = binary.getPrefixFileToPCH().get(sourceSet.getPrefixHeaderFile());
pch.setPchObjects(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.pch", "**/*.gch")));
pch.builtBy(task);
}
use of org.gradle.nativeplatform.toolchain.internal.PreCompiledHeader in project gradle by gradle.
the class SourceCompileTaskConfig method configureCompileTask.
@Override
protected void configureCompileTask(AbstractNativeCompileTask abstractTask, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) {
AbstractNativeSourceCompileTask task = (AbstractNativeSourceCompileTask) abstractTask;
task.setDescription("Compiles the " + sourceSet + " of " + binary);
task.source(sourceSet.getSource());
final Project project = task.getProject();
task.getObjectFileDir().set(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), sourceSet.getProjectScopedName()));
// If this task uses a pre-compiled header
if (sourceSet instanceof DependentSourceSetInternal && ((DependentSourceSetInternal) sourceSet).getPreCompiledHeader() != null) {
final DependentSourceSetInternal dependentSourceSet = (DependentSourceSetInternal) sourceSet;
PreCompiledHeader pch = binary.getPrefixFileToPCH().get(dependentSourceSet.getPrefixHeaderFile());
pch.setPrefixHeaderFile(dependentSourceSet.getPrefixHeaderFile());
pch.setIncludeString(dependentSourceSet.getPreCompiledHeader());
task.setPreCompiledHeader(pch);
}
binary.binaryInputs(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o")));
}
Aggregations