Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing behaviour from visual-studio plugin when a configured toolChain isn't present #766

Closed
philmcardle opened this issue Oct 27, 2016 · 5 comments
Labels
a:feature A new functionality in:native-platform c, cpp, swift and other native languages support, etc

Comments

@philmcardle
Copy link

philmcardle commented Oct 27, 2016

In a script in which the configured toolChain isn't available to Gradle, the visual-studio plugin won't generate the solution and lifecycle tasks.

Expected Behavior

The visual-studio plugin should either always generate all tasks, regardless of the available toolchains, or report a useful error.

Current Behavior

On a machine without GCC, with the following code

apply plugin: 'cpp'
apply plugin: 'visual-studio'

model {

    toolChains {

        gcc(Gcc) {

        }

    }

    components {

        TestProject(NativeLibrarySpec) {

        }

    }

}

gradle tasks --all output is

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project. [assemble, check]
clean - Deletes the build directory.
TestProjectSharedLibrary - Assembles shared library 'testProject:sharedLibrary'.
    linkTestProjectSharedLibrary - Links shared library 'testProject:sharedLibrary'
TestProjectStaticLibrary - Assembles static library 'testProject:staticLibrary'.
    createTestProjectStaticLibrary - Creates static library 'testProject:staticLibrary'

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'test'.
components - Displays the components produced by root project 'test'. [incubating]
dependencies - Displays all dependencies declared in root project 'test'.
dependencyInsight - Displays the insight into a specific dependency in root project 'test'.
help - Displays a help message.
model - Displays the configuration model of root project 'test'. [incubating]
projects - Displays the sub-projects of root project 'test'.
properties - Displays the properties of root project 'test'.
tasks - Displays the tasks runnable from root project 'test'.

IDE tasks
---------
cleanVisualStudio - Removes all generated Visual Studio project and solution files

Verification tasks
------------------
check - Runs all checks.

Other tasks
-----------
TestProjectDllVisualStudioFilters
TestProjectDllVisualStudioProject
TestProjectLibVisualStudioFilters
TestProjectLibVisualStudioProject

When it should be the following (output created by either changing the toolChain for VisualCpp or after installing gcc)

Build tasks
-----------
assemble - Assembles the outputs of this project. [TestProjectSharedLibrary, TestProjectStaticLibrary]
build - Assembles and tests this project. [assemble, check]
clean - Deletes the build directory.
TestProjectSharedLibrary - Assembles shared library 'testProject:sharedLibrary'.
    linkTestProjectSharedLibrary - Links shared library 'testProject:sharedLibrary'
TestProjectStaticLibrary - Assembles static library 'testProject:staticLibrary'.
    createTestProjectStaticLibrary - Creates static library 'testProject:staticLibrary'

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'test'.
components - Displays the components produced by root project 'test'. [incubating]
dependencies - Displays all dependencies declared in root project 'test'.
dependencyInsight - Displays the insight into a specific dependency in root project 'test'.
help - Displays a help message.
model - Displays the configuration model of root project 'test'. [incubating]
projects - Displays the sub-projects of root project 'test'.
properties - Displays the properties of root project 'test'.
tasks - Displays the tasks runnable from root project 'test'.

IDE tasks
---------
cleanVisualStudio - Removes all generated Visual Studio project and solution files
TestProjectVisualStudio - Generates the Visual Studio solution for native library 'TestProject'.
    TestProjectDllVisualStudio - Generates the 'TestProjectDll' Visual Studio solution file.
    TestProjectDllVisualStudioFilters
    TestProjectDllVisualStudioProject
    TestProjectDllVisualStudioSolution
    TestProjectLibVisualStudio - Generates the 'TestProjectLib' Visual Studio solution file.
    TestProjectLibVisualStudioFilters
    TestProjectLibVisualStudioProject
    TestProjectLibVisualStudioSolution

Context

Discovered while writing code to allow my Gradle scripts to intentionally select a specific toolChain. Doesn't block anything, just, confusing initially.

Steps to Reproduce (for bugs)

Code above.

Your Environment

Gradle 3.1
Windows 10 Version 1607

@philmcardle
Copy link
Author

I've found another instance of this, which I can't work around, which might eventually block me.

Environment: Gradle 3.1, Windows 10 Version 1607, now with MinGW installed.

apply plugin: 'cpp'
apply plugin: 'visual-studio'

model {

    toolChains {

        gcc(Gcc) {

        }

    }

    platforms {
        x64 {
            architecture "x64"
        }
    }

    components {

        TestProject(NativeLibrarySpec) {
            targetPlatform 'x64'
        }

    }

}

This, again, doesn't create the full set of Visual Studio tasks. This is a bit of a nuisance for us as we're looking at (but haven't got to yet) cross-compiling both locally (MinGW / VM with shared disk / Windows Linux Subsystem) and also remote (Visual C++ for Linux) and it would be appreciated if the Visual Studio plugin would just generate the IDE projects and solutions.

@lacasseio
Copy link
Contributor

Thanks for reporting the limitation between Visual Studio and Gcc. The visual studio integration is limited when it comes to your current scenario. There is some idea in discussion in how this can be improved in order to provide a better solution. The IDE, especially for C++, is opinionated on certain modeling which make it the integration harder than it seems.

We decided not to take route of generating native IDE projects and solutions because of the complexity when it comes to mapping generated source set, pre-build, pre-link and post-link steps. The current solution is by far perfect and because of this it's harder to integrate current Visual Studio plugins. It's best to seek a solution in Gradle as you will be able to reuse the logic on local developer machine as well as CI server. That been said, share your various usage scenario with us so we can take them into account during future design improvement.

@philmcardle
Copy link
Author

I suppose I should clarify, my issue is that the Visual Studio plugin won't create some of the IDE tasks when Gradle knows that it can't build that target, but it's not consistent and it's not explained - i.e. it creates the Project and Filters tasks, but not the Solution task or the encompassing lifecycle tasks.

I would like the Visual Studio plugin (or any IDE project generator) to work independently from whether the target binaries are buildable, or, if it must be tied to whether to something is buildable, then it shouldn't generate only half the tasks - it should generate none of them.

I'm not expecting Gradle's Visual Studio plugin to generate Visual Studio projects with VS-equivalent build steps (pre-build, pre-link, etc.) - we're implementing all the build logic in Gradle, however, almost all of our developers will want to work in Visual Studio, so it's paramount that I'm able to generate something.

I've already written quite a lot of gradle (and will write more yet) to modify the generated Visual Studio projects, but it's much easier when I can depend on Gradle having created the projects in the first place :)

@lacasseio
Copy link
Contributor

Thanks for reporting this issue, we will consider your scenario in the improvement work for Visual Studio integration.

@eriwen eriwen added in:native-platform c, cpp, swift and other native languages support, etc a:feature A new functionality from:contributor and removed contributed labels Nov 9, 2016
@big-guy
Copy link
Member

big-guy commented Feb 21, 2018

Issue moved to gradle/gradle-native #496 via ZenHub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:native-platform c, cpp, swift and other native languages support, etc
Projects
None yet
Development

No branches or pull requests

4 participants