1 | "use strict";
|
2 |
|
3 | module.exports = exports = build;
|
4 |
|
5 | exports.usage = 'Attempts to compile the module by dispatching to node-gyp or nw-gyp';
|
6 |
|
7 | var compile = require('./util/compile.js');
|
8 | var handle_gyp_opts = require('./util/handle_gyp_opts.js');
|
9 | var configure = require('./configure.js');
|
10 |
|
11 | function do_build(gyp,argv,callback) {
|
12 | handle_gyp_opts(gyp,argv,function(err,result) {
|
13 | var final_args = ['build'].concat(result.gyp).concat(result.pre);
|
14 | if (result.unparsed.length > 0) {
|
15 | final_args = final_args.
|
16 | concat(['--']).
|
17 | concat(result.unparsed);
|
18 | }
|
19 | compile.run_gyp(final_args,result.opts,function(err) {
|
20 | return callback(err);
|
21 | });
|
22 | });
|
23 | }
|
24 |
|
25 | function build(gyp, argv, callback) {
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | if (argv.length && (argv.indexOf('rebuild') > -1)) {
|
31 |
|
32 |
|
33 | compile.run_gyp(['clean'],{},function(err) {
|
34 | if (err) return callback(err);
|
35 | configure(gyp,argv,function(err) {
|
36 | if (err) return callback(err);
|
37 | return do_build(gyp,argv,callback);
|
38 | });
|
39 | });
|
40 | } else {
|
41 | return do_build(gyp,argv,callback);
|
42 | }
|
43 | }
|