summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMura Li <github@ctli.io>2019-10-22 10:35:08 +0800
committerOri Bernstein <ori@eigenstate.org>2019-10-21 23:35:15 -0700
commitf2d12752c483648d554700e6ac7dc100801dfa59 (patch)
tree7955e70325f30f24aa400f3efd4e7b9f93ffb91b
parent21422e62f15776a5abf3bf16e8416ffa9f8771fc (diff)
downloadmc-f2d12752c483648d554700e6ac7dc100801dfa59.tar.gz
Use optparse's .arg to pass run target
-rw-r--r--mbld/main.myr17
1 files changed, 6 insertions, 11 deletions
diff --git a/mbld/main.myr b/mbld/main.myr
index 4d40266..1ee7ecb 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -25,7 +25,7 @@ const main = {args : byte[:][:]
[.opt='T', .arg="tag", .desc="build with only the specified systag"],
[.opt='S', .desc="generate assembly when building"],
[.opt='I', .arg="inc", .desc="add 'inc' to your include path"],
- [.opt='R', .desc="source to compile and run"],
+ [.opt='R', .arg="src", .desc="source to compile and run"],
[.opt='B', .arg="base", .desc="install into 'base'"],
[.opt='b', .arg="bin", .desc="compile binary 'bin' from inputs"],
[.opt='r', .arg="rt", .desc="link against runtime 'rt'"],
@@ -39,6 +39,7 @@ const main = {args : byte[:][:]
targname = ""
ok = true
objdir = ""
+ srcs = cmd.args
bld.initopts()
for opt : cmd.opts
@@ -57,13 +58,14 @@ const main = {args : byte[:][:]
std.fatal("at most one -b and -R may be specified\n")
;;
targname = arg
- | ('R', arg):
+ | ('R', src):
if targname.len != 0
std.fatal("at most one -b and -R may be specified\n")
;;
bld.opt_verbosity = -1
runsrc = true
targname = std.mktemppath("runmyr")
+ srcs = [src][:]
| _:
std.die("unreachable\n")
;;
@@ -75,23 +77,16 @@ const main = {args : byte[:][:]
std.setenv(e, v)
;;
- std.put("cmd.args: {}\n", cmd.args)
b = mkbuild(tags)
if targname.len != 0
- if cmd.args.len == 0
+ if srcs.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, srcs)
if runsrc && ok
- pid = runcmd(targname, cmd.args[1:])
+ pid = runcmd(targname, cmd.args)
match std.wait(pid)
| `std.Wsuccess: ok = true
| _: ok = false