diff --git a/lib/configure.js b/lib/configure.js index 33906fabce..376ab3403c 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -1,6 +1,5 @@ module.exports = exports = configure - /** * Module dependencies. */ @@ -26,14 +25,17 @@ function configure (gyp, argv, callback) { var python = gyp.opts.python || process.env.PYTHON || 'python' , buildDir = path.resolve('build') , hasVCExpress = false + , hasVC2012Express = false , hasWin71SDK = false + , hasWin8SDK = false , configPath , nodeDir + if (win) { checkVCExpress(function () { - if (hasVCExpress) { - checkWin71SDK(function () { + if (hasVCExpress || hasVC2012Express) { + checkWinSDK(function () { checkPython() }) } else { @@ -116,6 +118,12 @@ function configure (gyp, argv, callback) { + 'You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.')) } + function checkWinSDK(cb) { + checkWin71SDK(function() { + checkWin8SDK(cb); + }) + } + function checkWin71SDK(cb) { spawn('reg', ['query', 'HKLM\\Software\\Microsoft\\Microsoft SDKs\\Windows\\v7.1', '/v', 'InstallationFolder']) .on('exit', function (code) { @@ -124,11 +132,43 @@ function configure (gyp, argv, callback) { }) } + function checkWin8SDK(cb) { + var cp = spawn('reg', ['query', 'HKLM\\Software\\Microsoft\\Windows Kits\\Installed Products', '/f', 'Windows Software Development Kit x86', '/reg:32']) + cp.on('exit', function (code) { + hasWin8SDK = (code === 0) + cb() + }) + } + + function checkVC2012Express64(cb) { + var cp = spawn('reg', ['query', 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\11.0\\Setup\\VC', '/v', 'ProductDir']) + cp.on('exit', function (code) { + hasVC2012Express = (code === 0) + cb() + }) + } + + function checkVC2012Express(cb) { + var cp = spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC', '/v', 'ProductDir']) + cp.on('exit', function (code) { + hasVC2012Express = (code === 0) + if (code !== 0) { + checkVC2012Express64(cb) + } else { + cb() + } + }) + } + function checkVCExpress64(cb) { var cp = spawn('cmd', ['/C', '%WINDIR%\\SysWOW64\\reg', 'query', 'HKLM\\Software\\Microsoft\\VCExpress\\10.0\\Setup\\VC', '/v', 'ProductDir']) cp.on('exit', function (code) { hasVCExpress = (code === 0) - cb() + if (code !== 0) { + checkVC2012Express(cb) + } else { + cb() + } }) } @@ -238,9 +278,13 @@ function configure (gyp, argv, callback) { // set the target_arch variable variables.target_arch = gyp.opts.arch || process.arch || 'ia32' - // set the toolset for 64-bit VCExpress users - if (win && variables.target_arch === 'x64' && hasVCExpress && hasWin71SDK) { - defaults.msbuild_toolset = 'Windows7.1SDK' + // set the toolset for VCExpress users + if (win) { + if (hasVC2012Express && hasWin8SDK) { + defaults.msbuild_toolset = 'v110' + } else if (hasVCExpress && hasWin71SDK) { + defaults.msbuild_toolset = 'Windows7.1SDK' + } } // set the node development directory