diff --git a/src/action/gmake.js b/src/action/gmake.js index e69de29..555b12b 100644 --- a/src/action/gmake.js +++ b/src/action/gmake.js @@ -0,0 +1,6 @@ +const gmake = pmake.inherit(pmake.Action); + +gmake.target = "gmake"; +gmake.description = "GNU Make"; + +pmake.register(gmake); diff --git a/src/compiler/gcc.js b/src/compiler/gcc.js index d151bb8..0ffa542 100644 --- a/src/compiler/gcc.js +++ b/src/compiler/gcc.js @@ -1,6 +1,6 @@ -const GCC = pmake.inherit(Compiler); +const GCC = pmake.inherit(pmake.Compiler); -GCC.name = "GCC"; +GCC.target = "GCC"; GCC.description = "GCC/Clang"; pmake.register(GCC); diff --git a/src/compiler/watcom.js b/src/compiler/watcom.js index 7e3e6d8..3a987f9 100644 --- a/src/compiler/watcom.js +++ b/src/compiler/watcom.js @@ -1,6 +1,6 @@ -const Watcom = pmake.inherit(Compiler); +const Watcom = pmake.inherit(pmake.Compiler); -Watcom.name = "Watcom"; +Watcom.target = "Watcom"; Watcom.description = "Open Watcom"; pmake.register(Watcom); diff --git a/src/js/cmdline.js b/src/js/cmdline.js index 7d43e4c..daee9a4 100644 --- a/src/js/cmdline.js +++ b/src/js/cmdline.js @@ -1,19 +1,34 @@ -if(ARGV.length == 1) { - console.log("Type '" + ARGV[0] + " --help' for help"); - process.exit(1); -} +const PADDING = 16; +var action; for(var i = 1; i < ARGV.length; i++) { if(ARGV[i] == "--help") { + var keys; + console.log("PMake " + pmake.VERSION + " - Pyrite's build script generator"); console.log(""); console.log("Usage: " + ARGV[0] + " [options] action [arguments]"); + console.log(""); + console.log("ACTIONS"); + + keys = Object.keys(pmake.actions); + for(var i = 0; i < keys.length; i++) { + console.log(" " + keys[i] + " ".repeat(PADDING - keys[i].length) + pmake.actions[keys[i]].description); + } process.exit(0); } else if(ARGV[i].startsWith("--")) { console.log("Error: invalid option '" + ARGV[i].substr(2) + "'"); process.exit(1); + } else if(pmake.actions[ARGV[i]]) { + action = ARGV[i]; + break; } else { console.log("Error: no such action '" + ARGV[i] + "'"); process.exit(1); } } + +if(!action) { + console.log("Type '" + ARGV[0] + " --help' for help"); + process.exit(1); +} diff --git a/src/js/core.js b/src/js/core.js index f3205d4..60ea0c4 100644 --- a/src/js/core.js +++ b/src/js/core.js @@ -1,5 +1,7 @@ const pmake = { - VERSION : "0.0" + VERSION : "0.0", + actions : {}, + compilers : {} }; pmake.inherit = function(base) { @@ -23,9 +25,15 @@ pmake.inherited = function(base, parent) { }; pmake.register = function(base) { - if(pmake.inherited(base, Compiler)) { + if(pmake.inherited(base, pmake.Compiler)) { + pmake.compilers[base.target] = base; + } else if(pmake.inherited(base, pmake.Action)) { + pmake.actions[base.target] = base; } }; -function Compiler() { -} +pmake.Compiler = function() { +}; + +pmake.Action = function() { +};