summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-09-04 00:29:06 -0700
committerOri Bernstein <ori@eigenstate.org>2017-09-04 00:29:06 -0700
commit40d6f7b5cc0cb9e5de1675a1441ad0dfc0a66bda (patch)
tree7bd30d6141afb2516bd695ce824b9b4fb1b51311
parentcf1c6aa5e3025d81896eba7d3f0858b37bdc7309 (diff)
downloadmc-40d6f7b5cc0cb9e5de1675a1441ad0dfc0a66bda.tar.gz
`mbld bench` now works.
-rw-r--r--mbld/deps.myr26
-rw-r--r--mbld/main.myr1
-rw-r--r--mbld/parse.myr18
-rw-r--r--mbld/test.myr13
-rw-r--r--mbld/types.myr2
5 files changed, 51 insertions, 9 deletions
diff --git a/mbld/deps.myr b/mbld/deps.myr
index e4f0bd2..1ed9981 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -105,6 +105,13 @@ const myrdeps = {b, name, mt
n.wdir = std.sldup(mt.dir)
std.slpush(&n.cmd, std.pathjoin([b.basedir, opt_objdir, mt.dir, mt.name][:]))
+ elif mt.isbench
+ n = node(g, mt.name)
+ depends(g, n, to)
+ addnode(g, "bench", n)
+
+ n.wdir = std.sldup(mt.dir)
+ std.slpush(&n.cmd, std.pathjoin([b.basedir, opt_objdir, mt.dir, mt.name][:]))
else
addnode(g, "all", go)
go.instdir = config.Binpath
@@ -264,10 +271,19 @@ const datdeps = {b, name, dt
const addtests = {b, name, mt
for f : mt.inputs
addtest(b, mt, f)
+ addbench(b, mt, f)
;;
}
const addtest = {b, mt, f
+ addalt(b, mt, "test", f)
+}
+
+const addbench = {b, mt, f
+ addalt(b, mt, "bench", f)
+}
+
+const addalt = {b, mt, kind, f
var libs, deps
var sp, tp, op
var s, t, o
@@ -280,7 +296,7 @@ const addtest = {b, mt, f
*/
g = b.deps
s = changesuffix(f, ".myr")
- sp = std.pathjoin([mt.dir, "test", s][:])
+ sp = std.pathjoin([mt.dir, kind, s][:])
std.slfree(s)
if !std.fexists(sp)
std.slfree(sp)
@@ -291,11 +307,11 @@ const addtest = {b, mt, f
leaf(g, sp)
t = changesuffix(f, "")
- tp = std.pathjoin([opt_objdir, mt.dir, "test", t][:])
+ tp = std.pathjoin([opt_objdir, mt.dir, kind, t][:])
std.slfree(t)
o = changesuffix(f, config.Objsuffix)
- op = std.pathjoin([opt_objdir, mt.dir, "test", o][:])
+ op = std.pathjoin([opt_objdir, mt.dir, kind, o][:])
std.slfree(o)
n = node(g, sp)
@@ -325,9 +341,9 @@ const addtest = {b, mt, f
n = node(g, tp)
depends(g, n, tp)
n.wdir = std.sldup(std.dirname(std.dirname(sp)))
- std.slpush(&n.cmd, std.pathjoin([b.basedir, opt_objdir, mt.dir, "test", std.basename(tp)][:]))
+ std.slpush(&n.cmd, std.pathjoin([b.basedir, opt_objdir, mt.dir, kind, std.basename(tp)][:]))
- addnode(g, "test", n)
+ addnode(g, kind, n)
}
const resolve = {b
diff --git a/mbld/main.myr b/mbld/main.myr
index 84bf4fd..606ae3b 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -96,6 +96,7 @@ const main = {args : byte[:][:]
| "install": r = bld.install(b)
| "uninstall": r = bld.uninstall(b)
| "test": r = bld.test(b, cmd.args[1:])
+ | "bench": r = bld.bench(b, cmd.args[1:])
| "list": r = show(b, cmd.args[1:])
| _:
ok = true
diff --git a/mbld/parse.myr b/mbld/parse.myr
index de8178a..0378bd9 100644
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -191,6 +191,7 @@ const target = {b, p
| `std.Some "bin": bintarget(b, p)
| `std.Some "lib": libtarget(b, p)
| `std.Some "test": testtarget(b, p)
+ | `std.Some "bench": benchtarget(b, p)
| `std.Some "gen": cmdtarget(b, p, "gen", false)
| `std.Some "cmd": cmdtarget(b, p, "cmd", true)
| `std.Some "data": datatarget(b, p, "data")
@@ -291,6 +292,15 @@ const testtarget = {b, p
addtarg(p, b, t.name, t.tags, `Bin t)
}
+/* benchtarget: myrtarget */
+const benchtarget = {b, p
+ var t
+ t = myrtarget(b, p, "bench")
+ t.isbench = true
+ t.install = false
+ addtarg(p, b, t.name, t.tags, `Bin t)
+}
+
/* mantarget: anontarget */
const mantarget = {b, p
var targ
@@ -315,7 +325,7 @@ const subtarget = {b, p
/* gentarget: wordlist {attrs} = wordlist ;; */
const cmdtarget = {b, p, cmd, iscmd
var outlist, deplist, cmdlist, tags
- var durable, istest
+ var durable, istest, isbench
var attrs
var gt
@@ -356,6 +366,7 @@ const cmdtarget = {b, p, cmd, iscmd
match elt
| ("durable", ""): durable = true
| ("test", ""): istest = true
+ | ("bench", ""): isbench = true
| ("notest", ""): istest = false
| ("dep", depname): std.slpush(&deplist, depname)
| ("tag", tag): std.slpush(&tags, tag)
@@ -371,6 +382,7 @@ const cmdtarget = {b, p, cmd, iscmd
.gen=outlist,
.durable=durable,
.istest=istest,
+ .isbench=isbench,
.deps=deplist,
.cmd=cmdlist,
.tags=tags,
@@ -391,7 +403,7 @@ myrtarget: name '=' inputlist ';;'
const myrtarget = {b, p, targ
var ldscript, runtime, install, incpath, tags
var libdeps, name, inputs, attrs
- var istest
+ var istest, isbench
var fsel
match word(p)
@@ -441,6 +453,7 @@ const myrtarget = {b, p, targ
| ("inst", ""): install = true
| ("noinst", ""): install = false
| ("test", ""): istest = true
+ | ("bench", ""): isbench = true
| ("notest", ""): istest = false
| (invalid, ""): std.fatal("{}: invalid attr '{}'\n", targ, invalid)
| (invalid, attr): std.fatal("{}: invalid attr '{} = {}'\n", targ, invalid, attr)
@@ -456,6 +469,7 @@ const myrtarget = {b, p, targ
.libdeps=libdeps,
.islib=false,
.istest=istest,
+ .isbench=isbench,
/* attrs */
.tags=tags,
.install=install,
diff --git a/mbld/test.myr b/mbld/test.myr
index 62cd89c..33894f1 100644
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -10,17 +10,26 @@ use "config"
pkg bld =
const test : (b : build#, targs : byte[:][:] -> bool)
+ const bench : (b : build#, targs : byte[:][:] -> bool)
;;
const test = {b, targs
+ -> go(b, targs, "test")
+}
+
+const bench = {b, targs
+ -> go(b, targs, "bench")
+}
+
+const go = {b, targs, kind
var failed, ok
var tests
- if !buildtarg(b, "test")
+ if !buildtarg(b, kind)
std.exit(1)
;;
if targs.len == 0
- tests = std.htgetv(b.deps.targs, "test", [][:])
+ tests = std.htgetv(b.deps.targs, kind, [][:])
else
tests = [][:]
for t : targs
diff --git a/mbld/types.myr b/mbld/types.myr
index 28e13f0..7731cb4 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -45,6 +45,7 @@ pkg bld =
islib : bool
istest : bool
+ isbench : bool
install : bool
;;
@@ -57,6 +58,7 @@ pkg bld =
tags : byte[:][:]
durable : bool
istest : bool
+ isbench : bool
;;
type mantarg = struct