Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
23 changes: 23 additions & 0 deletions test/build.js
Original file line number Diff line number Diff line change
@@ -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();

});