ref: 40d6f7b5cc0cb9e5de1675a1441ad0dfc0a66bda
parent: cf1c6aa5e3025d81896eba7d3f0858b37bdc7309
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Sep 3 20:29:06 EDT 2017
`mbld bench` now works.
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -105,6 +105,13 @@
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 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 @@
*/
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 @@
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 @@
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
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -96,6 +96,7 @@
| "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
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -191,6 +191,7 @@
| `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 @@
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 @@
/* 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 @@
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 @@
.gen=outlist,
.durable=durable,
.istest=istest,
+ .isbench=isbench,
.deps=deplist,
.cmd=cmdlist,
.tags=tags,
@@ -391,7 +403,7 @@
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 @@
| ("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 @@
.libdeps=libdeps,
.islib=false,
.istest=istest,
+ .isbench=isbench,
/* attrs */
.tags=tags,
.install=install,
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -10,17 +10,26 @@
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
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -45,6 +45,7 @@
islib : bool
istest : bool
+ isbench : bool
install : bool
;;
@@ -57,6 +58,7 @@
tags : byte[:][:]
durable : bool
istest : bool
+ isbench : bool
;;
type mantarg = struct