use of org.gradle.nativeplatform.tasks.PrefixHeaderFileGenerateTask 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);
}
Aggregations