Skip to content

Commit

Permalink
deps: make node-gyp work with io.js
Browse files Browse the repository at this point in the history
Every npm version bump requires a few patches to be floated on
node-gyp for io.js compatibility. These patches are found in
03d1992,
5de334c, and
da730c7. This commit squashes
them into a single commit.

PR-URL: nodejs/node#990
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
cjihrig authored and piscisaureus committed Mar 26, 2015
1 parent 1670d26 commit f50d419
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion addon.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
'-luuid.lib',
'-lodbc32.lib',
'-lDelayImp.lib',
'-l"<(node_root_dir)/$(ConfigurationName)/node.lib"'
'-l"<(node_root_dir)/$(ConfigurationName)/iojs.lib"'
],
# warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persistent<T>'
# needs to have dll-interface to be used by clients of class 'node::ObjectWrap'
Expand Down
8 changes: 4 additions & 4 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,23 @@ function build (gyp, argv, callback) {
}

/**
* Copies the node.lib file for the current target architecture into the
* Copies the iojs.lib file for the current target architecture into the
* current proper dev dir location.
*/

function copyNodeLib () {
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, 'iojs.lib')
, buildNodeLibPath = path.resolve(buildDir, 'iojs.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 "iojs.lib" for ' + arch, buildNodeLibPath)
rs.pipe(ws)
rs.on('error', callback)
ws.on('error', callback)
Expand Down
40 changes: 20 additions & 20 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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 || 'https://iojs.org/dist'


// Determine which node dev files version we are installing
Expand Down Expand Up @@ -185,7 +185,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 + '/iojs-v' + version + '.tar.gz'
, badDownload = false
, extractCount = 0
, gunzip = zlib.createGunzip()
Expand Down Expand Up @@ -267,7 +267,7 @@ function install (gyp, argv, callback) {
var async = 0

if (win) {
// need to download node.lib
// need to download iojs.lib
async++
downloadNodeLib(deref)
}
Expand Down Expand Up @@ -343,36 +343,36 @@ function install (gyp, argv, callback) {
}

function downloadNodeLib (done) {
log.verbose('on Windows; need to download `node.lib`...')
log.verbose('on Windows; need to download `iojs.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'
, nodeLibPath32 = path.resolve(dir32, 'iojs.lib')
, nodeLibPath64 = path.resolve(dir64, 'iojs.lib')
, nodeLibUrl32 = distUrl + '/v' + version + '/win-x86/iojs.lib'
, nodeLibUrl64 = distUrl + '/v' + version + '/win-x64/iojs.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)
log.verbose('32-bit iojs.lib dir', dir32)
log.verbose('64-bit iojs.lib dir', dir64)
log.verbose('`iojs.lib` 32-bit url', nodeLibUrl32)
log.verbose('`iojs.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 iojs.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 iojs.lib'))
return
}

getContentSha(res, function (_, checksum) {
contentShasums['node.lib'] = checksum
log.verbose('content checksum', 'node.lib', checksum)
contentShasums['win-x86/iojs.lib'] = checksum
log.verbose('content checksum', 'win-x86/iojs.lib', checksum)
})

var ws = fs.createWriteStream(nodeLibPath32)
Expand All @@ -385,20 +385,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 iojs.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 iojs.lib'))
return
}

getContentSha(res, function (_, checksum) {
contentShasums['x64/node.lib'] = checksum
log.verbose('content checksum', 'x64/node.lib', checksum)
contentShasums['win-x64/iojs.lib'] = checksum
log.verbose('content checksum', 'win-x64/iojs.lib', checksum)
})

var ws = fs.createWriteStream(nodeLibPath64)
Expand Down

0 comments on commit f50d419

Please sign in to comment.