pmake/src/compiler/watcom.js
2026-05-15 00:01:30 +09:00

65 lines
1.5 KiB
JavaScript

(function() {
const Watcom = new pmake.Compiler();
Watcom.target = "Watcom";
Watcom.description = "Open Watcom";
Watcom.output = function(target) {
if(target instanceof pmake.LibraryProject) {
return target.output + ".lib";
}
return pmake.Compiler.prototype.output.call(this, target);
};
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 -fr= -q " + includes + " -fo=" + obj + " " + src;
if(src.endsWith(".rc")){
return "wrc -bt=nt -r -fo=" + obj + " " + src;
}else if(src.endsWith(".c")) {
return "wcc386 " + flags;
} else {
return "wpp386 " + flags;
}
return "";
};
Watcom.link = function(target, files) {
if(target instanceof pmake.LibraryProject) {
return "wlib -q -b -n -fo " + this.output(target) + " " + files.join(" ");
} else if(target instanceof pmake.ExecutableProject) {
function add_file(x) {
if(x.endsWith(".res")) return "option resource=" + x;
return "file \"" + x + "\"";
}
function add_lib(x) {
return x + ".lib";
}
function add_library(x) {
return "library \"" + x + "\"";
}
function add_libpath(x) {
return "libpath \"" + x + "\"";
}
return "wlink option quiet system nt name " + this.output(target) + " " + files.map(add_file).join(" ") + " " + pmake.libdirs(target).map(add_libpath).join(" ") + " " + pmake.libs(target, add_lib).map(add_library).join(" ");
}
return "";
};
Watcom.init = function() {
pmake.setSystem("Windows");
};
pmake.register(Watcom);
})();