const pmake = { VERSION : "0.0", compilers : {}, options : {}, projects : [] }; pmake.inherit = function(base, call) { const func = (function() {}); Object.setPrototypeOf(func.prototype, base.prototype); return func; }; pmake.inherited = function(base, parent) { var proto = base.prototype; while(proto) { if(proto == parent.prototype) return true; proto = Object.getPrototypeOf(proto); } return false; }; pmake.register = function(base) { if(base instanceof pmake.Compiler) { pmake.compilers[base.target] = base; } else if(base instanceof pmake.Option) { if(!pmake.options[base.category]) pmake.options[base.category] = {}; pmake.options[base.category][base.target] = base; } else if(base instanceof pmake.Project) { pmake.projects.push(base); } }; pmake.resolveProjects = function(arr) { var r = []; for(var i = 0; i < arr.length; i++) { if(arr[i] instanceof pmake.Project) { r = r.concat(pmake.resolveProjects(arr[i].libraries)); r.push(arr[i]); } } return r; }; (function() { const Compiler = function() {}; const POSIXCompiler = pmake.inherit(Compiler); const Option = function() {}; const Project = function(target) { this.target = target; this.files = []; this.libraries = []; }; Project.prototype.generate = function() { }; const File = function(filename, mode) { this.fp = fs.open(filename, mode); }; File.prototype.write = function(string) { fs.write(this.fp, string); }; File.prototype.close = function() { fs.close(this.fp); }; pmake.Compiler = Compiler; pmake.POSIXCompiler = POSIXCompiler; pmake.Option = Option; pmake.Project = Project; pmake.File = File; })(); /*** Option ***/ (function() { const Compiler = new pmake.Option(); Compiler.category = "General"; Compiler.target = "compiler"; Compiler.description = "Choose a compiler set; one of:"; Compiler.option = "VALUE"; Compiler.options = function() { return Object.keys(pmake.compilers); }; pmake.register(Compiler); })();