1 |
|
2 | (function() {
|
3 | var Config, build, path, spawn;
|
4 |
|
5 | path = require('path');
|
6 |
|
7 | spawn = require('child_process').spawn;
|
8 |
|
9 | Config = require('./config');
|
10 |
|
11 | module.exports.build = build = function() {
|
12 | var args, featurePath, make, projectRoot, target;
|
13 | projectRoot = Config.projectRoot();
|
14 | featurePath = path.relative(projectRoot, process.cwd());
|
15 | console.log('------------------------------');
|
16 | console.log("project root is " + projectRoot);
|
17 | target = process.argv[2];
|
18 | if (target) {
|
19 | target = path.join(featurePath, target);
|
20 | } else {
|
21 | target = featurePath;
|
22 | }
|
23 | args = ['-C', projectRoot];
|
24 | if (target) {
|
25 | console.log("building '" + target + "'");
|
26 | args.push(target);
|
27 | } else {
|
28 | console.log('building default target');
|
29 | }
|
30 | make = spawn('make', args);
|
31 | make.stdout.pipe(process.stdout);
|
32 | make.stderr.pipe(process.stderr);
|
33 | return make.on('close', function(exitCode) {
|
34 | console.log('------------------------------');
|
35 | if (exitCode !== 0) {
|
36 | console.log("make exit code is " + exitCode);
|
37 | process.exit(exitCode);
|
38 | }
|
39 | console.log('done');
|
40 | return process.exit(exitCode);
|
41 | });
|
42 | };
|
43 |
|
44 | if (require.main === module) {
|
45 | build();
|
46 | }
|
47 |
|
48 | }).call(this);
|