Search in sources :

Example 1 with LanguageSourceSetInternal

use of org.gradle.language.base.internal.LanguageSourceSetInternal in project gradle by gradle.

the class WindowsResourcesCompileTaskConfig method configureResourceCompileTask.

private void configureResourceCompileTask(WindowsResourceCompile task, final NativeBinarySpecInternal binary, final WindowsResourceSet sourceSet) {
    task.setDescription("Compiles resources of the " + sourceSet + " of " + binary);
    task.getToolChain().set(binary.getToolChain());
    task.getTargetPlatform().set(binary.getTargetPlatform());
    task.includes(sourceSet.getExportedHeaders().getSourceDirectories());
    FileCollectionFactory fileCollectionFactory = ((ProjectInternal) task.getProject()).getServices().get(FileCollectionFactory.class);
    task.includes(fileCollectionFactory.create(new MinimalFileSet() {

        @Override
        public Set<File> getFiles() {
            PlatformToolProvider platformToolProvider = ((NativeToolChainInternal) binary.getToolChain()).select((NativePlatformInternal) binary.getTargetPlatform());
            return new LinkedHashSet<File>(platformToolProvider.getSystemLibraries(ToolType.WINDOW_RESOURCES_COMPILER).getIncludeDirs());
        }

        @Override
        public String getDisplayName() {
            return "System includes for " + binary.getToolChain().getDisplayName();
        }
    }));
    task.source(sourceSet.getSource());
    final Project project = task.getProject();
    task.setOutputDir(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), ((LanguageSourceSetInternal) sourceSet).getProjectScopedName()));
    PreprocessingTool rcCompiler = (PreprocessingTool) binary.getToolByName("rcCompiler");
    task.setMacros(rcCompiler.getMacros());
    task.getCompilerArgs().set(rcCompiler.getArgs());
    FileTree resourceOutputs = task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.res"));
    binary.binaryInputs(resourceOutputs);
    if (binary instanceof StaticLibraryBinarySpecInternal) {
        ((StaticLibraryBinarySpecInternal) binary).additionalLinkFiles(resourceOutputs);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) Project(org.gradle.api.Project) LanguageSourceSetInternal(org.gradle.language.base.internal.LanguageSourceSetInternal) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) PreprocessingTool(org.gradle.nativeplatform.PreprocessingTool) FileTree(org.gradle.api.file.FileTree) StaticLibraryBinarySpecInternal(org.gradle.nativeplatform.internal.StaticLibraryBinarySpecInternal) MinimalFileSet(org.gradle.api.internal.file.collections.MinimalFileSet) File(java.io.File) PatternSet(org.gradle.api.tasks.util.PatternSet) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory)

Example 2 with LanguageSourceSetInternal

use of org.gradle.language.base.internal.LanguageSourceSetInternal in project gradle by gradle.

the class BinarySourceTransformations method createTasksFor.

public void createTasksFor(BinarySpecInternal binary) {
    Set<LanguageSourceSetInternal> sourceSetsToCompile = getSourcesToCompile(binary);
    for (LanguageTransform<?, ?> languageTransform : prioritizedTransforms) {
        if (!languageTransform.applyToBinary(binary)) {
            continue;
        }
        LanguageSourceSetInternal sourceSetToCompile;
        while ((sourceSetToCompile = findSourceFor(languageTransform, sourceSetsToCompile)) != null) {
            sourceSetsToCompile.remove(sourceSetToCompile);
            final SourceTransformTaskConfig taskConfig = languageTransform.getTransformTask();
            String taskName = getTransformTaskName(languageTransform, taskConfig, binary, sourceSetToCompile);
            Task task = tasks.create(taskName, taskConfig.getTaskType());
            taskConfig.configureTask(task, binary, sourceSetToCompile, serviceRegistry);
            task.dependsOn(sourceSetToCompile);
            binary.getTasks().add(task);
            if (binary.hasCodependentSources() && taskConfig instanceof JointCompileTaskConfig) {
                JointCompileTaskConfig jointCompileTaskConfig = (JointCompileTaskConfig) taskConfig;
                Iterator<LanguageSourceSetInternal> candidateSourceSets = sourceSetsToCompile.iterator();
                while (candidateSourceSets.hasNext()) {
                    LanguageSourceSetInternal candidate = candidateSourceSets.next();
                    if (jointCompileTaskConfig.canTransform(candidate)) {
                        jointCompileTaskConfig.configureAdditionalTransform(task, candidate);
                        candidateSourceSets.remove();
                    }
                }
            }
        }
    }
// Should really fail here if sourcesToCompile is not empty: no transform for this source set in this binary
}
Also used : LanguageSourceSetInternal(org.gradle.language.base.internal.LanguageSourceSetInternal) Task(org.gradle.api.Task) SourceTransformTaskConfig(org.gradle.language.base.internal.SourceTransformTaskConfig) JointCompileTaskConfig(org.gradle.language.base.internal.JointCompileTaskConfig)

Aggregations

LanguageSourceSetInternal (org.gradle.language.base.internal.LanguageSourceSetInternal)2 File (java.io.File)1 LinkedHashSet (java.util.LinkedHashSet)1 Project (org.gradle.api.Project)1 Task (org.gradle.api.Task)1 FileTree (org.gradle.api.file.FileTree)1 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)1 MinimalFileSet (org.gradle.api.internal.file.collections.MinimalFileSet)1 PatternSet (org.gradle.api.tasks.util.PatternSet)1 JointCompileTaskConfig (org.gradle.language.base.internal.JointCompileTaskConfig)1 SourceTransformTaskConfig (org.gradle.language.base.internal.SourceTransformTaskConfig)1 PreprocessingTool (org.gradle.nativeplatform.PreprocessingTool)1 StaticLibraryBinarySpecInternal (org.gradle.nativeplatform.internal.StaticLibraryBinarySpecInternal)1 NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)1 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)1