Socket
Socket
Sign inDemoInstall

node-gyp

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-gyp - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2722/patch.gypi

2

lib/build.js

@@ -80,3 +80,3 @@

if (win && !hasSln) {
if (win) {
// did the user specify their own .sln file?

@@ -83,0 +83,0 @@ var hasSln = argv.some(function (arg) {

@@ -8,3 +8,5 @@

var path = require('path')
var fs = require('fs')
, path = require('path')
, glob = require('glob')
, win = process.platform == 'win32'

@@ -42,11 +44,19 @@

if (win) {
if (version < 0.8) {
// if < 0.8, we need to manually apply the patch at joyent/node#2685,
// since it got merged somewhere in 0.7.x.
argv.push('-Dnode_root_dir=' + devDir)
argv.push('-I')
argv.push(path.join(devDir, 'tools', 'patch.gypi'))
}
} else {
if (win && version < 0.8) {
gyp.verbose('on Windows and target version is less than 0.8; applying #2685 patch')
// if < 0.8, we need to manually apply the patch at joyent/node#2685,
// since it got merged somewhere in 0.7.x.
argv.push('-Dnode_root_dir=' + devDir)
argv.push('-I')
argv.push(path.join(devDir, 'tools', 'patch.gypi'))
}
if (!win && version < 0.8) {
gyp.verbose('on Unix and target version is less than 0.8; applying #2722 patch')
argv.push('-I')
argv.push(path.join(devDir, 'tools', 'patch2722.gypi'))
}
if (!win && !~argv.indexOf('-f') && !~argv.indexOf('--format')) {
gyp.verbose('gyp format was not specified; forcing "make"')
// use a 'gyp' suffix on the Makefile, as to not overwrite an existing one

@@ -60,2 +70,23 @@ argv.unshift('.gyp')

var hasArch = argv.some(function (arg) {
return arg.indexOf('-Dtarget_arch') === 0
})
// was --arch specified?
if (!hasArch && gyp.opts.arch) {
gyp.verbose('using the architecture specified by --arch', gyp.opts.arch)
argv.push('-Dtarget_arch=' + gyp.opts.arch)
hasArch = true
}
// this may need to be tweaked for windows and stuff, we'll see...
if (!hasArch) {
// on < 0.8 the target_arch variable is set to ia32 by default unless
// overridden, so we have to explicitly specify the arch here
gyp.verbose('target arch not specified, using the current host architecture', process.arch)
argv.push('-Dtarget_arch=' + process.arch)
gyp.opts.arch = process.arch
hasArch = true
}
// execute `gyp_addon` from the current target node version
argv.unshift(gyp_addon)

@@ -67,2 +98,6 @@ var cp = gyp.spawn(python, argv)

callback(new Error('`gyp_addon` failed with exit code: ' + code))
} else if (process.platform == 'darwin' && gyp.opts.arch != 'ia32') {
// XXX: Add a version check here when node upgrades gyp to a version that
// fixes this
remove_i386()
} else {

@@ -75,2 +110,68 @@ callback()

/**
* Removes the lines that contain '-arch i386' from any generated
* *.target.gyp.mk files. This works around a nasty gyp bug where they
* hard-code these flags in for some reason.
*/
function remove_i386 () {
glob('*.target.gyp.mk', function (err, files) {
if (err) return callback(err)
var count = files.length
if (count === 0) return callback()
files.forEach(function (filename) {
remove_i386single(filename, function (err) {
if (err) return callback(err)
--count || callback()
})
})
})
}
function remove_i386single (filename, done) {
gyp.verbose('removing "-arch i386" flag from', filename)
var rs = fs.createReadStream(filename)
, lines = []
rs.setEncoding('utf8')
emitLines(rs)
rs.on('line', function (line) {
// ignore lines containing the bad flag
if (!~line.indexOf('-arch i386')) {
lines.push(line)
}
})
rs.on('end', function () {
// now save the file back with the offending lines removed
fs.writeFile(filename, lines.join('\n'), function (err) {
if (err) return done(err)
done()
})
})
}
}
/**
* A quick little thingy that takes a Stream instance and makes it emit 'line'
* events when a newline is encountered.
*/
function emitLines (stream) {
var backlog = ''
stream.on('data', function (data) {
backlog += data
var n = backlog.indexOf('\n')
// got a \n? emit one or more 'line' events
while (~n) {
stream.emit('line', backlog.substring(0, n))
backlog = backlog.substring(n + 1)
n = backlog.indexOf('\n')
}
})
stream.on('end', function () {
if (backlog) {
stream.emit('line', backlog)
}
})
}

@@ -153,3 +153,4 @@

if (version === 0.6) {
if (version < 0.7) {
// copy over gyp_addon, addon.gypi and common.gypi
async++

@@ -163,7 +164,13 @@ copyLegacy(deref)

downloadNodeLib(deref)
}
// turn this into a <= when joyent/node#2685 lands
if (win && version < 0.8) {
// before node 0.8 we need to manually link to node.lib
async++
copy2685(deref)
}
if (!win && version < 0.8) {
async++
copy2722(deref)
}

@@ -265,3 +272,3 @@ function deref (err) {

function copy2685 (done) {
gyp.verbose('need to install the patch gypi file for version', version)
gyp.verbose('need to install the patch gypi file for #2685 for version', version)
var patchPath = path.join(__dirname, '..', '2685', 'patch.gypi')

@@ -274,3 +281,12 @@ , copyTo = path.join(devDir, 'tools', 'patch.gypi')

function copy2722 (done) {
gyp.verbose('need to install the patch gypi file for #2722 for version', version)
var patchPath = path.join(__dirname, '..', '2722', 'patch.gypi')
, copyTo = path.join(devDir, 'tools', 'patch2722.gypi')
gyp.verbose('patch.gypi', patchPath)
gyp.verbose('copy to', copyTo)
copy(patchPath, copyTo, done)
}
})

@@ -277,0 +293,0 @@

@@ -63,2 +63,3 @@

help: Boolean // everywhere
, arch: String // 'configure'
, debug: Boolean // 'build'

@@ -65,0 +66,0 @@ , ensure: Boolean // 'install'

{ "name": "node-gyp"
, "description": "Node.js native addon build tool"
, "keywords": [ "native", "addon", "module", "c", "c++", "bindings", "gyp" ]
, "version": "0.0.2"
, "version": "0.0.3"
, "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)"

@@ -6,0 +6,0 @@ , "repository": { "type": "git", "url": "git://github.com/TooTallNate/node-gyp.git" }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc