Search in sources :

Example 1 with NativeToolChainInternal

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

the class AbstractNativeBinarySpec method getBinaryBuildAbility.

@Override
protected BinaryBuildAbility getBinaryBuildAbility() {
    NativeToolChainInternal toolChainInternal = (NativeToolChainInternal) getToolChain();
    NativePlatformInternal platformInternal = (NativePlatformInternal) getTargetPlatform();
    return new ToolSearchBuildAbility(toolChainInternal.select(platformInternal));
}
Also used : ToolSearchBuildAbility(org.gradle.platform.base.internal.ToolSearchBuildAbility) NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal)

Example 2 with NativeToolChainInternal

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

the class NativeBinaryRules method assignToolsToNativeBinary.

private static void assignToolsToNativeBinary(NativeBinarySpecInternal nativeBinary, NativeBinarySpec nativeBinarySpec, NativeToolChainRegistryInternal toolChains) {
    NativeToolChainInternal toolChain = toolChainFor(nativeBinarySpec, toolChains);
    PlatformToolProvider toolProvider = toolChain.select((NativePlatformInternal) nativeBinarySpec.getTargetPlatform());
    nativeBinary.setToolChain(toolChain);
    nativeBinary.setPlatformToolProvider(toolProvider);
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)

Example 3 with NativeToolChainInternal

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

the class XCTestConventionPlugin method configureTestSuiteBuildingTasks.

private void configureTestSuiteBuildingTasks(ProjectInternal project, final DefaultSwiftXCTestBinary binary) {
    if (binary instanceof SwiftXCTestBundle) {
        TaskContainer tasks = project.getTasks();
        final Names names = binary.getNames();
        SwiftCompile compile = binary.getCompileTask().get();
        // TODO - creating a bundle should be done by some general purpose plugin
        // TODO - make this lazy
        DefaultNativePlatform currentPlatform = new DefaultNativePlatform("current");
        final ModelRegistry modelRegistry = project.getModelRegistry();
        NativeToolChain toolChain = modelRegistry.realize("toolChains", NativeToolChainRegistryInternal.class).getForPlatform(currentPlatform);
        // Platform specific arguments
        compile.getCompilerArgs().addAll(project.provider(new Callable<List<String>>() {

            @Override
            public List<String> call() {
                File frameworkDir = new File(sdkPlatformPathLocator.find(), "Developer/Library/Frameworks");
                return Arrays.asList("-parse-as-library", "-F" + frameworkDir.getAbsolutePath());
            }
        }));
        // Add a link task
        final LinkMachOBundle link = tasks.create(names.getTaskName("link"), LinkMachOBundle.class);
        link.getLinkerArgs().set(project.provider(new Callable<List<String>>() {

            @Override
            public List<String> call() {
                File frameworkDir = new File(sdkPlatformPathLocator.find(), "Developer/Library/Frameworks");
                return Lists.newArrayList("-F" + frameworkDir.getAbsolutePath(), "-framework", "XCTest", "-Xlinker", "-rpath", "-Xlinker", "@executable_path/../Frameworks", "-Xlinker", "-rpath", "-Xlinker", "@loader_path/../Frameworks");
            }
        }));
        InstallXCTestBundle install = tasks.create(names.getTaskName("install"), InstallXCTestBundle.class);
        install.getBundleBinaryFile().set(link.getLinkedFile());
        install.getInstallDirectory().set(project.getLayout().getBuildDirectory().dir("install/" + names.getDirName()));
        binary.getInstallDirectory().set(install.getInstallDirectory());
        link.source(binary.getObjects());
        link.lib(binary.getLinkLibraries());
        final PlatformToolProvider toolProvider = ((NativeToolChainInternal) toolChain).select(currentPlatform);
        Provider<RegularFile> exeLocation = project.getLayout().getBuildDirectory().file(project.getProviders().provider(new Callable<String>() {

            @Override
            public String call() {
                return toolProvider.getExecutableName("exe/" + names.getDirName() + binary.getBaseName().get());
            }
        }));
        link.getLinkedFile().set(exeLocation);
        link.getTargetPlatform().set(currentPlatform);
        link.getToolChain().set(toolChain);
        link.getDebuggable().set(binary.isDebuggable());
        binary.getExecutableFile().set(link.getLinkedFile());
        DefaultSwiftXCTestBundle bundle = (DefaultSwiftXCTestBundle) binary;
        bundle.getLinkTask().set(link);
        bundle.getRunScriptFile().set(install.getRunScriptFile());
    } else {
        DefaultSwiftXCTestExecutable executable = (DefaultSwiftXCTestExecutable) binary;
        executable.getRunScriptFile().set(executable.getInstallTask().get().getRunScriptFile());
    }
}
Also used : DefaultSwiftXCTestExecutable(org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestExecutable) RegularFile(org.gradle.api.file.RegularFile) NativeToolChain(org.gradle.nativeplatform.toolchain.NativeToolChain) SwiftXCTestBundle(org.gradle.nativeplatform.test.xctest.SwiftXCTestBundle) DefaultSwiftXCTestBundle(org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestBundle) Callable(java.util.concurrent.Callable) Names(org.gradle.language.nativeplatform.internal.Names) InstallXCTestBundle(org.gradle.nativeplatform.test.xctest.tasks.InstallXCTestBundle) NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) TaskContainer(org.gradle.api.tasks.TaskContainer) SwiftCompile(org.gradle.language.swift.tasks.SwiftCompile) NativeToolChainRegistryInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal) PlatformToolProvider(org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider) DefaultNativePlatform(org.gradle.nativeplatform.platform.internal.DefaultNativePlatform) LinkMachOBundle(org.gradle.nativeplatform.tasks.LinkMachOBundle) DefaultSwiftXCTestBundle(org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestBundle) File(java.io.File) RegularFile(org.gradle.api.file.RegularFile)

Example 4 with NativeToolChainInternal

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

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

the class Assemble method assemble.

@TaskAction
public void assemble() {
    BuildOperationLogger operationLogger = getOperationLoggerFactory().newOperationLogger(getName(), getTemporaryDir());
    SimpleStaleClassCleaner cleaner = new SimpleStaleClassCleaner(getOutputs());
    cleaner.setDestinationDir(getObjectFileDir());
    cleaner.execute();
    DefaultAssembleSpec spec = new DefaultAssembleSpec();
    spec.setTempDir(getTemporaryDir());
    spec.setObjectFileDir(getObjectFileDir());
    spec.source(getSource());
    spec.include(getIncludes());
    spec.args(getAssemblerArgs());
    spec.setOperationLogger(operationLogger);
    NativeToolChainInternal nativeToolChain = (NativeToolChainInternal) toolChain.get();
    NativePlatformInternal nativePlatform = (NativePlatformInternal) targetPlatform.get();
    Compiler<AssembleSpec> compiler = nativeToolChain.select(nativePlatform).newCompiler(AssembleSpec.class);
    WorkResult result = BuildOperationLoggingCompilerDecorator.wrap(compiler).execute(spec);
    setDidWork(result.getDidWork());
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) BuildOperationLogger(org.gradle.internal.operations.logging.BuildOperationLogger) AssembleSpec(org.gradle.nativeplatform.toolchain.internal.compilespec.AssembleSpec) DefaultAssembleSpec(org.gradle.language.assembler.internal.DefaultAssembleSpec) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal) DefaultAssembleSpec(org.gradle.language.assembler.internal.DefaultAssembleSpec) WorkResult(org.gradle.api.tasks.WorkResult) SimpleStaleClassCleaner(org.gradle.language.base.internal.tasks.SimpleStaleClassCleaner) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)17 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)15 NativePlatformInternal (org.gradle.nativeplatform.platform.internal.NativePlatformInternal)10 File (java.io.File)5 LinkedHashSet (java.util.LinkedHashSet)3 Project (org.gradle.api.Project)3 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)3 MinimalFileSet (org.gradle.api.internal.file.collections.MinimalFileSet)3 TaskAction (org.gradle.api.tasks.TaskAction)3 BuildOperationLogger (org.gradle.internal.operations.logging.BuildOperationLogger)3 List (java.util.List)2 Callable (java.util.concurrent.Callable)2 WorkResult (org.gradle.api.tasks.WorkResult)2 PatternSet (org.gradle.api.tasks.util.PatternSet)2 Names (org.gradle.language.nativeplatform.internal.Names)2 PreprocessingTool (org.gradle.nativeplatform.PreprocessingTool)2 Tool (org.gradle.nativeplatform.Tool)2 DefaultNativePlatform (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform)2 NativeCompileSpec (org.gradle.nativeplatform.toolchain.internal.NativeCompileSpec)2 NativeToolChainRegistryInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal)2