node-gyp
Advanced tools
Comparing version 3.6.3 to 3.7.0
@@ -26,2 +26,6 @@ | ||
platformMake = 'gmake' | ||
} else if (win && argv.length > 0) { | ||
argv = argv.map(function(target) { | ||
return '/t:' + target | ||
}) | ||
} | ||
@@ -28,0 +32,0 @@ |
@@ -75,4 +75,6 @@ module.exports = exports = configure | ||
// ensure that the target node version's dev files are installed | ||
gyp.opts.ensure = true | ||
// If the tarball option is set, always remove and reinstall the headers | ||
// into devdir. Otherwise only install if they're not already there. | ||
gyp.opts.ensure = gyp.opts.tarball ? false : true | ||
gyp.commands.install([ release.version ], function (err, version) { | ||
@@ -246,18 +248,25 @@ if (err) return callback(err) | ||
// for AIX we need to set up the path to the exp file | ||
// which contains the symbols needed for linking. | ||
// The file will either be in one of the following | ||
// depending on whether it is an installed or | ||
// development environment: | ||
// - the include/node directory | ||
// - the out/Release directory | ||
// - the out/Debug directory | ||
// - the root directory | ||
// For AIX and z/OS we need to set up the path to the exports file | ||
// which contains the symbols needed for linking. | ||
var node_exp_file = undefined | ||
if (process.platform === 'aix') { | ||
if (process.platform === 'aix' || process.platform === 'os390') { | ||
var ext = process.platform === 'aix' ? 'exp' : 'x' | ||
var node_root_dir = findNodeDirectory() | ||
var candidates = ['include/node/node.exp', | ||
'out/Release/node.exp', | ||
'out/Debug/node.exp', | ||
'node.exp'] | ||
var candidates = undefined | ||
if (process.platform === 'aix') { | ||
candidates = ['include/node/node', | ||
'out/Release/node', | ||
'out/Debug/node', | ||
'node' | ||
].map(function(file) { | ||
return file + '.' + ext | ||
}) | ||
} else { | ||
candidates = ['out/Release/obj.target/libnode', | ||
'out/Debug/obj.target/libnode', | ||
'lib/libnode' | ||
].map(function(file) { | ||
return file + '.' + ext | ||
}) | ||
} | ||
var logprefix = 'find exports file' | ||
@@ -268,3 +277,3 @@ node_exp_file = findAccessibleSync(logprefix, node_root_dir, candidates) | ||
} else { | ||
var msg = msgFormat('Could not find node.exp file in %s', node_root_dir) | ||
var msg = msgFormat('Could not find node.%s file in %s', ext, node_root_dir) | ||
log.error(logprefix, 'Could not find exports file') | ||
@@ -298,3 +307,3 @@ return callback(new Error(msg)) | ||
argv.push('-Dnode_root_dir=' + nodeDir) | ||
if (process.platform === 'aix') { | ||
if (process.platform === 'aix' || process.platform === 'os390') { | ||
argv.push('-Dnode_exp_file=' + node_exp_file) | ||
@@ -301,0 +310,0 @@ } |
@@ -9,5 +9,5 @@ var log = require('npmlog') | ||
var csFile = path.join(__dirname, 'Find-VS2017.cs') | ||
var psArgs = ['-ExecutionPolicy', 'Unrestricted', '-Command', | ||
'&{Add-Type -Path \'' + csFile + | ||
'\'; [VisualStudioConfiguration.Main]::Query()}'] | ||
var psArgs = ['-ExecutionPolicy', 'Unrestricted', '-NoProfile', | ||
'-Command', '&{Add-Type -Path \'' + csFile + '\';' + | ||
'[VisualStudioConfiguration.Main]::Query()}'] | ||
@@ -14,0 +14,0 @@ log.silly('find vs2017', 'Running', ps, psArgs) |
@@ -0,6 +1,11 @@ | ||
module.exports = exports = function (gyp, argv, callback) { | ||
return install(fs, gyp, argv, callback) | ||
} | ||
module.exports = exports = install | ||
module.exports.test = { | ||
download: download, | ||
install: install, | ||
readCAFile: readCAFile, | ||
} | ||
module.exports.test = { download: download, readCAFile: readCAFile } | ||
exports.usage = 'Install node development files for the specified node version.' | ||
@@ -23,3 +28,2 @@ | ||
, request = require('request') | ||
, minimatch = require('minimatch') | ||
, mkdir = require('mkdirp') | ||
@@ -29,3 +33,3 @@ , processRelease = require('./process-release') | ||
function install (gyp, argv, callback) { | ||
function install (fs, gyp, argv, callback) { | ||
@@ -89,3 +93,3 @@ var release = processRelease(argv, gyp, process.version, process.release) | ||
} else if (err.code == 'EACCES') { | ||
eaccesFallback() | ||
eaccesFallback(err) | ||
} else { | ||
@@ -135,3 +139,3 @@ cb(err) | ||
if (err.code == 'EACCES') { | ||
eaccesFallback() | ||
eaccesFallback(err) | ||
} else { | ||
@@ -403,4 +407,4 @@ cb(err) | ||
// header files | ||
return minimatch(file, '*.h', { matchBase: true }) || | ||
minimatch(file, '*.gypi', { matchBase: true }) | ||
var extname = path.extname(file); | ||
return extname === '.h' || extname === '.gypi'; | ||
} | ||
@@ -417,3 +421,5 @@ | ||
function eaccesFallback () { | ||
function eaccesFallback (err) { | ||
var noretry = '--node_gyp_internal_noretry' | ||
if (-1 !== argv.indexOf(noretry)) return cb(err) | ||
var tmpdir = osenv.tmpdir() | ||
@@ -427,3 +433,3 @@ gyp.devDir = path.resolve(tmpdir, '.node-gyp') | ||
} | ||
gyp.commands.install(argv, cb) | ||
gyp.commands.install([noretry].concat(argv), cb) | ||
} | ||
@@ -430,0 +436,0 @@ |
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "3.6.3", | ||
"version": "3.7.0", | ||
"installVersion": 9, | ||
@@ -29,3 +29,2 @@ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)", | ||
"graceful-fs": "^4.1.2", | ||
"minimatch": "^3.0.2", | ||
"mkdirp": "^0.5.0", | ||
@@ -32,0 +31,0 @@ "nopt": "2 || 3", |
node-gyp | ||
========= | ||
### Node.js native addon build tool | ||
## Node.js native addon build tool | ||
@@ -17,3 +17,3 @@ `node-gyp` is a cross-platform command-line tool written in Node.js for compiling | ||
#### Features: | ||
## Features | ||
@@ -36,26 +36,43 @@ * Easy to use, consistent interface | ||
* On Unix: | ||
* `python` (`v2.7` recommended, `v3.x.x` is __*not*__ supported) | ||
* `make` | ||
* A proper C/C++ compiler toolchain, like [GCC](https://gcc.gnu.org) | ||
* On Mac OS X: | ||
* `python` (`v2.7` recommended, `v3.x.x` is __*not*__ supported) (already installed on Mac OS X) | ||
* [Xcode](https://developer.apple.com/xcode/download/) | ||
* You also need to install the `Command Line Tools` via Xcode. You can find this under the menu `Xcode -> Preferences -> Downloads` | ||
* This step will install `gcc` and the related toolchain containing `make` | ||
* On Windows: | ||
* Option 1: Install all the required tools and configurations using Microsoft's [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools) using `npm install --global --production windows-build-tools` from an elevated PowerShell or CMD.exe (run as Administrator). | ||
* Option 2: Install tools and configuration manually: | ||
* Visual C++ Build Environment: | ||
* Option 1: Install [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools) using the **Default Install** option. | ||
### On Unix | ||
* Option 2: Install [Visual Studio 2015](https://www.visualstudio.com/products/visual-studio-community-vs) (or modify an existing installation) and select *Common Tools for Visual C++* during setup. This also works with the free Community and Express for Desktop editions. | ||
* `python` (`v2.7` recommended, `v3.x.x` is __*not*__ supported) | ||
* `make` | ||
* A proper C/C++ compiler toolchain, like [GCC](https://gcc.gnu.org) | ||
> :bulb: [Windows Vista / 7 only] requires [.NET Framework 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40773) | ||
### On macOS | ||
* Install [Python 2.7](https://www.python.org/downloads/) (`v3.x.x` is not supported), and run `npm config set python python2.7` (or see below for further instructions on specifying the proper Python version and path.) | ||
* Launch cmd, `npm config set msvs_version 2015` | ||
* `python` (`v2.7` recommended, `v3.x.x` is __*not*__ supported) (already installed on macOS) | ||
* [Xcode](https://developer.apple.com/xcode/download/) | ||
* You also need to install the `Command Line Tools` via Xcode. You can find this under the menu `Xcode -> Preferences -> Downloads` (or by running `xcode-select --install` in your Terminal) | ||
* This step will install `gcc` and the related toolchain containing `make` | ||
If the above steps didn't work for you, please visit [Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules) for additional tips. | ||
### On Windows | ||
#### Option 1 | ||
Install all the required tools and configurations using Microsoft's [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools) using `npm install --global --production windows-build-tools` from an elevated PowerShell or CMD.exe (run as Administrator). | ||
#### Option 2 | ||
Install tools and configuration manually: | ||
* Visual C++ Build Environment: | ||
* Option 1: Install [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools) using the **Default Install** option. | ||
* Option 2: Install [Visual Studio 2015](https://www.visualstudio.com/products/visual-studio-community-vs) and select *Common Tools for Visual C++* during setup. This also works with the free Community and Express for Desktop editions. | ||
* Option 3: if you already have Visual Studio 2015 installed and did not install the | ||
*Common Tools for Visual C++* during setup, you can `File -> New -> Project`, pick | ||
any of the options under `Templates -> Other Languages -> Visual C++` then `Ok` | ||
and Visual Studio will offer to install the *Common Tools for Visual C++* with a | ||
"Install Missing Features" / "You need the Universal Windows App Development Tools | ||
to develop Windows app projects." dialog. | ||
> :bulb: [Windows Vista / 7 only] requires [.NET Framework 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40773) | ||
* Install [Python 2.7](https://www.python.org/downloads/) (`v3.x.x` is not supported), and run `npm config set python python2.7` (or see below for further instructions on specifying the proper Python version and path.) | ||
* Launch cmd, `npm config set msvs_version 2015` | ||
If the above steps didn't work for you, please visit [Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules) for additional tips. | ||
If you have multiple Python versions installed, you can identify which Python | ||
@@ -76,6 +93,2 @@ version `node-gyp` uses by setting the '--python' variable: | ||
Note that OS X is just a flavour of Unix and so needs `python`, `make`, and C/C++. | ||
An easy way to obtain these is to install XCode from Apple, | ||
and then use it to install the command line tools (under Preferences -> Downloads). | ||
How to Use | ||
@@ -192,3 +205,3 @@ ---------- | ||
| `--cafile=$cafile` | Override default CA chain (to download tarball) | ||
| `--nodedir=$path` | Set the path to the node binary | ||
| `--nodedir=$path` | Set the path to the node source code | ||
| `--python=$path` | Set path to the python (2) binary | ||
@@ -195,0 +208,0 @@ | `--msvs_version=$version` | Set Visual Studio version (win) |
'use strict' | ||
var test = require('tape') | ||
var execFile = require('child_process').execFile | ||
var path = require('path') | ||
var fs = require('graceful-fs') | ||
var child_process = require('child_process') | ||
var addonPath = path.resolve(__dirname, 'node_modules', 'hello_world') | ||
var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js') | ||
var execFileSync = child_process.execFileSync | ||
var execFile = child_process.execFile | ||
function runHello() { | ||
var testCode = "console.log(require('hello_world').hello())" | ||
return execFileSync('node', ['-e', testCode], { cwd: __dirname }).toString() | ||
} | ||
function getEncoding() { | ||
var code = 'import locale;print locale.getdefaultlocale()[1]' | ||
return execFileSync('python', ['-c', code]).toString().trim() | ||
} | ||
function checkCharmapValid() { | ||
var data | ||
try { | ||
data = execFileSync('python', ['fixtures/test-charmap.py'], | ||
{ cwd: __dirname }) | ||
} catch (err) { | ||
return false | ||
} | ||
var lines = data.toString().trim().split('\n') | ||
return lines.pop() === 'True' | ||
} | ||
test('build simple addon', function (t) { | ||
@@ -19,8 +44,68 @@ t.plan(3) | ||
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok') | ||
t.strictEqual(runHello().trim(), 'world') | ||
}) | ||
proc.stdout.setEncoding('utf-8') | ||
proc.stderr.setEncoding('utf-8') | ||
}) | ||
test('build simple addon in path with non-ascii characters', function (t) { | ||
t.plan(1) | ||
if (!checkCharmapValid()) { | ||
return t.skip('python console app can\'t encode non-ascii character.') | ||
} | ||
var testDirNames = { | ||
'cp936': '文件夹', | ||
'cp1252': 'Latīna', | ||
'cp932': 'フォルダ' | ||
} | ||
// Select non-ascii characters by current encoding | ||
var testDirName = testDirNames[getEncoding()] | ||
// If encoding is UTF-8 or other then no need to test | ||
if (!testDirName) { | ||
return t.skip('no need to test') | ||
} | ||
t.plan(3) | ||
var data, configPath = path.join(addonPath, 'build', 'config.gypi') | ||
try { | ||
data = fs.readFileSync(configPath, 'utf8') | ||
} catch (err) { | ||
t.error(err) | ||
return | ||
} | ||
var config = JSON.parse(data.replace(/\#.+\n/, '')) | ||
var nodeDir = config.variables.nodedir | ||
var testNodeDir = path.join(addonPath, testDirName) | ||
// Create symbol link to path with non-ascii characters | ||
try { | ||
fs.symlinkSync(nodeDir, testNodeDir, 'dir') | ||
} catch (err) { | ||
switch (err.code) { | ||
case 'EEXIST': break | ||
case 'EPERM': | ||
t.error(err, 'Please try to running console as an administrator') | ||
return | ||
default: | ||
t.error(err) | ||
return | ||
} | ||
} | ||
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, | ||
'--loglevel=verbose', '-nodedir=' + testNodeDir] | ||
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) { | ||
try { | ||
var binding = require('hello_world') | ||
t.strictEqual(binding.hello(), 'world') | ||
} catch (error) { | ||
t.error(error, 'load module') | ||
fs.unlink(testNodeDir) | ||
} catch (err) { | ||
t.error(err) | ||
} | ||
var logLines = stderr.toString().trim().split(/\r?\n/) | ||
var lastLine = logLines[logLines.length-1] | ||
t.strictEqual(err, null) | ||
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok') | ||
t.strictEqual(runHello().trim(), 'world') | ||
}) | ||
@@ -27,0 +112,0 @@ proc.stdout.setEncoding('utf-8') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
12
3054
256
1595931
107
- Removedminimatch@^3.0.2