Search in sources :

Example 1 with DefaultVisualStudioProject

use of org.gradle.ide.visualstudio.internal.DefaultVisualStudioProject in project gradle by gradle.

the class VisualStudioPlugin method applyVisualStudioCurrentModelRules.

private void applyVisualStudioCurrentModelRules(final VisualStudioExtensionInternal extension) {
    project.getComponents().withType(CppApplication.class).all(cppApplication -> {
        DefaultVisualStudioProject vsProject = extension.getProjectRegistry().createProject(project.getName(), cppApplication.getName());
        vsProject.getSourceFiles().from(cppApplication.getCppSource());
        vsProject.getHeaderFiles().from(cppApplication.getHeaderFiles());
        cppApplication.getBinaries().whenElementFinalized(CppExecutable.class, executable -> {
            extension.getProjectRegistry().addProjectConfiguration(new CppApplicationVisualStudioTargetBinary(project.getName(), project.getPath(), cppApplication, executable, project.getLayout()));
        });
    });
    project.afterEvaluate(proj -> {
        project.getComponents().withType(CppLibrary.class).all(cppLibrary -> {
            for (Linkage linkage : cppLibrary.getLinkage().get()) {
                VisualStudioTargetBinary.ProjectType projectType = VisualStudioTargetBinary.ProjectType.DLL;
                if (Linkage.STATIC.equals(linkage)) {
                    projectType = VisualStudioTargetBinary.ProjectType.LIB;
                }
                DefaultVisualStudioProject vsProject = extension.getProjectRegistry().createProject(project.getName() + projectType.getSuffix(), cppLibrary.getName());
                vsProject.getSourceFiles().from(cppLibrary.getCppSource());
                vsProject.getHeaderFiles().from(cppLibrary.getHeaderFiles());
            }
            cppLibrary.getBinaries().whenElementFinalized(CppSharedLibrary.class, library -> {
                extension.getProjectRegistry().addProjectConfiguration(new CppSharedLibraryVisualStudioTargetBinary(project.getName(), project.getPath(), cppLibrary, library, project.getLayout()));
            });
            cppLibrary.getBinaries().whenElementFinalized(CppStaticLibrary.class, library -> {
                extension.getProjectRegistry().addProjectConfiguration(new CppStaticLibraryVisualStudioTargetBinary(project.getName(), project.getPath(), cppLibrary, library, project.getLayout()));
            });
        });
    });
}
Also used : CppApplicationVisualStudioTargetBinary(org.gradle.ide.visualstudio.internal.CppApplicationVisualStudioTargetBinary) Linkage(org.gradle.nativeplatform.Linkage) VisualStudioTargetBinary(org.gradle.ide.visualstudio.internal.VisualStudioTargetBinary) CppApplicationVisualStudioTargetBinary(org.gradle.ide.visualstudio.internal.CppApplicationVisualStudioTargetBinary) CppStaticLibraryVisualStudioTargetBinary(org.gradle.ide.visualstudio.internal.CppStaticLibraryVisualStudioTargetBinary) CppSharedLibraryVisualStudioTargetBinary(org.gradle.ide.visualstudio.internal.CppSharedLibraryVisualStudioTargetBinary) CppLibrary(org.gradle.language.cpp.CppLibrary) CppStaticLibraryVisualStudioTargetBinary(org.gradle.ide.visualstudio.internal.CppStaticLibraryVisualStudioTargetBinary) DefaultVisualStudioProject(org.gradle.ide.visualstudio.internal.DefaultVisualStudioProject) CppApplication(org.gradle.language.cpp.CppApplication) CppSharedLibraryVisualStudioTargetBinary(org.gradle.ide.visualstudio.internal.CppSharedLibraryVisualStudioTargetBinary)

Example 2 with DefaultVisualStudioProject

use of org.gradle.ide.visualstudio.internal.DefaultVisualStudioProject in project gradle by gradle.

the class GenerateProjectFileTask method configure.

@Override
protected void configure(VisualStudioProjectFile projectFile) {
    DefaultVisualStudioProject vsProject = visualStudioProject;
    projectFile.setGradleCommand(buildGradleCommand());
    projectFile.setProjectUuid(DefaultVisualStudioProject.getUUID(getOutputFile()));
    projectFile.setVisualStudioVersion(visualStudioProject.getVisualStudioVersion().get());
    projectFile.setSdkVersion(visualStudioProject.getSdkVersion().get());
    for (File sourceFile : vsProject.getSourceFiles()) {
        projectFile.addSourceFile(sourceFile);
    }
    for (File resourceFile : vsProject.getResourceFiles()) {
        projectFile.addResource(resourceFile);
    }
    for (File headerFile : vsProject.getHeaderFiles()) {
        projectFile.addHeaderFile(headerFile);
    }
    if (vsProject.getConfigurations().stream().noneMatch(it -> it.isBuildable())) {
        getLogger().warn("'" + vsProject.getComponentName() + "' component in project '" + getProject().getPath() + "' is not buildable.");
    }
    for (VisualStudioProjectConfiguration configuration : vsProject.getConfigurations()) {
        projectFile.addConfiguration(configuration);
    }
    for (Action<? super XmlProvider> xmlAction : vsProject.getProjectFile().getXmlActions()) {
        getXmlTransformer().addAction(xmlAction);
    }
}
Also used : DefaultVisualStudioProject(org.gradle.ide.visualstudio.internal.DefaultVisualStudioProject) VisualStudioProjectConfiguration(org.gradle.ide.visualstudio.internal.VisualStudioProjectConfiguration) VisualStudioProjectFile(org.gradle.ide.visualstudio.tasks.internal.VisualStudioProjectFile) File(java.io.File) OutputFile(org.gradle.api.tasks.OutputFile)

Aggregations

DefaultVisualStudioProject (org.gradle.ide.visualstudio.internal.DefaultVisualStudioProject)2 File (java.io.File)1 OutputFile (org.gradle.api.tasks.OutputFile)1 CppApplicationVisualStudioTargetBinary (org.gradle.ide.visualstudio.internal.CppApplicationVisualStudioTargetBinary)1 CppSharedLibraryVisualStudioTargetBinary (org.gradle.ide.visualstudio.internal.CppSharedLibraryVisualStudioTargetBinary)1 CppStaticLibraryVisualStudioTargetBinary (org.gradle.ide.visualstudio.internal.CppStaticLibraryVisualStudioTargetBinary)1 VisualStudioProjectConfiguration (org.gradle.ide.visualstudio.internal.VisualStudioProjectConfiguration)1 VisualStudioTargetBinary (org.gradle.ide.visualstudio.internal.VisualStudioTargetBinary)1 VisualStudioProjectFile (org.gradle.ide.visualstudio.tasks.internal.VisualStudioProjectFile)1 CppApplication (org.gradle.language.cpp.CppApplication)1 CppLibrary (org.gradle.language.cpp.CppLibrary)1 Linkage (org.gradle.nativeplatform.Linkage)1