From fac750a2b3fdd15f1d8b1d81e9b1c4e17fb05bd5 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sat, 9 May 2026 16:57:33 +0900 Subject: [PATCH] watcom --- .gitignore | 1 + src/compiler/watcom.js | 15 ++++++++++++--- src/js/cmdline.js | 6 +++++- src/js_process.c | 13 +++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 86d6c52..95d02ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /pmake* *.o +*.lib *.a /Makefile /*.make diff --git a/src/compiler/watcom.js b/src/compiler/watcom.js index 73ad586..4966d9b 100644 --- a/src/compiler/watcom.js +++ b/src/compiler/watcom.js @@ -4,7 +4,15 @@ const Watcom = new pmake.Compiler(); Watcom.target = "Watcom"; Watcom.description = "Open Watcom"; -Watcom.compile = function(target, obj, src) { +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; } @@ -22,6 +30,7 @@ Watcom.compile = function(target, obj, src) { 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) { return "file \"" + x + "\""; @@ -35,7 +44,7 @@ Watcom.link = function(target, files) { } return ""; -} +}; - pmake.register(Watcom); +pmake.register(Watcom); })(); diff --git a/src/js/cmdline.js b/src/js/cmdline.js index 8a6fd1e..7f02b3a 100644 --- a/src/js/cmdline.js +++ b/src/js/cmdline.js @@ -97,7 +97,7 @@ function make(output) { mk.write(".PHONY: all clean\n"); if(output == "Makefile") { - mk.write(".PHONY: " + targets.map(target_map).join(" ") + "\n"); + mk.write(".PHONY: " + targets.map(target_map).join(" ") + " distclean\n"); mk.write("\n"); mk.write("MAKEARGS$(.TARGET) = --no-print-directory"); @@ -116,6 +116,10 @@ function make(output) { for(var i = 0; i < targets.length; i++) { mk.write(" @$(MAKE) $(MAKEARGS) -f " + targets[i].target + ".make clean\n"); } + mk.write("\n"); + + mk.write("distclean: clean\n"); + mk.write(" $(SILENT)rm -f *.make Makefile\n"); } else { function target_filter(x) { return x.target == output.replace(/\.make$/, ""); diff --git a/src/js_process.c b/src/js_process.c index 0427d32..70d1c7c 100644 --- a/src/js_process.c +++ b/src/js_process.c @@ -15,6 +15,16 @@ static duk_ret_t js_process_exit(duk_context* self) { } exit(ex); + + return 0; +} + +static duk_ret_t js_process_system(duk_context* self) { + int n = system(duk_get_string(self, 0)); + + duk_push_number(self, n); + + return 1; } void js_process_init(void) { @@ -26,6 +36,9 @@ void js_process_init(void) { duk_push_c_function(js_ctx, js_process_exit, DUK_VARARGS); duk_put_prop_string(js_ctx, obj, "exit"); + duk_push_c_function(js_ctx, js_process_system, 1); + duk_put_prop_string(js_ctx, obj, "system"); + duk_put_prop_string(js_ctx, 0, "process"); duk_pop(js_ctx);