summaryrefslogtreecommitdiff
path: root/mbld
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-10-28 13:16:56 -0700
committerOri Bernstein <ori@eigenstate.org>2018-10-28 13:17:17 -0700
commite70e83ae4362b60e9eb2134fb5d388576ee90bdf (patch)
tree41b11c2fe0795af34f7b48e849734b0ba5d54766 /mbld
parentd92ff16a7e9ba2919746620fac40c798b06955ce (diff)
downloadmc-e70e83ae4362b60e9eb2134fb5d388576ee90bdf.tar.gz
Emit test logs into the obj/ directory.
Diffstat (limited to 'mbld')
-rw-r--r--mbld/main.myr24
-rw-r--r--mbld/test.myr11
-rw-r--r--mbld/types.myr1
3 files changed, 20 insertions, 16 deletions
diff --git a/mbld/main.myr b/mbld/main.myr
index 4e14761..5212865 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -15,13 +15,8 @@ use "syssel"
const main = {args : byte[:][:]
var b : bld.build#
- var targname
- var runsrc
- var path
- var tmp
- var cmd
- var tags
- var pid
+ var runsrc, objdir, path, tmp, cmd
+ var targname, tags, pid
var ok, r
cmd = std.optparse(args, &[
@@ -56,7 +51,7 @@ const main = {args : byte[:][:]
| ('T', tag): std.slpush(&bld.opt_alltags, tag)
| ('j', arg): bld.opt_maxproc = std.getv(std.intparse(arg), 1)
| ('R', arg): runsrc = arg
- | ('o', arg): bld.opt_objdir = arg
+ | ('o', arg): objdir = arg
| ('b', arg): targname = arg
| ('r', arg): bld.opt_runtime = arg
| ('v', _): bld.opt_verbosity++
@@ -72,11 +67,13 @@ const main = {args : byte[:][:]
b = mkbuild(tags)
if targname.len != 0
- ok = buildimm(b, targname, cmd.args, bld.opt_objdir)
+ bld.opt_objdir = objdir
+ ok = buildimm(b, targname, cmd.args)
elif runsrc.len != 0
+ bld.opt_objdir = objdir
bld.opt_verbosity = -1
tmp = std.mktemppath("runmyr")
- ok = buildimm(b, tmp, [runsrc][:], bld.opt_objdir)
+ ok = buildimm(b, tmp, [runsrc][:])
if ok
pid = runcmd(tmp, cmd.args)
match std.wait(pid)
@@ -86,6 +83,9 @@ const main = {args : byte[:][:]
;;
std.remove(tmp)
else
+ if objdir.len > 0
+ bld.opt_objdir = objdir
+ ;;
findproj(b)
bld.load(b)
bld.deps(b)
@@ -115,7 +115,7 @@ const main = {args : byte[:][:]
;;
}
-const buildimm = {b, targ, inputs, objdir
+const buildimm = {b, targ, inputs
var mt : bld.myrtarg
mt = [
@@ -125,7 +125,6 @@ const buildimm = {b, targ, inputs, objdir
.incpath=bld.opt_incpaths,
.libdeps=[][:]
]
- bld.opt_objdir = objdir
std.slpush(&b.all, "__out__")
std.htput(b.targs, "__out__", `bld.Bin &mt)
bld.deps(b)
@@ -198,6 +197,7 @@ const findproj = {b
while dir.len > 0 && !std.eq(dir, "/")
if std.chdir(dir) && std.fexists("bld.proj")
b.basedir = dir
+ b.rootdir = dir
break
;;
dir = std.dirname(dir)
diff --git a/mbld/test.myr b/mbld/test.myr
index a6d703e..f74c5cf 100644
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -22,7 +22,7 @@ const bench = {b, targs
}
const go = {b, targs, kind, isbench
- var failed, ok
+ var logdir, failed, ok
var tests
if !buildtarg(b, kind)
@@ -32,9 +32,12 @@ const go = {b, targs, kind, isbench
ok = true
failed = [][:]
for t : tests
- if !runtest(b, t, targs, isbench, &failed)
+ logdir = std.fmt("{}/{}/{}", b.basedir, opt_objdir, t.wdir)
+ std.mkpath(logdir)
+ if !runtest(b, t, targs, logdir, isbench, &failed)
ok = false
;;
+ std.slfree(logdir)
;;
std.chdir(b.basedir)
@@ -61,7 +64,7 @@ const printfailed = {failed
;;
}
-const runtest = {b, n, targs, isbench, failed
+const runtest = {b, n, targs, logdir, isbench, failed
var dir, res, log, logfd
var sub, found
@@ -93,7 +96,7 @@ const runtest = {b, n, targs, isbench, failed
log = ""
logfd = std.try(std.dup(std.Out))
else
- log = std.strcat(std.basename(n.lbl), ".log")
+ log = std.fmt("{}/{}.log", logdir, std.basename(n.lbl))
logfd = std.try(std.openmode(log, std.Owrite | std.Ocreat, 0o644))
;;
sub = showsub(b, n.lbl, outfd, logfd, failed)
diff --git a/mbld/types.myr b/mbld/types.myr
index 4e6901e..84db996 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -3,6 +3,7 @@ use std
pkg bld =
type build = struct
/* build state */
+ rootdir : byte[:]
basedir : byte[:]
tags : std.htab(byte[:], (int, int, int))#
libs : std.htab(byte[:], libdep#)#