ref: 21422e62f15776a5abf3bf16e8416ffa9f8771fc
parent: 3450935eec9aa87ac23f8b6524a2c9a873105041
author: Mura Li <github@ctli.io>
date: Mon Oct 21 16:08:16 EDT 2019
Support cli arguments for mbld -R Example: mbld -R main.myr arg1 arg2 arg3
diff -u a/mbld/main.myr b/mbld/main.myr
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -14,7 +14,7 @@
use "syssel"
const main = {args : byte[:][:]
- var b, runsrc, objdir, path, cmd
+ var b, runsrc, objdir, path, cmd, srcs
var targname, tags, pid, ok
cmd = std.optparse(args, &[
@@ -75,15 +75,23 @@
std.setenv(e, v)
;;
+ std.put("cmd.args: {}\n", cmd.args)
b = mkbuild(tags)
if targname.len != 0
if cmd.args.len == 0
std.fatal("nothing to compile\n")
;;
+
+ if runsrc
+ srcs = cmd.args[0:1]
+ else
+ srcs = cmd.args
+ ;;
+
bld.opt_objdir = objdir
- ok = buildimm(b, targname, cmd.args)
+ ok = buildimm(b, targname, srcs)
if runsrc && ok
- pid = runcmd(targname, cmd.args)
+ pid = runcmd(targname, cmd.args[1:])
match std.wait(pid)
| `std.Wsuccess: ok = true
| _: ok = false
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -14,7 +14,7 @@
use "syssel"
const main = {args : byte[:][:]
- var b, runsrc, objdir, path, cmd
+ var b, runsrc, objdir, path, cmd, srcs
var targname, tags, pid, ok
cmd = std.optparse(args, &[
@@ -75,15 +75,23 @@
std.setenv(e, v)
;;
+ std.put("cmd.args: {}\n", cmd.args)
b = mkbuild(tags)
if targname.len != 0
if cmd.args.len == 0
std.fatal("nothing to compile\n")
;;
+
+ if runsrc
+ srcs = cmd.args[0:1]
+ else
+ srcs = cmd.args
+ ;;
+
bld.opt_objdir = objdir
- ok = buildimm(b, targname, cmd.args)
+ ok = buildimm(b, targname, srcs)
if runsrc && ok
- pid = runcmd(targname, cmd.args)
+ pid = runcmd(targname, cmd.args[1:])
match std.wait(pid)
| `std.Wsuccess: ok = true
| _: ok = false