Search in sources :

Example 6 with PlatformToolProvider

use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.

the class NativeBasePlugin method addTasksForComponentWithExecutable.

private void addTasksForComponentWithExecutable(final TaskContainer tasks, final DirectoryProperty buildDirectory, SoftwareComponentContainer components) {
    components.withType(ConfigurableComponentWithExecutable.class, executable -> {
        final Names names = executable.getNames();
        final NativeToolChain toolChain = executable.getToolChain();
        final NativePlatform targetPlatform = executable.getNativePlatform();
        final PlatformToolProvider toolProvider = executable.getPlatformToolProvider();
        // Add a link task
        TaskProvider<LinkExecutable> link = tasks.register(names.getTaskName("link"), LinkExecutable.class, task -> {
            task.source(executable.getObjects());
            task.lib(executable.getLinkLibraries());
            task.getLinkedFile().set(buildDirectory.file(executable.getBaseName().map(baseName -> toolProvider.getExecutableName("exe/" + names.getDirName() + baseName))));
            task.getTargetPlatform().set(targetPlatform);
            task.getToolChain().set(toolChain);
            task.getDebuggable().set(executable.isDebuggable());
        });
        executable.getLinkTask().set(link);
        executable.getDebuggerExecutableFile().set(link.flatMap(linkExecutable -> linkExecutable.getLinkedFile()));
        if (executable.isDebuggable() && executable.isOptimized() && toolProvider.requiresDebugBinaryStripping()) {
            Provider<RegularFile> symbolLocation = buildDirectory.file(executable.getBaseName().map(baseName -> toolProvider.getExecutableSymbolFileName("exe/" + names.getDirName() + "stripped/" + baseName)));
            Provider<RegularFile> strippedLocation = buildDirectory.file(executable.getBaseName().map(baseName -> toolProvider.getExecutableName("exe/" + names.getDirName() + "stripped/" + baseName)));
            TaskProvider<StripSymbols> stripSymbols = stripSymbols(link, names, tasks, toolChain, targetPlatform, strippedLocation);
            executable.getExecutableFile().set(stripSymbols.flatMap(task -> task.getOutputFile()));
            TaskProvider<ExtractSymbols> extractSymbols = extractSymbols(link, names, tasks, toolChain, targetPlatform, symbolLocation);
            executable.getOutputs().from(extractSymbols.flatMap(task -> task.getSymbolFile()));
            executable.getExecutableFileProducer().set(stripSymbols);
        } else {
            executable.getExecutableFile().set(link.flatMap(task -> task.getLinkedFile()));
            executable.getExecutableFileProducer().set(link);
        }
        // Add an install task
        // TODO - should probably not add this for all executables?
        // TODO - add stripped symbols to the installation
        final TaskProvider<InstallExecutable> install = tasks.register(names.getTaskName("install"), InstallExecutable.class, task -> {
            task.getTargetPlatform().set(targetPlatform);
            task.getToolChain().set(toolChain);
            task.getInstallDirectory().set(buildDirectory.dir("install/" + names.getDirName()));
            task.getExecutableFile().set(executable.getExecutableFile());
            task.lib(executable.getRuntimeLibraries());
        });
        executable.getInstallTask().set(install);
        executable.getInstallDirectory().set(install.flatMap(task -> task.getInstallDirectory()));
        executable.getOutputs().from(executable.getInstallDirectory());
        executable.getDebuggerExecutableFile().set(install.flatMap(task -> task.getInstalledExecutable()));
    });
}
Also used : ConfigurableComponentWithRuntimeUsage(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithRuntimeUsage) ConfigurableComponentWithSharedLibrary(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithSharedLibrary) ComponentWithVariants(org.gradle.api.component.ComponentWithVariants) LinkSharedLibrary(org.gradle.nativeplatform.tasks.LinkSharedLibrary) ComponentWithBinaries(org.gradle.language.ComponentWithBinaries) Task(org.gradle.api.Task) Provider(org.gradle.api.provider.Provider) PublishingExtension(org.gradle.api.publish.PublishingExtension) ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) MultipleCandidatesDetails(org.gradle.api.attributes.MultipleCandidatesDetails) TaskProvider(org.gradle.api.tasks.TaskProvider) TargetMachineFactory(org.gradle.nativeplatform.TargetMachineFactory) Linkage(org.gradle.nativeplatform.Linkage) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) UnzipTransform(org.gradle.api.internal.artifacts.transform.UnzipTransform) Incubating(org.gradle.api.Incubating) SoftwareComponentContainer(org.gradle.api.component.SoftwareComponentContainer) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) Project(org.gradle.api.Project) TargetMachine(org.gradle.nativeplatform.TargetMachine) ComponentWithNames(org.gradle.language.nativeplatform.internal.ComponentWithNames) Set(java.util.Set) MutableMavenProjectIdentity(org.gradle.api.publish.maven.internal.publisher.MutableMavenProjectIdentity) DIRECTORY_TYPE(org.gradle.api.artifacts.type.ArtifactTypeDefinition.DIRECTORY_TYPE) AttributeDisambiguationRule(org.gradle.api.attributes.AttributeDisambiguationRule) TaskContainer(org.gradle.api.tasks.TaskContainer) AbstractLinkTask(org.gradle.nativeplatform.tasks.AbstractLinkTask) ArtifactTypeDefinition(org.gradle.api.artifacts.type.ArtifactTypeDefinition) Names(org.gradle.language.nativeplatform.internal.Names) SoftwareComponent(org.gradle.api.component.SoftwareComponent) NativeToolChain(org.gradle.nativeplatform.toolchain.NativeToolChain) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal) CreateStaticLibrary(org.gradle.nativeplatform.tasks.CreateStaticLibrary) ZIP_TYPE(org.gradle.api.artifacts.type.ArtifactTypeDefinition.ZIP_TYPE) ConfigurableComponentWithStaticLibrary(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithStaticLibrary) StripSymbols(org.gradle.nativeplatform.tasks.StripSymbols) PublishableComponent(org.gradle.api.component.PublishableComponent) Callable(java.util.concurrent.Callable) MavenPublication(org.gradle.api.publish.maven.MavenPublication) NativePlatform(org.gradle.nativeplatform.platform.NativePlatform) FileCollection(org.gradle.api.file.FileCollection) ProductionComponent(org.gradle.language.ProductionComponent) ExtractSymbols(org.gradle.nativeplatform.tasks.ExtractSymbols) LinkExecutable(org.gradle.nativeplatform.tasks.LinkExecutable) Inject(javax.inject.Inject) Configuration(org.gradle.api.artifacts.Configuration) LifecycleBasePlugin(org.gradle.language.base.plugins.LifecycleBasePlugin) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) AttributeContainer(org.gradle.api.attributes.AttributeContainer) DefaultTargetMachineFactory(org.gradle.nativeplatform.internal.DefaultTargetMachineFactory) Attribute(org.gradle.api.attributes.Attribute) DirectoryProperty(org.gradle.api.file.DirectoryProperty) DomainObjectSet(org.gradle.api.DomainObjectSet) Usage(org.gradle.api.attributes.Usage) ConfigurableComponentWithLinkUsage(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithLinkUsage) ConfigurableComponentWithExecutable(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithExecutable) PublicationAwareComponent(org.gradle.language.nativeplatform.internal.PublicationAwareComponent) InstallExecutable(org.gradle.nativeplatform.tasks.InstallExecutable) ComponentWithTargetMachines(org.gradle.language.ComponentWithTargetMachines) Cast(org.gradle.internal.Cast) LINKAGE_ATTRIBUTE(org.gradle.language.cpp.CppBinary.LINKAGE_ATTRIBUTE) ObjectFactory(org.gradle.api.model.ObjectFactory) RegularFile(org.gradle.api.file.RegularFile) ComponentWithOutputs(org.gradle.language.ComponentWithOutputs) Collections(java.util.Collections) Plugin(org.gradle.api.Plugin) RegularFile(org.gradle.api.file.RegularFile) NativeToolChain(org.gradle.nativeplatform.toolchain.NativeToolChain) ComponentWithNames(org.gradle.language.nativeplatform.internal.ComponentWithNames) Names(org.gradle.language.nativeplatform.internal.Names) LinkExecutable(org.gradle.nativeplatform.tasks.LinkExecutable) StripSymbols(org.gradle.nativeplatform.tasks.StripSymbols) ExtractSymbols(org.gradle.nativeplatform.tasks.ExtractSymbols) InstallExecutable(org.gradle.nativeplatform.tasks.InstallExecutable) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) NativePlatform(org.gradle.nativeplatform.platform.NativePlatform)

Example 7 with PlatformToolProvider

use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.

the class NativeBasePlugin method addTasksForComponentWithStaticLibrary.

private void addTasksForComponentWithStaticLibrary(final TaskContainer tasks, final DirectoryProperty buildDirectory, SoftwareComponentContainer components) {
    components.withType(ConfigurableComponentWithStaticLibrary.class, library -> {
        final Names names = library.getNames();
        // Add a create task
        final TaskProvider<CreateStaticLibrary> createTask = tasks.register(names.getTaskName("create"), CreateStaticLibrary.class, task -> {
            task.source(library.getObjects());
            final PlatformToolProvider toolProvider = library.getPlatformToolProvider();
            Provider<RegularFile> linktimeFile = buildDirectory.file(library.getBaseName().map(baseName -> toolProvider.getStaticLibraryName("lib/" + names.getDirName() + baseName)));
            task.getOutputFile().set(linktimeFile);
            task.getTargetPlatform().set(library.getNativePlatform());
            task.getToolChain().set(library.getToolChain());
        });
        // Wire the task into the library model
        library.getLinkFile().set(createTask.flatMap(task -> task.getBinaryFile()));
        library.getLinkFileProducer().set(createTask);
        library.getCreateTask().set(createTask);
        library.getOutputs().from(library.getLinkFile());
    });
}
Also used : ComponentWithNames(org.gradle.language.nativeplatform.internal.ComponentWithNames) Names(org.gradle.language.nativeplatform.internal.Names) ConfigurableComponentWithRuntimeUsage(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithRuntimeUsage) ConfigurableComponentWithSharedLibrary(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithSharedLibrary) ComponentWithVariants(org.gradle.api.component.ComponentWithVariants) LinkSharedLibrary(org.gradle.nativeplatform.tasks.LinkSharedLibrary) ComponentWithBinaries(org.gradle.language.ComponentWithBinaries) Task(org.gradle.api.Task) Provider(org.gradle.api.provider.Provider) PublishingExtension(org.gradle.api.publish.PublishingExtension) ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) MultipleCandidatesDetails(org.gradle.api.attributes.MultipleCandidatesDetails) TaskProvider(org.gradle.api.tasks.TaskProvider) TargetMachineFactory(org.gradle.nativeplatform.TargetMachineFactory) Linkage(org.gradle.nativeplatform.Linkage) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) UnzipTransform(org.gradle.api.internal.artifacts.transform.UnzipTransform) Incubating(org.gradle.api.Incubating) SoftwareComponentContainer(org.gradle.api.component.SoftwareComponentContainer) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) Project(org.gradle.api.Project) TargetMachine(org.gradle.nativeplatform.TargetMachine) ComponentWithNames(org.gradle.language.nativeplatform.internal.ComponentWithNames) Set(java.util.Set) MutableMavenProjectIdentity(org.gradle.api.publish.maven.internal.publisher.MutableMavenProjectIdentity) DIRECTORY_TYPE(org.gradle.api.artifacts.type.ArtifactTypeDefinition.DIRECTORY_TYPE) AttributeDisambiguationRule(org.gradle.api.attributes.AttributeDisambiguationRule) TaskContainer(org.gradle.api.tasks.TaskContainer) AbstractLinkTask(org.gradle.nativeplatform.tasks.AbstractLinkTask) ArtifactTypeDefinition(org.gradle.api.artifacts.type.ArtifactTypeDefinition) Names(org.gradle.language.nativeplatform.internal.Names) SoftwareComponent(org.gradle.api.component.SoftwareComponent) NativeToolChain(org.gradle.nativeplatform.toolchain.NativeToolChain) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal) CreateStaticLibrary(org.gradle.nativeplatform.tasks.CreateStaticLibrary) ZIP_TYPE(org.gradle.api.artifacts.type.ArtifactTypeDefinition.ZIP_TYPE) ConfigurableComponentWithStaticLibrary(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithStaticLibrary) StripSymbols(org.gradle.nativeplatform.tasks.StripSymbols) PublishableComponent(org.gradle.api.component.PublishableComponent) Callable(java.util.concurrent.Callable) MavenPublication(org.gradle.api.publish.maven.MavenPublication) NativePlatform(org.gradle.nativeplatform.platform.NativePlatform) FileCollection(org.gradle.api.file.FileCollection) ProductionComponent(org.gradle.language.ProductionComponent) ExtractSymbols(org.gradle.nativeplatform.tasks.ExtractSymbols) LinkExecutable(org.gradle.nativeplatform.tasks.LinkExecutable) Inject(javax.inject.Inject) Configuration(org.gradle.api.artifacts.Configuration) LifecycleBasePlugin(org.gradle.language.base.plugins.LifecycleBasePlugin) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) AttributeContainer(org.gradle.api.attributes.AttributeContainer) DefaultTargetMachineFactory(org.gradle.nativeplatform.internal.DefaultTargetMachineFactory) Attribute(org.gradle.api.attributes.Attribute) DirectoryProperty(org.gradle.api.file.DirectoryProperty) DomainObjectSet(org.gradle.api.DomainObjectSet) Usage(org.gradle.api.attributes.Usage) ConfigurableComponentWithLinkUsage(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithLinkUsage) ConfigurableComponentWithExecutable(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithExecutable) PublicationAwareComponent(org.gradle.language.nativeplatform.internal.PublicationAwareComponent) InstallExecutable(org.gradle.nativeplatform.tasks.InstallExecutable) ComponentWithTargetMachines(org.gradle.language.ComponentWithTargetMachines) Cast(org.gradle.internal.Cast) LINKAGE_ATTRIBUTE(org.gradle.language.cpp.CppBinary.LINKAGE_ATTRIBUTE) ObjectFactory(org.gradle.api.model.ObjectFactory) RegularFile(org.gradle.api.file.RegularFile) ComponentWithOutputs(org.gradle.language.ComponentWithOutputs) Collections(java.util.Collections) Plugin(org.gradle.api.Plugin) RegularFile(org.gradle.api.file.RegularFile) CreateStaticLibrary(org.gradle.nativeplatform.tasks.CreateStaticLibrary) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)

Example 8 with PlatformToolProvider

use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.

the class NativeBasePlugin method addTasksForComponentWithSharedLibrary.

private void addTasksForComponentWithSharedLibrary(final TaskContainer tasks, final DirectoryProperty buildDirectory, SoftwareComponentContainer components) {
    components.withType(ConfigurableComponentWithSharedLibrary.class, library -> {
        final Names names = library.getNames();
        final NativePlatform targetPlatform = library.getNativePlatform();
        final NativeToolChain toolChain = library.getToolChain();
        final PlatformToolProvider toolProvider = library.getPlatformToolProvider();
        // Add a link task
        final TaskProvider<LinkSharedLibrary> link = tasks.register(names.getTaskName("link"), LinkSharedLibrary.class, task -> {
            task.source(library.getObjects());
            task.lib(library.getLinkLibraries());
            task.getLinkedFile().set(buildDirectory.file(library.getBaseName().map(baseName -> toolProvider.getSharedLibraryName("lib/" + names.getDirName() + baseName))));
            // when Swift depends on C++ libraries built by Gradle.
            if (!targetPlatform.getOperatingSystem().isMacOsX()) {
                Provider<String> installName = task.getLinkedFile().getLocationOnly().map(linkedFile -> linkedFile.getAsFile().getName());
                task.getInstallName().set(installName);
            }
            task.getTargetPlatform().set(targetPlatform);
            task.getToolChain().set(toolChain);
            task.getDebuggable().set(library.isDebuggable());
        });
        Provider<RegularFile> linkFile = link.flatMap(task -> task.getLinkedFile());
        Provider<RegularFile> runtimeFile = link.flatMap(task -> task.getLinkedFile());
        Provider<? extends Task> linkFileTask = link;
        if (toolProvider.producesImportLibrary()) {
            link.configure(linkSharedLibrary -> {
                linkSharedLibrary.getImportLibrary().set(buildDirectory.file(library.getBaseName().map(baseName -> toolProvider.getImportLibraryName("lib/" + names.getDirName() + baseName))));
            });
            linkFile = link.flatMap(task -> task.getImportLibrary());
        }
        if (library.isDebuggable() && library.isOptimized() && toolProvider.requiresDebugBinaryStripping()) {
            Provider<RegularFile> symbolLocation = buildDirectory.file(library.getBaseName().map(baseName -> toolProvider.getLibrarySymbolFileName("lib/" + names.getDirName() + "stripped/" + baseName)));
            Provider<RegularFile> strippedLocation = buildDirectory.file(library.getBaseName().map(baseName -> toolProvider.getSharedLibraryName("lib/" + names.getDirName() + "stripped/" + baseName)));
            TaskProvider<StripSymbols> stripSymbols = stripSymbols(link, names, tasks, toolChain, targetPlatform, strippedLocation);
            linkFile = runtimeFile = stripSymbols.flatMap(task -> task.getOutputFile());
            TaskProvider<ExtractSymbols> extractSymbols = extractSymbols(link, names, tasks, toolChain, targetPlatform, symbolLocation);
            library.getOutputs().from(extractSymbols.flatMap(task -> task.getSymbolFile()));
            linkFileTask = stripSymbols;
        }
        library.getLinkTask().set(link);
        library.getLinkFile().set(linkFile);
        library.getLinkFileProducer().set(linkFileTask);
        library.getRuntimeFile().set(runtimeFile);
        library.getOutputs().from(library.getLinkFile());
        library.getOutputs().from(library.getRuntimeFile());
    });
}
Also used : ConfigurableComponentWithRuntimeUsage(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithRuntimeUsage) ConfigurableComponentWithSharedLibrary(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithSharedLibrary) ComponentWithVariants(org.gradle.api.component.ComponentWithVariants) LinkSharedLibrary(org.gradle.nativeplatform.tasks.LinkSharedLibrary) ComponentWithBinaries(org.gradle.language.ComponentWithBinaries) Task(org.gradle.api.Task) Provider(org.gradle.api.provider.Provider) PublishingExtension(org.gradle.api.publish.PublishingExtension) ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) MultipleCandidatesDetails(org.gradle.api.attributes.MultipleCandidatesDetails) TaskProvider(org.gradle.api.tasks.TaskProvider) TargetMachineFactory(org.gradle.nativeplatform.TargetMachineFactory) Linkage(org.gradle.nativeplatform.Linkage) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) UnzipTransform(org.gradle.api.internal.artifacts.transform.UnzipTransform) Incubating(org.gradle.api.Incubating) SoftwareComponentContainer(org.gradle.api.component.SoftwareComponentContainer) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) Project(org.gradle.api.Project) TargetMachine(org.gradle.nativeplatform.TargetMachine) ComponentWithNames(org.gradle.language.nativeplatform.internal.ComponentWithNames) Set(java.util.Set) MutableMavenProjectIdentity(org.gradle.api.publish.maven.internal.publisher.MutableMavenProjectIdentity) DIRECTORY_TYPE(org.gradle.api.artifacts.type.ArtifactTypeDefinition.DIRECTORY_TYPE) AttributeDisambiguationRule(org.gradle.api.attributes.AttributeDisambiguationRule) TaskContainer(org.gradle.api.tasks.TaskContainer) AbstractLinkTask(org.gradle.nativeplatform.tasks.AbstractLinkTask) ArtifactTypeDefinition(org.gradle.api.artifacts.type.ArtifactTypeDefinition) Names(org.gradle.language.nativeplatform.internal.Names) SoftwareComponent(org.gradle.api.component.SoftwareComponent) NativeToolChain(org.gradle.nativeplatform.toolchain.NativeToolChain) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal) CreateStaticLibrary(org.gradle.nativeplatform.tasks.CreateStaticLibrary) ZIP_TYPE(org.gradle.api.artifacts.type.ArtifactTypeDefinition.ZIP_TYPE) ConfigurableComponentWithStaticLibrary(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithStaticLibrary) StripSymbols(org.gradle.nativeplatform.tasks.StripSymbols) PublishableComponent(org.gradle.api.component.PublishableComponent) Callable(java.util.concurrent.Callable) MavenPublication(org.gradle.api.publish.maven.MavenPublication) NativePlatform(org.gradle.nativeplatform.platform.NativePlatform) FileCollection(org.gradle.api.file.FileCollection) ProductionComponent(org.gradle.language.ProductionComponent) ExtractSymbols(org.gradle.nativeplatform.tasks.ExtractSymbols) LinkExecutable(org.gradle.nativeplatform.tasks.LinkExecutable) Inject(javax.inject.Inject) Configuration(org.gradle.api.artifacts.Configuration) LifecycleBasePlugin(org.gradle.language.base.plugins.LifecycleBasePlugin) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) AttributeContainer(org.gradle.api.attributes.AttributeContainer) DefaultTargetMachineFactory(org.gradle.nativeplatform.internal.DefaultTargetMachineFactory) Attribute(org.gradle.api.attributes.Attribute) DirectoryProperty(org.gradle.api.file.DirectoryProperty) DomainObjectSet(org.gradle.api.DomainObjectSet) Usage(org.gradle.api.attributes.Usage) ConfigurableComponentWithLinkUsage(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithLinkUsage) ConfigurableComponentWithExecutable(org.gradle.language.nativeplatform.internal.ConfigurableComponentWithExecutable) PublicationAwareComponent(org.gradle.language.nativeplatform.internal.PublicationAwareComponent) InstallExecutable(org.gradle.nativeplatform.tasks.InstallExecutable) ComponentWithTargetMachines(org.gradle.language.ComponentWithTargetMachines) Cast(org.gradle.internal.Cast) LINKAGE_ATTRIBUTE(org.gradle.language.cpp.CppBinary.LINKAGE_ATTRIBUTE) ObjectFactory(org.gradle.api.model.ObjectFactory) RegularFile(org.gradle.api.file.RegularFile) ComponentWithOutputs(org.gradle.language.ComponentWithOutputs) Collections(java.util.Collections) Plugin(org.gradle.api.Plugin) RegularFile(org.gradle.api.file.RegularFile) NativeToolChain(org.gradle.nativeplatform.toolchain.NativeToolChain) LinkSharedLibrary(org.gradle.nativeplatform.tasks.LinkSharedLibrary) ComponentWithNames(org.gradle.language.nativeplatform.internal.ComponentWithNames) Names(org.gradle.language.nativeplatform.internal.Names) StripSymbols(org.gradle.nativeplatform.tasks.StripSymbols) ExtractSymbols(org.gradle.nativeplatform.tasks.ExtractSymbols) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) NativePlatform(org.gradle.nativeplatform.platform.NativePlatform)

Example 9 with PlatformToolProvider

use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider 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 10 with PlatformToolProvider

use of org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider in project gradle by gradle.

the class WindowsResourceCompile method compile.

@TaskAction
public void compile(InputChanges inputs) {
    BuildOperationLogger operationLogger = getOperationLoggerFactory().newOperationLogger(getName(), getTemporaryDir());
    NativeCompileSpec spec = new DefaultWindowsResourceCompileSpec();
    spec.setTempDir(getTemporaryDir());
    spec.setObjectFileDir(getOutputDir());
    spec.include(getIncludes());
    spec.source(getSource());
    spec.setMacros(getMacros());
    spec.args(getCompilerArgs().get());
    spec.setIncrementalCompile(inputs.isIncremental());
    spec.setOperationLogger(operationLogger);
    NativeToolChainInternal nativeToolChain = (NativeToolChainInternal) toolChain.get();
    NativePlatformInternal nativePlatform = (NativePlatformInternal) targetPlatform.get();
    PlatformToolProvider platformToolProvider = nativeToolChain.select(nativePlatform);
    WorkResult result = doCompile(spec, platformToolProvider);
    setDidWork(result.getDidWork());
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) BuildOperationLogger(org.gradle.internal.operations.logging.BuildOperationLogger) DefaultWindowsResourceCompileSpec(org.gradle.language.rc.internal.DefaultWindowsResourceCompileSpec) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) NativeCompileSpec(org.gradle.nativeplatform.toolchain.internal.NativeCompileSpec) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal) WorkResult(org.gradle.api.tasks.WorkResult) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)29 NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)20 NativePlatformInternal (org.gradle.nativeplatform.platform.internal.NativePlatformInternal)10 File (java.io.File)7 Project (org.gradle.api.Project)7 Names (org.gradle.language.nativeplatform.internal.Names)6 Callable (java.util.concurrent.Callable)5 RegularFile (org.gradle.api.file.RegularFile)5 TaskContainer (org.gradle.api.tasks.TaskContainer)5 DefaultNativePlatform (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform)5 NativeToolChain (org.gradle.nativeplatform.toolchain.NativeToolChain)5 Inject (javax.inject.Inject)4 Plugin (org.gradle.api.Plugin)4 FileCollection (org.gradle.api.file.FileCollection)4 ObjectFactory (org.gradle.api.model.ObjectFactory)4 Provider (org.gradle.api.provider.Provider)4 TaskProvider (org.gradle.api.tasks.TaskProvider)4 LifecycleBasePlugin (org.gradle.language.base.plugins.LifecycleBasePlugin)4 TargetMachine (org.gradle.nativeplatform.TargetMachine)4 TargetMachineFactory (org.gradle.nativeplatform.TargetMachineFactory)4