This commit is contained in:
Nishi 2026-05-09 03:16:12 +09:00
commit d951a0bceb
Signed by: nishi
GPG key ID: 27EF69B208EB9343
15 changed files with 381 additions and 90 deletions

View file

@ -1,11 +1,12 @@
const pmake = {
VERSION : "0.0",
actions : {},
compilers : {}
compilers : {},
options : {},
projects : []
};
pmake.inherit = function(base) {
const func = function() {};
pmake.inherit = function(base, call) {
const func = (function() {});
Object.setPrototypeOf(func.prototype, base.prototype);
@ -25,15 +26,77 @@ pmake.inherited = function(base, parent) {
};
pmake.register = function(base) {
if(pmake.inherited(base, pmake.Compiler)) {
if(base instanceof pmake.Compiler) {
pmake.compilers[base.target] = base;
} else if(pmake.inherited(base, pmake.Action)) {
pmake.actions[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.Compiler = function() {
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;
};
pmake.Action = function() {
(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);
})();