How can I configure the default search path for the VisualCpp tool chain?


(Christo Zietsman) #1

We’re using Visual Studio 2012 and some of us use Visual Studio 2013. The visualCpp tool chain for these can be found in “C:\Program Files\Microsoft Visual Studio 11.0” & “C:\Program Files\Microsoft Visual Studio 12.0” including the 64 bit and 32 bit variations.

On my system with Visual Studio 2012 installed gradle outputs:

> Tool chain visualCpp is not available: Visual Studio installation cannot be located. Searched in [C:\Program Files\Microsoft Visual Studio 10.0, C:\Program Files (x86)\Microsoft Visual Studio 10.0].

It looks like this is hard coded in org.gradle.nativebinaries.toolchain.internal.msvcpp.DefaultVisualStudioLocator.

Ideally it would be nice to be able to modify the list of candidates for both VisualStudio and WindowsSdks.

Are there plans for making the default search path configurable or for supporting the latest VisualStudio and WindowSdk search paths?


#2

You have a couple of options: if Gradle finds ‘cl.exe’ on the path, it should use this to locate the containing Visual Studio installation. Likewise for the Windows SDK, Gradle looks for ‘rc.exe’ on the path.

Alternatively you should be able to configure the Visual Studio install path like this:

toolChains {
    vc(VisualCpp) {
        installDir "C:/Apps/Microsoft Visual Studio 11.0"
    }
}

There’s not yet an equivalent feature for defining the Windows SDK directory.

Be aware that so far Gradle has only been tested against Visual C++ 2010 Express. I’d be interested to hear your experience working with other versions.


(Christo Zietsman) #3

Thanks, I’ll do that for now.

I like that gradle is auto discovering the Visual Studio installation. I was wondering how to setup Jenkins to kick off binary builds given that the correct environment should be set first, especially targeting multiple platforms.

I’ll let you know if I find any issues. I’m excited at the pace you’re going with native support.


(Christo Zietsman) #4

I’ve added the Visual Studio install path, but now it can’t find the Windows SDK directory which on my installation is under “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A”.

> Tool chain vc is not available: Windows SDK cannot be located. Searched in [C:
\Program Files\Microsoft SDKs\Windows\v7.1, C:\Program Files (x86)\Microsoft SDK
s\Windows\v7.1, C:\Program Files\Microsoft SDKs\Windows\v7.0A, C:\Program Files
(x86)\Microsoft SDKs\Windows\v7.0A].

I guess the only way would be to add the folder on the path.

Its pretty easy to add support for specifying an alternate windowsSdkDir like the installDir and providing the capability to specify additional search locations.

Would it be worth implementing it and submitting a pull request?


#5

A pull request would be great: you could also update VisualStudioLocator to include the standard locations for Visual Studio 2012 and the Windows SDK v7.1A.

You can the verify that everything is working for C++ with:

gradlew.bat --continue quickCheck :cpp:check

If this works, we could possibly add Visual Studio 2012 to our CI infrastructure and add it as a supported platform.


(Christo Zietsman) #6

I’ve sent a pull request for this in which I’ve added a windowsSdkDir property to VisualCpp. I also added “Microsoft SDKs/Windows/v7.1A” and “/Microsoft Visual Studio 11.0” to the WindowsSdk and VisualStudio search paths respectively.

I ran:

gradlew.bat --continue quickCheck :cpp:check

which worked except that I do not have the Itanium compiler in my sdk.

I locally commented out the relevant Itanium part in BinaryPlatformIntegrationTest & CppSamplesIntegrationTest & samples/native-binaries/variants/build.gralde which subsequently ran through without a hitch. I did not commit these three changes.

I’m not sure where exactly I need to update the documentation.