Search in sources :

Example 1 with PrefixHeaderFileGenerateTask

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);
}
Also used : Project(org.gradle.api.Project) PrefixHeaderFileGenerateTask(org.gradle.nativeplatform.tasks.PrefixHeaderFileGenerateTask) PreCompiledHeader(org.gradle.nativeplatform.toolchain.internal.PreCompiledHeader) Spec(org.gradle.api.specs.Spec) ObjectFile(org.gradle.nativeplatform.ObjectFile) File(java.io.File) PatternSet(org.gradle.api.tasks.util.PatternSet)

Aggregations

File (java.io.File)1 Project (org.gradle.api.Project)1 Spec (org.gradle.api.specs.Spec)1 PatternSet (org.gradle.api.tasks.util.PatternSet)1 ObjectFile (org.gradle.nativeplatform.ObjectFile)1 PrefixHeaderFileGenerateTask (org.gradle.nativeplatform.tasks.PrefixHeaderFileGenerateTask)1 PreCompiledHeader (org.gradle.nativeplatform.toolchain.internal.PreCompiledHeader)1