Search in sources :

Example 1 with HeaderExportingSourceSet

use of org.gradle.language.nativeplatform.HeaderExportingSourceSet in project gradle by gradle.

the class CompileTaskConfig method configureCompileTaskCommon.

private void configureCompileTaskCommon(final 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>>() {

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

                @Override
                public FileCollection transform(NativeDependencySet original) {
                    return original.getIncludeRoots();
                }
            });
        }
    });
    FileCollectionFactory fileCollectionFactory = ((ProjectInternal) task.getProject()).getServices().get(FileCollectionFactory.class);
    task.getSystemIncludes().from(fileCollectionFactory.create(new MinimalFileSet() {

        @Override
        public Set<File> getFiles() {
            PlatformToolProvider platformToolProvider = ((NativeToolChainInternal) binary.getToolChain()).select((NativePlatformInternal) binary.getTargetPlatform());
            ToolType toolType = languageTransform.getToolType();
            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) 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 2 with HeaderExportingSourceSet

use of org.gradle.language.nativeplatform.HeaderExportingSourceSet in project gradle by gradle.

the class DefaultVisualStudioProject method getHeaderFiles.

public List<File> getHeaderFiles() {
    Set<File> allHeaders = new LinkedHashSet<File>();
    for (LanguageSourceSet sourceSet : sources) {
        if (sourceSet instanceof HeaderExportingSourceSet) {
            HeaderExportingSourceSet exportingSourceSet = (HeaderExportingSourceSet) sourceSet;
            allHeaders.addAll(exportingSourceSet.getExportedHeaders().getFiles());
            allHeaders.addAll(exportingSourceSet.getImplicitHeaders().getFiles());
        }
    }
    return new ArrayList<File>(allHeaders);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) LanguageSourceSet(org.gradle.language.base.LanguageSourceSet) HeaderExportingSourceSet(org.gradle.language.nativeplatform.HeaderExportingSourceSet) ArrayList(java.util.ArrayList) XmlConfigFile(org.gradle.ide.visualstudio.XmlConfigFile) File(java.io.File)

Example 3 with HeaderExportingSourceSet

use of org.gradle.language.nativeplatform.HeaderExportingSourceSet in project gradle by gradle.

the class NativeSpecVisualStudioTargetBinary method getHeaderFiles.

@Override
public FileCollection getHeaderFiles() {
    Spec<LanguageSourceSet> filter = new Spec<LanguageSourceSet>() {

        @Override
        public boolean isSatisfiedBy(LanguageSourceSet sourceSet) {
            return sourceSet instanceof HeaderExportingSourceSet;
        }
    };
    Transformer<FileCollection, LanguageSourceSet> transform = new Transformer<FileCollection, LanguageSourceSet>() {

        @Override
        public FileCollection transform(LanguageSourceSet sourceSet) {
            HeaderExportingSourceSet exportingSourceSet = (HeaderExportingSourceSet) sourceSet;
            return exportingSourceSet.getExportedHeaders().plus(exportingSourceSet.getImplicitHeaders());
        }
    };
    return new LanguageSourceSetCollectionAdapter(getComponentName() + " header files", binary.getInputs(), filter, transform);
}
Also used : LanguageSourceSet(org.gradle.language.base.LanguageSourceSet) Transformer(org.gradle.api.Transformer) HeaderExportingSourceSet(org.gradle.language.nativeplatform.HeaderExportingSourceSet) SharedLibraryBinarySpec(org.gradle.nativeplatform.SharedLibraryBinarySpec) NativeTestSuiteBinarySpec(org.gradle.nativeplatform.test.NativeTestSuiteBinarySpec) StaticLibraryBinarySpec(org.gradle.nativeplatform.StaticLibraryBinarySpec) Spec(org.gradle.api.specs.Spec) NativeExecutableBinarySpec(org.gradle.nativeplatform.NativeExecutableBinarySpec) NativeBinarySpec(org.gradle.nativeplatform.NativeBinarySpec) FileCollection(org.gradle.api.file.FileCollection) CompositeFileCollection(org.gradle.api.internal.file.CompositeFileCollection)

Aggregations

HeaderExportingSourceSet (org.gradle.language.nativeplatform.HeaderExportingSourceSet)3 File (java.io.File)2 LinkedHashSet (java.util.LinkedHashSet)2 Transformer (org.gradle.api.Transformer)2 FileCollection (org.gradle.api.file.FileCollection)2 LanguageSourceSet (org.gradle.language.base.LanguageSourceSet)2 SharedLibraryBinarySpec (org.gradle.nativeplatform.SharedLibraryBinarySpec)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 CompositeFileCollection (org.gradle.api.internal.file.CompositeFileCollection)1 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)1 MinimalFileSet (org.gradle.api.internal.file.collections.MinimalFileSet)1 Spec (org.gradle.api.specs.Spec)1 XmlConfigFile (org.gradle.ide.visualstudio.XmlConfigFile)1 DependentSourceSet (org.gradle.language.nativeplatform.DependentSourceSet)1 NativeBinarySpec (org.gradle.nativeplatform.NativeBinarySpec)1 NativeDependencySet (org.gradle.nativeplatform.NativeDependencySet)1 NativeExecutableBinarySpec (org.gradle.nativeplatform.NativeExecutableBinarySpec)1 PreprocessingTool (org.gradle.nativeplatform.PreprocessingTool)1