summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-07-24 23:06:02 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-25 22:23:05 -0700
commitd470a28bf8c0b730b9dbf8e73ba7856fed338084 (patch)
tree23d254f5fc3203e3a1c7187c6782071c1159e15b
parent5a4946bb577b755df6ddb543bccd0573de7cf2bd (diff)
downloadmc-d470a28bf8c0b730b9dbf8e73ba7856fed338084.tar.gz
Fix running tests.
-rw-r--r--mbld/deps.myr42
-rw-r--r--mbld/libs.myr6
-rw-r--r--mbld/main.myr5
-rw-r--r--mbld/opts.myr3
-rw-r--r--mbld/test.myr6
-rw-r--r--mbld/types.myr1
-rwxr-xr-xtest/runtest.rc2
-rwxr-xr-xtest/runtest.sh4
8 files changed, 35 insertions, 34 deletions
diff --git a/mbld/deps.myr b/mbld/deps.myr
index 471180b..dc37200 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -68,8 +68,8 @@ const myrdeps = {b, name, mt
if mt.islib
u = std.fmt("lib{}.use", mt.name)
o = std.fmt("lib{}.a", mt.name)
- tu = std.pathjoin([b.objdir, mt.dir, u][:])
- to = std.pathjoin([b.objdir, mt.dir, o][:])
+ tu = std.pathjoin([opt_objdir, mt.dir, u][:])
+ to = std.pathjoin([opt_objdir, mt.dir, o][:])
gu = node(g, tu)
go = node(g, to)
@@ -90,8 +90,8 @@ const myrdeps = {b, name, mt
std.slfree(u)
else
u = std.fmt("{}.use", mt.name)
- tu = std.pathjoin([b.objdir, mt.dir, u][:])
- to = std.pathjoin([b.objdir, mt.dir, mt.name][:])
+ tu = std.pathjoin([opt_objdir, mt.dir, u][:])
+ to = std.pathjoin([opt_objdir, mt.dir, mt.name][:])
go = node(g, to)
gu = node(g, tu)
@@ -104,7 +104,7 @@ const myrdeps = {b, name, mt
addnode(g, "test", n)
n.wdir = std.sldup(mt.dir)
- std.slpush(&n.cmd, std.fmt("./{}", mt.name))
+ std.slpush(&n.cmd, std.pathjoin([b.basedir, opt_objdir, mt.dir, mt.name][:]))
else
addnode(g, "all", go)
go.instdir = config.Binpath
@@ -121,11 +121,11 @@ const myrdeps = {b, name, mt
leaf(g, p)
if std.hassuffix(f, ".myr")
t = changesuffix(p, config.Objsuffix)
- o = std.pathcat(b.objdir, t)
+ o = std.pathcat(opt_objdir, t)
std.slfree(t)
t = changesuffix(p, ".use")
- u = std.pathcat(b.objdir, t)
+ u = std.pathcat(opt_objdir, t)
std.slfree(t)
depends(g, go, o)
@@ -149,7 +149,7 @@ const myrdeps = {b, name, mt
std.slfree(deps)
elif std.hassuffix(f, ".s")
t = changesuffix(p, config.Objsuffix)
- o = std.pathcat(b.objdir, t)
+ o = std.pathcat(opt_objdir, t)
std.slfree(t)
depends(g, go, o)
@@ -159,7 +159,7 @@ const myrdeps = {b, name, mt
ascmd(b, n, mt, o, p)
elif std.hassuffix(f, ".glue.c")
t = changesuffix(p, config.Objsuffix)
- o = std.pathcat(b.objdir, t)
+ o = std.pathcat(opt_objdir, t)
std.slfree(t)
(cflags, ll) = scrapecflags(b, mt, p)
@@ -292,11 +292,11 @@ const addtest = {b, mt, f
leaf(g, sp)
t = changesuffix(f, "")
- tp = std.pathjoin([mt.dir, "test", t][:])
+ tp = std.pathjoin([opt_objdir, mt.dir, "test", t][:])
std.slfree(t)
o = changesuffix(f, config.Objsuffix)
- op = std.pathjoin([mt.dir, "test", o][:])
+ op = std.pathjoin([opt_objdir, mt.dir, "test", o][:])
std.slfree(o)
n = node(g, sp)
@@ -325,8 +325,8 @@ const addtest = {b, mt, f
n = node(g, tp)
depends(g, n, tp)
- n.wdir = std.sldup(std.dirname(std.dirname(tp)))
- std.slpush(&n.cmd, std.fmt("./test/{}", std.basename(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)][:]))
addnode(g, "test", n)
}
@@ -439,21 +439,21 @@ const linkcmd = {b, n, mt, bin, libs, dynlibs, istest
}
const myrcmd = {b, n, mt, src, istest
- std.slpush(&n.cmd, opt_mc)
- if b.objdir.len > 0
- pushopt(&n.cmd, "-O", b.objdir)
+ std.slpush(&n.cmd, std.sldup(opt_mc))
+ if opt_objdir.len > 0
+ pushopt(&n.cmd, "-O", std.sldup(opt_objdir))
;;
for inc : mt.incpath[:mt.incpath.len - 1]
- pushopt(&n.cmd, "-I", inc)
+ pushopt(&n.cmd, "-I", std.pathcat(opt_objdir, inc))
;;
if istest
for (dir, _, _) : mt.tstdeps
- pushopt(&n.cmd, "-I", dir)
+ pushopt(&n.cmd, "-I", std.pathcat(opt_objdir, dir))
;;
- pushopt(&n.cmd, "-I", mt.dir)
+ pushopt(&n.cmd, "-I", std.pathcat(opt_objdir, mt.dir))
;;
for (dir, _, _) : mt.libdeps
- pushopt(&n.cmd, "-I", dir)
+ pushopt(&n.cmd, "-I", std.pathcat(opt_objdir, dir))
;;
if opt_genasm
std.slpush(&n.cmd, "-S")
@@ -500,7 +500,7 @@ const scrapedeps = {b : build#, mt, path
std.slpush(&l, `Xdep p)
else
/* internal library */
- p = std.pathjoin([b.objdir, mt.dir, uses[3]][:])
+ p = std.pathjoin([opt_objdir, mt.dir, uses[3]][:])
std.sljoin(&p, ".use")
std.slpush(&l, `Ldep p)
;;
diff --git a/mbld/libs.myr b/mbld/libs.myr
index b63499a..f99b0b2 100644
--- a/mbld/libs.myr
+++ b/mbld/libs.myr
@@ -28,11 +28,11 @@ const builtlib = {b, mt, dep, dyndep
u = std.fmt("lib{}.use", mt.name)
ldep = std.mk([
.name=mt.name,
- .dir=std.pathcat(b.objdir, mt.dir),
+ .dir=std.pathcat(opt_objdir, mt.dir),
.dep=dep,
.dyndep=dyndep,
- .genuse=std.pathjoin([b.objdir, mt.dir, u][:]),
- .genar=std.pathjoin([b.objdir, mt.dir, l][:]),
+ .genuse=std.pathjoin([opt_objdir, mt.dir, u][:]),
+ .genar=std.pathjoin([opt_objdir, mt.dir, l][:]),
])
std.slfree(l)
std.slfree(u)
diff --git a/mbld/main.myr b/mbld/main.myr
index eb55d38..6262fb1 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -37,6 +37,7 @@ const main = {args : byte[:][:]
[.opt='b', .arg="bin", .desc="compile binary named 'bin' from inputs"],
[.opt='l', .arg="lib", .desc="compile lib named 'lib' from inputs"],
[.opt='r', .arg="rt", .desc="link against runtime 'rt' instead of default"],
+ [.opt='o', .arg="dir", .desc="output directory"],
][:]
])
@@ -53,6 +54,7 @@ const main = {args : byte[:][:]
| ('B', arg): bld.opt_instbase = arg
| ('t', tag): std.slpush(&tags, tag)
| ('R', arg): runsrc = arg
+ | ('o', arg): bld.opt_objdir = arg
| ('b', arg):
targname = arg
bintarg = true
@@ -83,7 +85,7 @@ const main = {args : byte[:][:]
b = mkbuild(tags)
if targname.len != 0
- buildimm(b, targname, cmd.args)
+ ok = buildimm(b, targname, cmd.args)
elif runsrc.len != 0
bld.opt_silent = true
tmp = std.mktemppath("runmyr")
@@ -152,7 +154,6 @@ const mkbuild = {tags
var b
b = std.zalloc()
- b.objdir = "obj"
b.libs = std.mkht(std.strhash, std.streq)
b.proc = std.mkht(std.inthash, std.inteq)
b.targs = std.mkht(std.strhash, std.streq)
diff --git a/mbld/opts.myr b/mbld/opts.myr
index 6b478db..ca11d56 100644
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -12,7 +12,7 @@ pkg bld =
var opt_incpaths : byte[:][:]
var opt_instbase : byte[:]
var opt_destdir : byte[:]
- var opt_outdir : byte[:]
+ var opt_objdir : byte[:]
var opt_maxproc : std.size
var opt_debug : bool
var opt_silent : bool
@@ -44,6 +44,7 @@ var opt_as = "as"
var opt_muse = "muse"
var opt_ld = "ld"
var opt_ar = "ar"
+var opt_objdir = "obj"
var opt_genasm = false
var opt_silent = false
var opt_maxproc = 1
diff --git a/mbld/test.myr b/mbld/test.myr
index 50eb6bb..7f244fa 100644
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -57,7 +57,7 @@ const runtest = {b, n, failed
var sub
dir = std.pathcat(b.basedir, n.wdir)
- mbldput("run {}:\t", n.lbl)
+ mbldput("run {} in {}:\t", n.lbl, dir)
std.chdir(dir)
match std.spork(n.cmd)
| `std.Err m:
@@ -84,10 +84,10 @@ const runtest = {b, n, failed
;;
;;
if !res
- std.slpush(failed, n.lbl)
+ std.slpush(failed, std.fmt("{j= } || {}", n.cmd, dir))
;;
;;
- std.slfree(dir)
+ //std.slfree(dir)
-> res
}
diff --git a/mbld/types.myr b/mbld/types.myr
index 141c8ae..307712d 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -4,7 +4,6 @@ pkg bld =
type build = struct
/* build state */
basedir : byte[:]
- objdir : byte[:]
tags : std.htab(byte[:], (int, int, int))#
libs : std.htab(byte[:], libdep#)#
deps : depgraph#
diff --git a/test/runtest.rc b/test/runtest.rc
index 5e374fb..6a57d8a 100755
--- a/test/runtest.rc
+++ b/test/runtest.rc
@@ -5,7 +5,7 @@ MYR_MC=../6/6.out
MYR_MUSE=../muse/6.out
fn build {
rm -f $1 $1^.6 $1^.use
- ../mbld/mbld -b $1 -I../lib/std -I../lib/sys -r../rt/_myrrt.6 $1^.myr
+ ../obj/mbld/mbld -o '' -b $1 -I../lib/std -I../lib/sys -r../rt/_myrrt.6 $1^.myr
}
fn pass {
diff --git a/test/runtest.sh b/test/runtest.sh
index d8f959e..9df3435 100755
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -11,8 +11,8 @@ NPASSES=0
build() {
rm -f $1 $1.o $1.s $1.use
- echo mbld -b $1 -I../lib/std -I../lib/sys -r../rt/_myrrt.o $1.myr
- ../mbld/mbld -b $1 -I../lib/std -I../lib/sys -r../rt/_myrrt.o $1.myr
+ echo ../obj/mbld/mbld -o '' -b $1 -I../lib/std -I../lib/sys -r../rt/_myrrt.o $1.myr
+ ../obj/mbld/mbld -o '' -b $1 -I../lib/std -I../lib/sys -r../rt/_myrrt.o $1.myr
}
pass() {