Skip to content

Commit

Permalink
configure: supply target_arch define to gyp.js
Browse files Browse the repository at this point in the history
Since version 1.1.1 gyp.js uses environment files. Set --target_arch
command-line option with value of node-gyp --arch option in order to
generate proper ninja environment file.

Removed findMSVS() function and `vcvars.bat` invocation before building with
`ninja` because `gyp.js` supports target environments and the actual
`target_arch` is set before on `configure` stage.
  • Loading branch information
pmed committed Jun 23, 2016
1 parent 5b0a17b commit 8d3b929
Showing 1 changed file with 2 additions and 35 deletions.
37 changes: 2 additions & 35 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function build (gyp, argv, callback) {
, config
, arch
, nodeDir
, vcDir

if (gyp.opts.gypjs) {
command = gyp.opts.ninja || process.env.NINJA || 'ninja'
Expand Down Expand Up @@ -75,41 +74,14 @@ function build (gyp, argv, callback) {
log.verbose('architecture', arch)
log.verbose('node dev dir', nodeDir)

if (win) {
gyp.opts.gypjs? findMSVS() : findSolutionFile()
if (!gyp.opts.gypjs && win) {
findSolutionFile()
} else {
doWhich()
}
})
}

/**
* On Windows, find Visual C++ toolset
*/

function findMSVS () {
var msvs_version = gyp.opts.msvs_version || 'auto'
var vs_versions = (msvs_version === 'auto'? [14, 12, 10] : [msvs_version])
vs_versions.find(function(version) {
var vscomntools = process.env['VS' + version + '0COMNTOOLS']
if (vscomntools) {
// remove quotes to work with path.join()
if (vscomntools.substr(0, 1) === '"' && vscomntools.substr(-1, 1) === '"') {
vscomntools = vscomntools.substr(1, vscomntools.length - 2)
}
vcDir = path.join(vscomntools, '..', '..', 'VC')
if (vcDir) {
log.verbose('found Visual C++ in ', vcDir)
return true
}
}
})
if (!vcDir) {
callback(new Error('Visual C++ not found, please setup a C++ compiler toolset'))
}
doWhich()
}

/**
* On Windows, find the first build/*.sln file.
*/
Expand Down Expand Up @@ -281,11 +253,6 @@ function build (gyp, argv, callback) {
argv.push('-j' + j)
}
}
// invoke vcvarsall.bat before build
if (win && vcDir) {
argv.unshift(arch === 'ia32'? 'x86' : arch, '&', command)
command = path.join(vcDir, 'vcvarsall.bat')
}
}

var proc = gyp.spawn(command, argv)
Expand Down

0 comments on commit 8d3b929

Please sign in to comment.