diff --git a/lib/build.js b/lib/build.js index 0ed369e..cd3ed5e 100644 --- a/lib/build.js +++ b/lib/build.js @@ -13,21 +13,37 @@ var ntr = require('ntr') , modified = require('./modified') , dirscanproject = require('./projectscan'); +// convert filename to object function toO(file){return toExt(file,'.o');} module.exports = LeoBuild; +// The constructor sets the build environment: +// - includes from Arduino project +// - libs +// - original env function LeoBuild(env){ + if (!env) { + env = {}; + } + if(!this instanceof LeoBuild) return new LeoBuild(); this.includes = [].concat(env.includes); this.libs = []; this.env = env; + + // to enable verbose output + this.verbose = env.verbose ? true : false; } LeoBuild.prototype.makeBuildDir = function(){ - fs.mkdirSync(this.env.build.path); + var path = this.env.build.path; + if (this.vebose) { + console.log('... create build path: ' + path); + } + fs.mkdirSync(path); }; LeoBuild.prototype.clean = function(){ diff --git a/test/build.js b/test/build.js new file mode 100644 index 0000000..904d2db --- /dev/null +++ b/test/build.js @@ -0,0 +1,23 @@ +var test = require('tape'); +var LeoBuild = require('../lib/build'); + +test("init leoBuild",function(t){ + var leoBuild = new LeoBuild(); + + t.ok(leoBuild.includes, [], 'no default includes'); + t.ok(leoBuild.libs, [], 'no default libs'); + t.ok(leoBuild.env, [], 'no default env'); + t.notOk(leoBuild.verbose, true, 'no verbose output'); + + t.end(); + +}); + +test("init leoBuild with verbose output",function(t){ + var leoBuild = new LeoBuild({verbose: true}); + + t.ok(leoBuild.verbose, true, 'enables verbose output'); + + t.end(); + +});