3 module.exports = exports = build;
5 exports.usage = 'Attempts to compile the module by dispatching to node-gyp or nw-gyp';
7 var napi = require('./util/napi.js');
8 var compile = require('./util/compile.js');
9 var handle_gyp_opts = require('./util/handle_gyp_opts.js');
10 var configure = require('./configure.js');
12 function do_build(gyp,argv,callback) {
13 handle_gyp_opts(gyp,argv,function(err,result) {
14 var final_args = ['build'].concat(result.gyp).concat(result.pre);
15 if (result.unparsed.length > 0) {
16 final_args = final_args.
18 concat(result.unparsed);
20 if (!err && result.opts.napi_build_version) {
21 napi.swap_build_dir_in(result.opts.napi_build_version);
23 compile.run_gyp(final_args,result.opts,function(err) {
24 if (result.opts.napi_build_version) {
25 napi.swap_build_dir_out(result.opts.napi_build_version);
32 function build(gyp, argv, callback) {
34 // Form up commands to pass to node-gyp:
35 // We map `node-pre-gyp build` to `node-gyp configure build` so that we do not
36 // trigger a clean and therefore do not pay the penalty of a full recompile
37 if (argv.length && (argv.indexOf('rebuild') > -1)) {
38 argv.shift(); // remove `rebuild`
39 // here we map `node-pre-gyp rebuild` to `node-gyp rebuild` which internally means
40 // "clean + configure + build" and triggers a full recompile
41 compile.run_gyp(['clean'],{},function(err) {
42 if (err) return callback(err);
43 configure(gyp,argv,function(err) {
44 if (err) return callback(err);
45 return do_build(gyp,argv,callback);
49 return do_build(gyp,argv,callback);