mirror of
https://github.com/hanzoai/node-dtrace-provider.git
synced 2026-09-23 23:48:45 +00:00
support installing without compiling
Some platforms may not have a compiler, or be appropriate for use with dtrace-provider. On those environments allow the build to succeed and rely on the stub implementations instead. This will squelch all build output, which may be loud and noisey for end users. If you want to see build output set the environment variable V to anything.
This commit is contained in:
@@ -18,5 +18,8 @@
|
||||
"devDependencies": {
|
||||
"tap": ">=0.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"preinstall": "scripts/preinstall.js"
|
||||
},
|
||||
"main" : "./dtrace-provider.js"
|
||||
}
|
||||
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var movedFile = false;
|
||||
|
||||
if (["linux", "win32"].indexOf(process.platform) !== -1)
|
||||
return;
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
var src = path.join(__dirname, '..', 'compile.py');
|
||||
var dst = path.join(__dirname, '..', 'binding.gyp');
|
||||
|
||||
fs.renameSync(src, dst);
|
||||
|
||||
movedFile = true;
|
||||
|
||||
var nodegyp = path.join(process.execPath,
|
||||
'..',
|
||||
'..',
|
||||
'lib',
|
||||
'node_modules',
|
||||
'npm',
|
||||
'bin',
|
||||
'node-gyp-bin',
|
||||
'node-gyp');
|
||||
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
var stdio = 'ignore';
|
||||
|
||||
if (process.env.V)
|
||||
stdio = 'inherit';
|
||||
|
||||
var options = {
|
||||
cwd: path.join(__dirname, '..'),
|
||||
stdio: stdio
|
||||
};
|
||||
|
||||
var child = spawn(nodegyp, ['rebuild'], options);
|
||||
|
||||
child.on('close', function(code, signal) {
|
||||
if ((code || signal) && process.env.V === undefined) {
|
||||
console.error('---------------');
|
||||
console.error('Building dtrace-provider failed with exit code %d and signal %d',
|
||||
code, signal);
|
||||
console.error('re-run install with environment variable V set to see the build output');
|
||||
console.error('---------------');
|
||||
}
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
if (movedFile)
|
||||
fs.renameSync(dst, src);
|
||||
});
|
||||
Reference in New Issue
Block a user