ref: 5e1d337617979642a8575fb90a167f75150c21d5
parent: d910afb413459ce9a11c5cd2c8b4e32f1d649cc3
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Jan 21 16:39:41 EST 2016
Check for subcommand success.
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -11,8 +11,8 @@
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 @@
std.slfree(incs)
std.slfree(src)
;;
+ -> true
}
const buildlib = {b, targ
@@ -166,6 +167,7 @@
std.slfree(src)
;;
std.slfree(archive)
+ -> true
}
const genfiles = {b, gt
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -23,7 +23,7 @@
var tmp
var cmd
var tags
- var st
+ var ok, r
cmd = std.optparse(args, &[
.argdesc = "[inputs...]",
@@ -90,8 +90,10 @@
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 @@
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 @@
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
--- a/mbld/util.myr
+++ b/mbld/util.myr
@@ -4,7 +4,7 @@
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 @@
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, " "))