works for gcc

This commit is contained in:
Nishi 2026-05-09 16:39:35 +09:00
commit f5e4e6990b
Signed by: nishi
GPG key ID: 27EF69B208EB9343
3 changed files with 45 additions and 11 deletions

View file

@ -4,5 +4,38 @@ const Watcom = new pmake.Compiler();
Watcom.target = "Watcom";
Watcom.description = "Open Watcom";
pmake.register(Watcom);
Watcom.compile = function(target, obj, src) {
function add_i(x) {
return "-i=" + x;
}
const includes = pmake.includes(target).map(add_i).join(" ");
const flags = "-bt=nt -q " + includes + " -fo=" + obj + " " + src;
if(src.endsWith(".c")) {
return "wcc386 " + flags;
} else {
return "wpp386 " + flags;
}
return "";
};
Watcom.link = function(target, files) {
if(target instanceof pmake.LibraryProject) {
} else if(target instanceof pmake.ExecutableProject) {
function add_file(x) {
return "file \"" + x + "\"";
}
function add_library(x) {
return "library \"" + x + "\"";
}
return "wlink option quiet system nt name " + this.output(target) + " " + files.map(add_file).join(" ") + " " + pmake.libs(target).map(add_library).join(" ");
}
return "";
}
pmake.register(Watcom);
})();

View file

@ -130,17 +130,19 @@ function make(output) {
mk.write("\n");
mk.write(pmake.compiler.output(self) + ": " + objs.join(" ") + "\n");
mk.write(" " + pmake.compiler.link(self, objs) + "\n");
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++) {
mk.write(objs[i] + ": " + self.sources[i] + "\n");
mk.write(" " + pmake.compiler.compile(self, objs[i], self.sources[i]) + "\n");
mk.write(" @echo CC/CXX " + self.sources[i] + "\n");
mk.write(" $(SILENT)" + pmake.compiler.compile(self, objs[i], self.sources[i]) + "\n");
mk.write("\n");
}
mk.write("clean: \n");
mk.write(" $(SILENT)$(RM) " + pmake.compiler.output(self) + " *.o *.exe *.a *.lib *.so *.dll\n");
mk.write(" $(SILENT)$(RM) " + pmake.compiler.output(self) + " " + objs.join(" ") + "\n");
}
mk.close();

View file

@ -146,20 +146,19 @@ POSIXCompiler.prototype.compile = function(target, obj, src) {
return "-I" + x;
}
const includes = pmake.includes(target).map(add_i)
if(includes.length > 0) includes = " " + includes.join(" ");
const includes = pmake.includes(target).map(add_i).join(" ");
const flags = includes + " -c -o " + obj + " " + src;
if(src.endsWith(".c")) {
return this.prefix + this.cc + includes + " -c -o " + obj + " " + src;
return this.prefix + this.cc + " " + flags;
} else if(is_cxx(src)) {
return this.prefix + this.cxx + includes + " -c -o " + obj + " " + src;
return this.prefix + this.cxx + " " + flags;
}
return "";
}
};
POSIXCompiler.prototype.link = function(target, files) {
POSIXCompiler.prototype.link = function(target, files) {
if(target instanceof pmake.LibraryProject) {
return this.prefix + this.ar + " rcs " + this.output(target) + " " + files.join(" ");
} else if(target instanceof pmake.ExecutableProject) {