summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-05-03 10:57:20 -0700
committerOri Bernstein <ori@eigenstate.org>2015-05-03 10:58:02 -0700
commit3c76465367aeb6152dcb6447d3aeb37e1cd3a6d3 (patch)
tree089aa4d592011ab7346c0fbd47a09a90ba6af27e
parent075d594d7191ccb985f8f92e7330662bdbe31c02 (diff)
downloadmc-3c76465367aeb6152dcb6447d3aeb37e1cd3a6d3.tar.gz
Run gen/cmd commands in the right subdir.
-rw-r--r--mbld/build.myr11
-rw-r--r--mbld/parse.myr28
-rwxr-xr-xmbldwrap.sh4
-rw-r--r--test/bld.sub1
4 files changed, 26 insertions, 18 deletions
diff --git a/mbld/build.myr b/mbld/build.myr
index f8a0414..b7dfb0f 100644
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -36,7 +36,7 @@ const buildall = {b
const genall = {b
for tn in b.all
match gettarg(b.targs, tn)
- | `Gen gt: run(gt.cmd)
+ | `Gen gt: runin(b, gt.cmd, gt.dir)
| _: /* skip */
;;
;;
@@ -49,14 +49,19 @@ const build = {b, targ
| `std.Some (`Bin bt): buildbin(b, bt, false)
| `std.Some (`Lib lt): buildlib(b, lt)
| `std.Some (`Test tt): buildbin(b, tt, false)
- | `std.Some (`Gen gt): run(gt.cmd)
- | `std.Some (`Cmd ct): run(ct.cmd)
+ | `std.Some (`Gen gt): runin(b, gt.cmd, gt.dir)
+ | `std.Some (`Cmd ct): runin(b, ct.cmd, ct.dir)
| `std.Some (`Man mt): /* nothing needed */
| `std.None: std.fatal(1, "invalid target %s\n", targ)
;;
-> true
}
+const runin = {b, cmd, dir
+ setdir(b, dir)
+ run(cmd)
+}
+
const buildbin = {b, targ, addsrc
var dg, src
diff --git a/mbld/parse.myr b/mbld/parse.myr
index 8f02221..5877f2e 100644
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -169,8 +169,8 @@ const target = {b, p
| `std.Some "bin": bintarget(b, p)
| `std.Some "test": testtarget(b, p)
| `std.Some "lib": libtarget(b, p)
- | `std.Some "gen": cmdtarget(b, p, false)
- | `std.Some "cmd": cmdtarget(b, p, true)
+ | `std.Some "gen": cmdtarget(b, p, "gen", false)
+ | `std.Some "cmd": cmdtarget(b, p, "cmd", true)
| `std.Some "man": mantarget(b, p)
| `std.Some "sub": subtarget(b, p)
| `std.Some targtype: failparse(p, "unknown targtype type %s\n", targtype)
@@ -223,23 +223,23 @@ const subtarget = {b, p
}
/* gentarget: wordlist {attrs} = wordlist ;; */
-const cmdtarget = {b, p, isgen
+const cmdtarget = {b, p, cmd, iscmd
var outlist, deplist, cmdlist
var durable
var attrs
var gt
match wordlist(p)
- | `std.None: failparse(p, "gen target missing output files\n")
+ | `std.None: failparse(p, "%s target missing output files\n", cmd)
| `std.Some out:
- if isgen && out.len != 1
- failparse(p, "gen target takes one name\n")
+ if iscmd && out.len != 1
+ failparse(p, "%s target takes one name\n", cmd)
;;
outlist = out
;;
skipspace(p)
- if !isgen && matchc(p, '{')
+ if !iscmd && matchc(p, '{')
match attrlist(p)
| `std.Some al: attrs = al
| `std.None: failparse(p, "invalid attr list for %s\n", outlist[0])
@@ -254,9 +254,9 @@ const cmdtarget = {b, p, isgen
;;
match wordlist(p)
- | `std.None: failparse(p, "target missing command\n")
- | `std.Some cmd:
- cmdlist = cmd
+ | `std.None: failparse(p, "%s target missing command\n", cmd)
+ | `std.Some cl:
+ cmdlist = cl
;;
if !matchc(p, ';') || !matchc(p, ';')
@@ -270,7 +270,7 @@ const cmdtarget = {b, p, isgen
| ("durable", ""): durable = true
| ("durable", val): failparse(p, "durable attr does not take argument\n")
| ("dep", depname): deplist = std.slpush(deplist, depname)
- | (attrname, val): failparse(p, "attribute %s not valid on gen targets\n")
+ | (attrname, val): failparse(p, "attribute %s not valid on %s targets\n", attrname, cmd)
;;
;;
@@ -281,8 +281,10 @@ const cmdtarget = {b, p, isgen
.deps=deplist,
.cmd=cmdlist
])
- if !isgen
- for o in outlist
+ for o in outlist
+ if iscmd
+ addtarg(p, b, o, `Cmd gt)
+ else
std.htput(b.gensrc, o, gt)
addtarg(p, b, o, `Gen gt)
;;
diff --git a/mbldwrap.sh b/mbldwrap.sh
index 478228a..8a75691 100755
--- a/mbldwrap.sh
+++ b/mbldwrap.sh
@@ -5,8 +5,8 @@ export MYR_MC=../6/6m
export MYR_RT=../rt/_myrrt.o
# this should be a bourne compatible shell script.
-if test -f mbld/mbld; then
- mbld $@
+if test -f ./mbld/mbld; then
+ ./mbld/mbld $@
else
./bootstrap.sh
fi
diff --git a/test/bld.sub b/test/bld.sub
new file mode 100644
index 0000000..3a4993c
--- /dev/null
+++ b/test/bld.sub
@@ -0,0 +1 @@
+cmd runtest = ./runtest.sh ;;