-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add io.js support #564
Add io.js support #564
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
test: build-buffertools build-leveldown | ||
|
||
build-buffertools: | ||
cd node_modules/buffertools/ && \ | ||
../../bin/node-gyp.js rebuild | ||
|
||
build-leveldown: | ||
cd node_modules/leveldown/ && \ | ||
../../bin/node-gyp.js rebuild | ||
|
||
test-docker-node: | ||
docker run \ | ||
--rm=true -i -v `pwd`:/opt/node-gyp/ \ | ||
nodesource/node:wheezy \ | ||
bash -c 'rm -rf /root/.node-gyp/ && cd /opt/node-gyp && make test' | ||
|
||
test-docker-iojs: | ||
docker run \ | ||
--rm=true -i -v `pwd`:/opt/node-gyp/ \ | ||
iojs/iojs:1.0 \ | ||
bash -c 'rm -rf /root/.node-gyp/ && cd /opt/node-gyp && make test' | ||
|
||
test-docker: test-docker-node test-docker-iojs |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ var fs = require('graceful-fs') | |
, mkdirp = require('mkdirp') | ||
, exec = require('child_process').exec | ||
, win = process.platform == 'win32' | ||
, semver = require('semver') | ||
, runtime = semver.parse(process.version).major < 1 ? 'node' : 'iojs' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this be a problem when node v1 is released? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can there be an override for this as an env variable? e.g. tcr/pangyp@b9209b8 If I want to enable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in iojs you can check for To set as a target I would recommend to use same notation as nvm: |
||
|
||
exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module' | ||
|
||
|
@@ -181,15 +183,15 @@ function build (gyp, argv, callback) { | |
if (!win || !copyDevLib) return doBuild() | ||
|
||
var buildDir = path.resolve(nodeDir, buildType) | ||
, archNodeLibPath = path.resolve(nodeDir, arch, 'node.lib') | ||
, buildNodeLibPath = path.resolve(buildDir, 'node.lib') | ||
, archNodeLibPath = path.resolve(nodeDir, arch, runtime + '.lib') | ||
, buildNodeLibPath = path.resolve(buildDir, runtime + '.lib') | ||
|
||
mkdirp(buildDir, function (err, isNew) { | ||
if (err) return callback(err) | ||
log.verbose('"' + buildType + '" dir needed to be created?', isNew) | ||
var rs = fs.createReadStream(archNodeLibPath) | ||
, ws = fs.createWriteStream(buildNodeLibPath) | ||
log.verbose('copying "node.lib" for ' + arch, buildNodeLibPath) | ||
log.verbose('copying "' + runtime + '.lib" for ' + arch, buildNodeLibPath) | ||
rs.pipe(ws) | ||
rs.on('error', callback) | ||
ws.on('error', callback) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ var fs = require('graceful-fs') | |
, minimatch = require('minimatch') | ||
, mkdir = require('mkdirp') | ||
, win = process.platform == 'win32' | ||
, runtime = semver.parse(process.version).major < 1 ? 'node' : 'iojs' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Longer-term, I'd really like to see iojs add an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. This is pretty lame. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. discussion here nodejs/node#491 |
||
, defaultDisturl = runtime == 'node' ? 'http://nodejs.org/dist' : 'https://iojs.org/dist' | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any idea to support nvm custom dist url env by default? https://github.com/creationix/nvm/blob/master/nvm.sh#L73 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fengmk2 would this be to support mirrors, like in China? I'm tinkering around in there currently and it wouldn't be hard to bring in custom URLs from where my local version is at. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not only for mirrors, but also can be used in private NPM services. @rvagg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rvagg yes, it will be very helpful for us. |
||
function install (gyp, argv, callback) { | ||
|
||
|
@@ -39,7 +41,7 @@ function install (gyp, argv, callback) { | |
} | ||
} | ||
|
||
var distUrl = gyp.opts['dist-url'] || gyp.opts.disturl || 'http://nodejs.org/dist' | ||
var distUrl = gyp.opts['dist-url'] || gyp.opts.disturl || defaultDisturl | ||
|
||
|
||
// Determine which node dev files version we are installing | ||
|
@@ -185,7 +187,7 @@ function install (gyp, argv, callback) { | |
|
||
// now download the node tarball | ||
var tarPath = gyp.opts['tarball'] | ||
var tarballUrl = tarPath ? tarPath : distUrl + '/v' + version + '/node-v' + version + '.tar.gz' | ||
var tarballUrl = tarPath ? tarPath : distUrl + '/v' + version + '/' + runtime + '-v' + version + '.tar.gz' | ||
, badDownload = false | ||
, extractCount = 0 | ||
, gunzip = zlib.createGunzip() | ||
|
@@ -343,36 +345,38 @@ function install (gyp, argv, callback) { | |
} | ||
|
||
function downloadNodeLib (done) { | ||
log.verbose('on Windows; need to download `node.lib`...') | ||
log.verbose('on Windows; need to download `' + runtime + '.lib`...') | ||
var dir32 = path.resolve(devDir, 'ia32') | ||
, dir64 = path.resolve(devDir, 'x64') | ||
, nodeLibPath32 = path.resolve(dir32, 'node.lib') | ||
, nodeLibPath64 = path.resolve(dir64, 'node.lib') | ||
, nodeLibUrl32 = distUrl + '/v' + version + '/node.lib' | ||
, nodeLibUrl64 = distUrl + '/v' + version + '/x64/node.lib' | ||
|
||
log.verbose('32-bit node.lib dir', dir32) | ||
log.verbose('64-bit node.lib dir', dir64) | ||
log.verbose('`node.lib` 32-bit url', nodeLibUrl32) | ||
log.verbose('`node.lib` 64-bit url', nodeLibUrl64) | ||
, nodeLibPath32 = path.resolve(dir32, runtime + '.lib') | ||
, nodeLibPath64 = path.resolve(dir64, runtime + '.lib') | ||
, nodeLibUrlFile32 = (runtime == 'node' ? 'node.lib' : 'win-x86/iojs.lib') | ||
, nodeLibUrlFile64 = (runtime == 'node' ? 'x64/node.lib' : 'win-x64/iojs.lib') | ||
, nodeLibUrl32 = distUrl + '/v' + version + '/' + nodeLibUrlFile32 | ||
, nodeLibUrl64 = distUrl + '/v' + version + '/' + nodeLibUrlFile64 | ||
|
||
log.verbose('32-bit ' + runtime + '.lib dir', dir32) | ||
log.verbose('64-bit ' + runtime + '.lib dir', dir64) | ||
log.verbose('`' + runtime + '.lib` 32-bit url', nodeLibUrl32) | ||
log.verbose('`' + runtime + '.lib` 64-bit url', nodeLibUrl64) | ||
|
||
var async = 2 | ||
mkdir(dir32, function (err) { | ||
if (err) return done(err) | ||
log.verbose('streaming 32-bit node.lib to:', nodeLibPath32) | ||
log.verbose('streaming 32-bit ' + runtime + '.lib to:', nodeLibPath32) | ||
|
||
var req = download(nodeLibUrl32) | ||
if (!req) return | ||
req.on('error', done) | ||
req.on('response', function (res) { | ||
if (res.statusCode !== 200) { | ||
done(new Error(res.statusCode + ' status code downloading 32-bit node.lib')) | ||
done(new Error(res.statusCode + ' status code downloading 32-bit ' + runtime + '.lib')) | ||
return | ||
} | ||
|
||
getContentSha(res, function (_, checksum) { | ||
contentShasums['node.lib'] = checksum | ||
log.verbose('content checksum', 'node.lib', checksum) | ||
contentShasums[nodeLibUrlFile32] = checksum | ||
log.verbose('content checksum', nodeLibUrlFile32, checksum) | ||
}) | ||
|
||
var ws = fs.createWriteStream(nodeLibPath32) | ||
|
@@ -385,20 +389,20 @@ function install (gyp, argv, callback) { | |
}) | ||
mkdir(dir64, function (err) { | ||
if (err) return done(err) | ||
log.verbose('streaming 64-bit node.lib to:', nodeLibPath64) | ||
log.verbose('streaming 64-bit ' + runtime + '.lib to:', nodeLibPath64) | ||
|
||
var req = download(nodeLibUrl64) | ||
if (!req) return | ||
req.on('error', done) | ||
req.on('response', function (res) { | ||
if (res.statusCode !== 200) { | ||
done(new Error(res.statusCode + ' status code downloading 64-bit node.lib')) | ||
done(new Error(res.statusCode + ' status code downloading 64-bit ' + runtime + '.lib')) | ||
return | ||
} | ||
|
||
getContentSha(res, function (_, checksum) { | ||
contentShasums['x64/node.lib'] = checksum | ||
log.verbose('content checksum', 'x64/node.lib', checksum) | ||
contentShasums[nodeLibUrlFile64] = checksum | ||
log.verbose('content checksum', nodeLibUrlFile64, checksum) | ||
}) | ||
|
||
var ws = fs.createWriteStream(nodeLibPath64) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,5 +37,9 @@ | |
}, | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
}, | ||
"devDependencies": { | ||
"buffertools": "~2.1.2", | ||
"leveldown": "~1.0.1" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and
build-leveldown
should probably depend on annpm install
task if you want these tests to be self-contained for CI.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
howso? that's why they are in devDependencies, doesn't that suffice?