Search in sources :

Example 1 with FileCollectionFactory

use of org.gradle.api.internal.file.FileCollectionFactory in project gradle by gradle.

the class AssembleTaskConfig method configureAssembleTask.

private void configureAssembleTask(Assemble task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) {
    task.setDescription("Assembles the " + sourceSet + " of " + binary);
    task.getToolChain().set(binary.getToolChain());
    task.getTargetPlatform().set(binary.getTargetPlatform());
    task.source(sourceSet.getSource());
    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.ASSEMBLER).getIncludeDirs());
        }

        @Override
        public String getDisplayName() {
            return "System includes for " + binary.getToolChain().getDisplayName();
        }
    }));
    final Project project = task.getProject();
    task.setObjectFileDir(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), sourceSet.getProjectScopedName()));
    Tool assemblerTool = binary.getToolByName("assembler");
    task.setAssemblerArgs(assemblerTool.getArgs());
    binary.binaryInputs(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o")));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) Project(org.gradle.api.Project) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) 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) Tool(org.gradle.nativeplatform.Tool)

Example 2 with FileCollectionFactory

use of org.gradle.api.internal.file.FileCollectionFactory in project gradle by gradle.

the class CompileTaskConfig method configureCompileTaskCommon.

private void configureCompileTaskCommon(AbstractNativeCompileTask task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) {
    task.getToolChain().set(binary.getToolChain());
    task.getTargetPlatform().set(binary.getTargetPlatform());
    task.setPositionIndependentCode(binary instanceof SharedLibraryBinarySpec);
    task.includes(((HeaderExportingSourceSet) sourceSet).getExportedHeaders().getSourceDirectories());
    task.includes(new Callable<List<FileCollection>>() {

        public List<FileCollection> call() {
            Collection<NativeDependencySet> libs = binary.getLibs((DependentSourceSet) sourceSet);
            return CollectionUtils.collect(libs, new Transformer<FileCollection, NativeDependencySet>() {

                public FileCollection transform(NativeDependencySet original) {
                    return original.getIncludeRoots();
                }
            });
        }
    });
    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());
            ToolType toolType = determineToolType(languageTransform.getLanguageName());
            return new LinkedHashSet<File>(platformToolProvider.getSystemLibraries(toolType).getIncludeDirs());
        }

        @Override
        public String getDisplayName() {
            return "System includes for " + binary.getToolChain().getDisplayName();
        }
    }));
    for (String toolName : languageTransform.getBinaryTools().keySet()) {
        Tool tool = binary.getToolByName(toolName);
        if (tool instanceof PreprocessingTool) {
            task.setMacros(((PreprocessingTool) tool).getMacros());
        }
        task.getCompilerArgs().set(tool.getArgs());
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Transformer(org.gradle.api.Transformer) PreprocessingTool(org.gradle.nativeplatform.PreprocessingTool) ToolType(org.gradle.nativeplatform.toolchain.internal.ToolType) SharedLibraryBinarySpec(org.gradle.nativeplatform.SharedLibraryBinarySpec) MinimalFileSet(org.gradle.api.internal.file.collections.MinimalFileSet) NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) DependentSourceSet(org.gradle.language.nativeplatform.DependentSourceSet) HeaderExportingSourceSet(org.gradle.language.nativeplatform.HeaderExportingSourceSet) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) FileCollection(org.gradle.api.file.FileCollection) Collection(java.util.Collection) List(java.util.List) ObjectFile(org.gradle.nativeplatform.ObjectFile) File(java.io.File) NativeDependencySet(org.gradle.nativeplatform.NativeDependencySet) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory) PreprocessingTool(org.gradle.nativeplatform.PreprocessingTool) Tool(org.gradle.nativeplatform.Tool)

Example 3 with FileCollectionFactory

use of org.gradle.api.internal.file.FileCollectionFactory 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.setCompilerArgs(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)

Aggregations

File (java.io.File)3 LinkedHashSet (java.util.LinkedHashSet)3 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)3 MinimalFileSet (org.gradle.api.internal.file.collections.MinimalFileSet)3 NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)3 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)3 Project (org.gradle.api.Project)2 PatternSet (org.gradle.api.tasks.util.PatternSet)2 PreprocessingTool (org.gradle.nativeplatform.PreprocessingTool)2 Tool (org.gradle.nativeplatform.Tool)2 Collection (java.util.Collection)1 List (java.util.List)1 Transformer (org.gradle.api.Transformer)1 FileCollection (org.gradle.api.file.FileCollection)1 FileTree (org.gradle.api.file.FileTree)1 LanguageSourceSetInternal (org.gradle.language.base.internal.LanguageSourceSetInternal)1 DependentSourceSet (org.gradle.language.nativeplatform.DependentSourceSet)1 HeaderExportingSourceSet (org.gradle.language.nativeplatform.HeaderExportingSourceSet)1 NativeDependencySet (org.gradle.nativeplatform.NativeDependencySet)1 ObjectFile (org.gradle.nativeplatform.ObjectFile)1