Skip to content
Browse files

node-gyp@0.8.2

  • Loading branch information...
1 parent ff07500 commit c6425feb463270c416d30b67d32a69a713e56cbe @isaacs isaacs committed Jan 9, 2013
View
57 node_modules/node-gyp/lib/build.js
@@ -12,6 +12,7 @@ var fs = require('graceful-fs')
, log = require('npmlog')
, which = require('which')
, mkdirp = require('mkdirp')
+ , exec = require('child_process').exec
, win = process.platform == 'win32'
exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module'
@@ -99,7 +100,7 @@ function build (gyp, argv, callback) {
if (err) {
if (win && /not found/.test(err.message)) {
// On windows and no 'msbuild' found. Let's guess where it is
- guessMsbuild()
+ findMsbuild()
} else {
// Some other error or 'make' not found on Unix, report that to the user
callback(err)
@@ -112,28 +113,50 @@ function build (gyp, argv, callback) {
}
/**
- * Guess the location of the "msbuild.exe" file on Windows.
+ * Search for the location of "msbuild.exe" file on Windows.
*/
- function guessMsbuild () {
+ function findMsbuild () {
log.verbose('could not find "msbuild.exe". guessing location')
- // This is basically just hard-coded. If this causes problems
- // then we'll think of something more clever.
- var windir = process.env.WINDIR || process.env.SYSTEMROOT || 'C:\\WINDOWS'
- , frameworkDir = path.resolve(windir, 'Microsoft.NET', 'Framework')
- , versionDir = path.resolve(frameworkDir, 'v4.0.30319') // This is probably the most brittle part...
- , msbuild = path.resolve(versionDir, 'msbuild.exe')
- fs.stat(msbuild, function (err, stat) {
+ var notfoundErr = new Error('Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?')
+ exec('reg query HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions /s /f MSBuildToolsPath /e /t REG_SZ', function (err, stdout, stderr) {
+ var reVers = /Software\\Microsoft\\MSBuild\\ToolsVersions\\([^\r]+)\r\n\s+MSBuildToolsPath\s+REG_SZ\s+([^\r]+)/gi
+ , msbuilds = []
+ , r
+ , msbuildPath
if (err) {
- if (err.code == 'ENOENT') {
- callback(new Error('Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2010 installed?'))
- } else {
- callback(err)
+ return callback(notfoundErr)
+ }
+ while (r = reVers.exec(stdout)) {
+ if (parseFloat(r[1], 10) >= 3.5) {
+ msbuilds.push({
+ version: parseFloat(r[1], 10),
+ path: r[2]
+ })
}
- return
}
- command = msbuild
- copyNodeLib()
+ msbuilds.sort(function (x, y) {
+ return (x.version < y.version ? -1 : 1)
+ })
+ ;(function verifyMsbuild () {
+ msbuildPath = path.resolve(msbuilds.pop().path, 'msbuild.exe')
+ fs.stat(msbuildPath, function (err, stat) {
+ if (err) {
+ if (err.code == 'ENOENT') {
+ if (msbuilds.length) {
+ return verifyMsbuild()
+ } else {
+ callback(notfoundErr)
+ }
+ } else {
+ callback(err)
+ }
+ return
+ }
+ command = msbuildPath
+ copyNodeLib()
+ })
+ })()
})
}
View
4 node_modules/node-gyp/lib/configure.js
@@ -91,11 +91,11 @@ function configure (gyp, argv, callback) {
}
function checkPythonVersion () {
- execFile(python, ['-c', 'import platform; print platform.python_version();'], function (err, stdout) {
+ execFile(python, ['-c', 'import platform; print(platform.python_version());'], function (err, stdout) {
if (err) {
return callback(err)
}
- log.verbose('check python version', '`%s -c "import platform; print platform.python_version();"` returned: %j', python, stdout)
+ log.verbose('check python version', '`%s -c "import platform; print(platform.python_version());"` returned: %j', python, stdout)
var version = stdout.trim()
if (~version.indexOf('+')) {
log.silly('stripping "+" sign(s) from version')
View
2 node_modules/node-gyp/lib/install.js
@@ -60,7 +60,7 @@ function install (gyp, argv, callback) {
}
// 0.x.y-pre versions are not published yet and cannot be installed. Bail.
- if (version[5] === '-pre') {
+ if (version[5] && version[5].match(/\-pre$/)) {
log.verbose('detected "pre" node version', versionStr)
if (gyp.opts.nodedir) {
log.verbose('--nodedir flag was passed; skipping install', gyp.opts.nodedir)
View
9 node_modules/node-gyp/package.json
@@ -10,7 +10,7 @@
"bindings",
"gyp"
],
- "version": "0.8.1",
+ "version": "0.8.2",
"installVersion": 9,
"author": {
"name": "Nathan Rajlich",
@@ -46,6 +46,9 @@
},
"readme": "node-gyp\n=========\n### Node.js native addon build tool\n\n`node-gyp` is a cross-platform command-line tool written in Node.js for compiling\nnative addon modules for Node.js, which takes away the pain of dealing with the\nvarious differences in build platforms. It is the replacement to the `node-waf`\nprogram which is removed for node `v0.8`. If you have a native addon for node that\nstill has a `wscript` file, then you should definitely add a `binding.gyp` file\nto support the latest versions of node.\n\nMultiple target versions of node are supported (i.e. `0.6`, `0.7`,..., `1.0`,\netc.), regardless of what version of node is actually installed on your system\n(`node-gyp` downloads the necessary development files for the target version).\n\n#### Features:\n\n * Easy to use, consistent interface\n * Same commands to build your module on every platform\n * Supports multiple target versions of Node\n\n\nInstallation\n------------\n\nYou can install with `npm`:\n\n``` bash\n$ npm install -g node-gyp\n```\n\nYou will also need to install:\n\n * On Unix:\n * `python`\n * `make`\n * A proper C/C++ compiler toolchain, like GCC\n * On Windows:\n * [Python][windows-python] ([`v2.7.3`][windows-python-v2.7.3] recommended, `v3.x.x` is __*not*__ supported)\n * Windows XP/Vista/7:\n * Microsoft Visual Studio C++ 2010 ([Express][msvc2010] version works well)\n * For 64-bit builds of node and native modules you will _**also**_ need the [Windows 7 64-bit SDK][win7sdk]\n * If you get errors that the 64-bit compilers are not installed you may also need the [compiler update for the Windows SDK 7.1]\n * Windows 8:\n * Microsoft Visual Studio C++ 2012 for Windows Desktop ([Express][msvc2012] version works well)\n\nHow to Use\n----------\n\nTo compile your native addon, first go to its root directory:\n\n``` bash\n$ cd my_node_addon\n```\n\nThe next step is to generate the appropriate project build files for the current\nplatform. Use `configure` for that:\n\n``` bash\n$ node-gyp configure\n```\n\n__Note__: The `configure` step looks for the `binding.gyp` file in the current\ndirectory to processs. See below for instructions on creating the `binding.gyp` file.\n\nNow you will have either a `Makefile` (on Unix platforms) or a `vcxproj` file\n(on Windows) in the `build/` directory. Next invoke the `build` command:\n\n``` bash\n$ node-gyp build\n```\n\nNow you have your compiled `.node` bindings file! The compiled bindings end up\nin `build/Debug/` or `build/Release/`, depending on the build mode. At this point\nyou can require the `.node` file with Node and run your tests!\n\n__Note:__ To create a _Debug_ build of the bindings file, pass the `--debug` (or\n`-d`) switch when running the either `configure` or `build` command.\n\n\nThe \"binding.gyp\" file\n----------------------\n\nPreviously when node had `node-waf` you had to write a `wscript` file. The\nreplacement for that is the `binding.gyp` file, which describes the configuration\nto build your module in a JSON-like format. This file gets placed in the root of\nyour package, alongside the `package.json` file.\n\nA barebones `gyp` file appropriate for building a node addon looks like:\n\n``` json\n{\n \"targets\": [\n {\n \"target_name\": \"binding\",\n \"sources\": [ \"src/binding.cc\" ]\n }\n ]\n}\n```\n\nSome additional resources for writing `gyp` files:\n\n * [\"Hello World\" node addon example](https://github.com/joyent/node/tree/master/test/addons/hello-world)\n * [gyp user documentation](http://code.google.com/p/gyp/wiki/GypUserDocumentation)\n * [gyp input format reference](http://code.google.com/p/gyp/wiki/InputFormatReference)\n * [*\"binding.gyp\" files out in the wild* wiki page](https://github.com/TooTallNate/node-gyp/wiki/%22binding.gyp%22-files-out-in-the-wild)\n\n\nCommands\n--------\n\n`node-gyp` responds to the following commands:\n\n| **Command** | **Description**\n|:--------------|:---------------------------------------------------------------\n| `build` | Invokes `make`/`msbuild.exe` and builds the native addon\n| `clean` | Removes any the `build` dir if it exists\n| `configure` | Generates project build files for the current platform\n| `rebuild` | Runs \"clean\", \"configure\" and \"build\" all in a row\n| `install` | Installs node development header files for the given version\n| `list` | Lists the currently installed node development file versions\n| `remove` | Removes the node development header files for the given version\n\n\nLicense\n-------\n\n(The MIT License)\n\nCopyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n[windows-python]: http://www.python.org/getit/windows\n[windows-python-v2.7.3]: http://www.python.org/download/releases/2.7.3#download\n[msvc2010]: http://go.microsoft.com/?linkid=9709949\n[msvc2012]: http://go.microsoft.com/?linkid=9816758\n[win7sdk]: http://www.microsoft.com/en-us/download/details.aspx?id=8279\n[compiler update for the Windows SDK 7.1]: http://www.microsoft.com/en-us/download/details.aspx?id=4422\n",
"readmeFilename": "README.md",
- "_id": "node-gyp@0.8.1",
- "_from": "node-gyp@latest"
+ "_id": "node-gyp@0.8.2",
+ "dist": {
+ "shasum": "d1a72a944a16a97b91ed3ea2f2ec6e7c0826c294"
+ },
+ "_from": "node-gyp@~0.8.1"
}

0 comments on commit c6425fe

Please sign in to comment.
Something went wrong with that request. Please try again.