summaryrefslogtreecommitdiff
path: root/mbld
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-21 21:39:41 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-21 21:39:41 -0800
commit5e1d337617979642a8575fb90a167f75150c21d5 (patch)
treed5dd5c05683f93f6c45a42f988f89eac8664c96f /mbld
parentd910afb413459ce9a11c5cd2c8b4e32f1d649cc3 (diff)
downloadmc-5e1d337617979642a8575fb90a167f75150c21d5.tar.gz
Check for subcommand success.
Diffstat (limited to 'mbld')
-rw-r--r--mbld/build.myr6
-rw-r--r--mbld/main.myr33
-rw-r--r--mbld/util.myr6
3 files changed, 26 insertions, 19 deletions
diff --git a/mbld/build.myr b/mbld/build.myr
index 0b82a4a..f3ca521 100644
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -11,8 +11,8 @@ pkg bld =
const buildall : (b : build# -> bool)
const genall : (b : build# -> bool)
const buildtarg : (b : build#, target : byte[:] -> bool)
- const buildbin : (b : build#, bt : myrtarg#, addsrc : bool -> void)
- const buildlib : (b : build#, lt : myrtarg# -> void)
+ const buildbin : (b : build#, bt : myrtarg#, addsrc : bool -> bool)
+ const buildlib : (b : build#, lt : myrtarg# -> bool)
;;
const buildall = {b
@@ -140,6 +140,7 @@ const buildbin = {b, targ, addsrc
std.slfree(incs)
std.slfree(src)
;;
+ -> true
}
const buildlib = {b, targ
@@ -166,6 +167,7 @@ const buildlib = {b, targ
std.slfree(src)
;;
std.slfree(archive)
+ -> true
}
const genfiles = {b, gt
diff --git a/mbld/main.myr b/mbld/main.myr
index d7a1c24..f24bc0e 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -23,7 +23,7 @@ const main = {args : byte[:][:]
var tmp
var cmd
var tags
- var st
+ var ok, r
cmd = std.optparse(args, &[
.argdesc = "[inputs...]",
@@ -90,8 +90,10 @@ const main = {args : byte[:][:]
buildimm(b, targname, cmd.args, bintarg, cleanfirst)
elif runsrc.len != 0
tmp = std.mktemppath("runmyr")
- buildimm(b, tmp, [runsrc][:], true, cleanfirst)
- runcmd(tmp, cmd.args)
+ ok = buildimm(b, tmp, [runsrc][:], true, cleanfirst)
+ if ok
+ ok = runcmd(tmp, cmd.args)
+ ;;
std.remove(tmp)
elif dumponly
findproj(b, "bld.proj")
@@ -112,23 +114,24 @@ const main = {args : byte[:][:]
else
for c in cmd.args
match c
- | "all": st = bld.buildall(b)
- | "gen": st = bld.genall(b)
- | "clean": st = bld.cleanall(b)
- | "install": st = bld.install(b)
- | "uninstall": st = bld.uninstall(b)
- | "test": st = bld.test(b)
- | target: st = bld.buildtarg(b, target)
+ | "all": r = bld.buildall(b)
+ | "gen": r = bld.genall(b)
+ | "clean": r = bld.cleanall(b)
+ | "install": r = bld.install(b)
+ | "uninstall": r = bld.uninstall(b)
+ | "test": r = bld.test(b)
+ | target: r = bld.buildtarg(b, target)
;;
+ ok = ok && r
;;
;;
;;
- if (!st)
+ if !ok
std.exit(1)
;;
}
-const buildimm = {b, targ, inputs, bintarg, cleanfirst
+const buildimm = {b, targ, inputs, bintarg, cleanfirst -> bool
var mt : bld.myrtarg
mt = [
@@ -142,14 +145,14 @@ const buildimm = {b, targ, inputs, bintarg, cleanfirst
bld.cleanmyr(b, &mt)
;;
if bintarg
- bld.buildbin(b, &mt, true)
+ -> bld.buildbin(b, &mt, true)
else
- bld.buildlib(b, &mt)
+ -> bld.buildlib(b, &mt)
;;
}
const runcmd = {bin, args
- bld.run(std.sljoin([bin][:], args))
+ -> bld.run(std.sljoin([bin][:], args))
}
const mkbuild = {tags
diff --git a/mbld/util.myr b/mbld/util.myr
index edcbf8c..8ef6dfc 100644
--- a/mbld/util.myr
+++ b/mbld/util.myr
@@ -4,7 +4,7 @@ use "opts.use"
use "types.use"
pkg bld =
- const run : (cmd : byte[:][:] -> void)
+ const run : (cmd : byte[:][:] -> bool)
const printcmd
const srcsplit : (src : byte[:] -> (byte[:], byte[:], byte[:]))
const swapsuffix : (f : byte[:], suff : byte[:], newsuff : byte[:] -> byte[:])
@@ -21,13 +21,15 @@ const run = {cmd
pid = std.fork()
if pid == -1
std.fatal("could not fork command\n")
+ -> false
elif pid == 0
if std.execvp(cmd[0], cmd) < 0
std.fatal("failed to exec {}\n", cmd[0])
;;
+ -> false
else
match std.wait(pid)
- | `std.Wsuccess: /* nothing */
+ | `std.Wsuccess: -> true
| `std.Wfailure: std.fatal("FAIL: \"{}\"\n", std.strjoin(cmd, " "))
| `std.Wsignalled: std.fatal("CRASH: \"{}\"\n", std.strjoin(cmd, " "))
| `std.Waiterror: std.fatal("WAT: \"{}\"\n", std.strjoin(cmd, " "))