This commit is contained in:
Nishi 2026-05-09 17:40:43 +09:00
commit 7278e994da
Signed by: nishi
GPG key ID: 27EF69B208EB9343
14 changed files with 128 additions and 40 deletions

View file

@ -1,7 +1,5 @@
const PADDING = 24;
pmake.compiler = pmake.compilers["GCC"];
for(var i = 1; i < ARGV.length; i++) {
if(ARGV[i] == "--help") {
var keys;
@ -79,6 +77,8 @@ for(var i = 1; i < ARGV.length; i++) {
}
}
main();
(function() {
function make(output) {
const targets = pmake.resolveProjects(pmake.projects);
@ -134,8 +134,10 @@ function make(output) {
mk.write("\n");
mk.write(pmake.compiler.output(self) + ": " + objs.join(" ") + "\n");
mk.write(" @echo LINK " + pmake.compiler.output(self) + "\n");
mk.write(" $(SILENT)" + pmake.compiler.link(self, objs) + "\n");
if(!(self instanceof pmake.InterfaceProject)) {
mk.write(" @echo LINK " + pmake.compiler.output(self) + "\n");
mk.write(" $(SILENT)" + pmake.compiler.link(self, objs) + "\n");
}
mk.write("\n");
for(var i = 0; i < objs.length; i++) {

View file

@ -21,6 +21,7 @@ if(!Array.prototype.flat) {
const pmake = {
VERSION : "0.0",
compilers : {},
systems : {},
options : {},
options_category : {},
projects : []
@ -53,6 +54,8 @@ pmake.inherited = function(base, parent) {
pmake.register = function(target) {
if(target instanceof pmake.Compiler) {
pmake.compilers[target.target] = target;
} else if(target instanceof pmake.System) {
pmake.systems[target.target] = target;
} else if(target instanceof pmake.Option) {
if(!pmake.options_category[target.category]) pmake.options_category[target.category] = {};
@ -118,11 +121,26 @@ pmake.libs = function(target, if_str) {
return targets.map(libs).flat();
};
pmake.setSystem = function(target){
pmake.system = pmake.systems[target];
if(pmake.system.init) pmake.system.init();
};
pmake.setCompiler = function(target){
pmake.compiler = pmake.compilers[target];
if(pmake.compiler.init) pmake.compiler.init();
};
(function() {
const Compiler = function() {
this.prefix = "";
};
Compiler.prototype.init = function() {
};
Compiler.prototype.output = function(target) {
if((typeof target) == "string") {
if(target.endsWith(".c")) return target.replace(/\.c$/, ".o");
@ -180,6 +198,11 @@ POSIXCompiler.prototype.link = function(target, files) {
return "";
}
const System = function() {};
System.prototype.init = function() {
};
const Option = function() {};
const Project = function(target) {
@ -216,6 +239,7 @@ File.prototype.close = function() {
pmake.Compiler = Compiler;
pmake.POSIXCompiler = POSIXCompiler;
pmake.System = System;
pmake.Option = Option;
pmake.Project = Project;
pmake.LibraryProject = LibraryProject;
@ -238,8 +262,24 @@ Compiler.options = function() {
};
Compiler.action = function(value) {
pmake.compiler = pmake.compilers[value];
pmake.setCompiler(value);
};
const System = new pmake.Option();
System.category = "General";
System.target = "system";
System.description = "Generate files for a different system; one of:";
System.option = "VALUE";
System.options = function() {
return Object.keys(pmake.systems);
};
System.action = function(value) {
pmake.setSystem(value);
};
pmake.register(Compiler);
pmake.register(System);
})();

7
src/js/postinit.js Normal file
View file

@ -0,0 +1,7 @@
pmake.setCompiler("GCC");
if(WIN32) {
pmake.setSystem("Windows");
}else{
pmake.setSystem("Unix");
}