summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2017-01-11 11:24:31 -0800
committerOri Bernstein <ori@markovcorp.com>2017-01-11 11:24:31 -0800
commit14d657bd447f9384130ba321324052d94a420ca1 (patch)
tree359724b743ec2956630542eb040436a838023b3f
parent8a92415ad8220c1f651b0ed6338efb072e848d5c (diff)
downloadmc-14d657bd447f9384130ba321324052d94a420ca1.tar.gz
Suppress prints when doing '-R'
-rw-r--r--mbld/build.myr8
-rw-r--r--mbld/clean.myr8
-rw-r--r--mbld/deps.myr10
-rw-r--r--mbld/install.myr8
-rw-r--r--mbld/main.myr5
-rw-r--r--mbld/opts.myr2
-rw-r--r--mbld/subtest.myr15
-rw-r--r--mbld/test.myr22
-rw-r--r--mbld/util.myr20
9 files changed, 56 insertions, 42 deletions
diff --git a/mbld/build.myr b/mbld/build.myr
index dafb994..66558f4 100644
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -122,7 +122,7 @@ const buildbin = {b, targ, addsrc
setdir(b, targ.dir)
addincludes(b, targ)
path = std.pathcat(b.curdir, targ.name)
- std.put("{}...\n", path)
+ mbldput("{}...\n", path)
std.slfree(path)
dg = myrdeps(b, targ, false, addsrc)
if !std.hthas(dg.deps, targ.name)
@@ -152,7 +152,7 @@ const buildlib = {b, targ
setdir(b, targ.dir)
addincludes(b, targ)
lib = targ.name
- std.put("{}/lib{}.a...\n", b.curdir, lib)
+ mbldput("{}/lib{}.a...\n", b.curdir, lib)
archive = std.fmt("lib{}.a", lib)
usefile = std.fmt("lib{}.use", lib)
dg = myrdeps(b, targ, false, false)
@@ -426,10 +426,10 @@ const putlib = {cmd, head, lib, incs
else
match findlib(lib, incs)
| `std.None:
- std.put("in path: ")
+ mbldput("in path: ")
sep = ""
for inc in incs
- std.put("\t{}{}\n", sep, inc)
+ mbldput("\t{}{}\n", sep, inc)
sep = ", "
;;
std.fatal("could not find library lib{}.a.\n", lib)
diff --git a/mbld/clean.myr b/mbld/clean.myr
index 68e4677..1e317fe 100644
--- a/mbld/clean.myr
+++ b/mbld/clean.myr
@@ -23,7 +23,7 @@ const cleanall = {b
| `Gen gt:
for f in gt.out
if !gt.durable && std.remove(f)
- std.put("\tclean {}\n", f)
+ mbldput("\tclean {}\n", f)
;;
;;
| `Data _: /* nothing to do */
@@ -48,7 +48,7 @@ const clean = {b, targ
| `Gen gt:
for f in gt.out
if !gt.durable && std.remove(f)
- std.put("\tclean {}\n", f)
+ mbldput("\tclean {}\n", f)
;;
;;
| `Data _: /* nothing to do */
@@ -81,11 +81,11 @@ const cleanup = {b, targ, leaves
keys = std.htkeys(dg.deps)
for k in keys
if !std.htgetv(mchammer_files, k, false) && std.remove(k)
- std.put("\tclean {}\n", k)
+ mbldput("\tclean {}\n", k)
;;
test = std.pathcat("test", k)
if std.remove(test)
- std.put("\tclean {}\n", test)
+ mbldput("\tclean {}\n", test)
;;
std.slfree(test)
;;
diff --git a/mbld/deps.myr b/mbld/deps.myr
index 839dfe8..0b66b5b 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -124,13 +124,13 @@ const dumpgraph = {dg
-> void
;;
keys = std.htkeys(dg.deps)
- std.put("digraph dg {{\n")
+ mbldput("digraph dg {{\n")
for k in keys
for v in std.htgetv(dg.deps, k, ["WTFUNKNOWN!"][:])
- std.put("\t\"{}\" -> \"{}\";\n", k, v)
+ mbldput("\t\"{}\" -> \"{}\";\n", k, v)
;;
;;
- std.put("}\n")
+ mbldput("}\n")
}
const srcdeps = {b, ds, g, path, obj, usefile
@@ -183,7 +183,7 @@ const addusedep = {b, ds, g, f, usefile, line
if std.hthas(g.done, usefile)
if opt_debug
- std.put("already loaded deps for {}\n", usefile)
+ mbldput("already loaded deps for {}\n", usefile)
;;
-> void
;;
@@ -408,7 +408,7 @@ const pushdep = {dg, src, dst
var sl
if opt_debug
- std.put("{} <= {}\n", dst, src)
+ mbldput("{} <= {}\n", dst, src)
;;
sl = std.htgetv(dg.deps, dst, [][:])
std.slpush(&sl, src)
diff --git a/mbld/install.myr b/mbld/install.myr
index 2591c59..d7c7ae5 100644
--- a/mbld/install.myr
+++ b/mbld/install.myr
@@ -72,9 +72,9 @@ const movefile = {b, rm, dir, file, prefix, perm
setdir(b, dir)
path = std.pathjoin([opt_destdir, opt_instbase, prefix, file][:])
if rm
- std.put("\trm {}\n", path)
+ mbldput("\trm {}\n", path)
if !std.remove(path)
- std.put("\t\tno such file {}\n", file)
+ mbldput("\t\tno such file {}\n", file)
;;
else
std.remove(path)
@@ -82,9 +82,9 @@ const movefile = {b, rm, dir, file, prefix, perm
| `std.Err m: std.fatal("could not open {} for reading\n", file)
| `std.Ok buf:
if std.blat(path, buf, perm)
- std.put("\t{} => {}\n", file, path)
+ mbldput("\t{} => {}\n", file, path)
else
- std.put("could not write {}\n", file)
+ mbldput("could not write {}\n", file)
;;
;;
;;
diff --git a/mbld/main.myr b/mbld/main.myr
index f009c25..d1841da 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -90,6 +90,7 @@ const main = {args : byte[:][:]
if targname.len != 0
buildimm(b, targname, cmd.args, bintarg, cleanfirst)
elif runsrc.len != 0
+ bld.opt_silent = true
tmp = std.mktemppath("runmyr")
ok = buildimm(b, tmp, [runsrc][:], true, cleanfirst)
if ok
@@ -100,7 +101,7 @@ const main = {args : byte[:][:]
findproj(b, "bld.proj")
bld.load(b)
for t in b.all
- std.put("{}\n", t)
+ bld.mbldput("{}\n", t)
;;
else
findproj(b, "bld.proj")
@@ -185,7 +186,7 @@ const findbase = {b, file
while !std.sleq(dir, "/")
bld = std.pathcat(dir, file)
if std.fexists(bld)
- std.put("project base {}:\n", dir)
+ bld.mbldput("project base {}:\n", dir)
b.basedir = dir
b.bldfile = bld
-> true
diff --git a/mbld/opts.myr b/mbld/opts.myr
index 651b1eb..0d5e721 100644
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -13,6 +13,7 @@ pkg bld =
var opt_destdir : byte[:]
var opt_outdir : byte[:]
var opt_debug : bool
+ var opt_silent : bool
/* undocumented/unsupported opts */
var opt_mc : byte[:]
@@ -41,6 +42,7 @@ var opt_muse = "muse"
var opt_ld = "ld"
var opt_ar = "ar"
var opt_genasm = false
+var opt_silent = false
const initopts = {
var si
diff --git a/mbld/subtest.myr b/mbld/subtest.myr
index e380a68..5f0668f 100644
--- a/mbld/subtest.myr
+++ b/mbld/subtest.myr
@@ -3,6 +3,7 @@ use bio
use regex
use "types"
+use "util"
pkg bld =
const showsub : (b : build#, cmd : byte[:], \
@@ -67,13 +68,13 @@ const showtests = {b, cmd, failed, f, log, ntests
var ok
if ntests == 0
- std.put("FAIL: missing tests\n")
+ mbldput("FAIL: missing tests\n")
-> false
;;
ok = true
curtest = ""
nresults = 0
- std.put("\n")
+ mbldput("\n")
for ln in bio.byline(f)
ln = std.strstrip(ln)
match testhead(ln)
@@ -118,7 +119,7 @@ const showtests = {b, cmd, failed, f, log, ntests
const checktests = {ntests, nresults
if ntests > 0 && ntests != nresults
- std.put("mismatched test count: expected {}, got {}\n", ntests, nresults)
+ mbldput("mismatched test count: expected {}, got {}\n", ntests, nresults)
-> false
;;
-> true
@@ -128,7 +129,7 @@ const starttest = {curtest, t
if curtest#.len != 0
std.fatal("malformed input: test {} nested in {}\n", t, curtest)
;;
- std.put("\trun {}:\t", std.strstrip(t))
+ mbldput("\trun {}:\t", std.strstrip(t))
curtest# = t
}
@@ -140,12 +141,12 @@ const endtest = {b, cmd, curtest, failed, nresults, pass, msg
;;
if pass
- std.put("PASS\n")
+ mbldput("PASS\n")
else
if msg.len > 0
- std.put("FAIL {}\n", msg)
+ mbldput("FAIL {}\n", msg)
else
- std.put("FAIL\n")
+ mbldput("FAIL\n")
;;
p = std.pathjoin([b.curdir, cmd, curtest#][:])
std.slpush(failed, p)
diff --git a/mbld/test.myr b/mbld/test.myr
index ed25f0f..a6a35f7 100644
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -78,9 +78,9 @@ const test = {b
std.slfree(f)
;;
if ok
- std.put("TESTS PASSED\n")
+ mbldput("TESTS PASSED\n")
else
- std.put("TESTS FAILED\n")
+ mbldput("TESTS FAILED\n")
;;
std.slfree(failed)
std.slfree(tests)
@@ -89,9 +89,9 @@ const test = {b
const printfailed = {failed
if failed.len > 0
- std.put("FAILURES: {}\n", failed.len)
+ mbldput("FAILURES: {}\n", failed.len)
for t in failed
- std.put("\t{}\n", t)
+ mbldput("\t{}\n", t)
;;
;;
}
@@ -151,13 +151,13 @@ const runtest = {b, cmd, failed
var res, log, logfd, p
var sub
- std.put("run")
+ mbldput("run")
for c in cmd
p = std.pathcat(b.curdir, c)
- std.put(" {}", p)
+ mbldput(" {}", p)
std.slfree(p)
;;
- std.put(":\t")
+ mbldput(":\t")
match std.spork(cmd)
| `std.Err m:
std.fatal("\nunable to run test: {}\n", m)
@@ -171,16 +171,16 @@ const runtest = {b, cmd, failed
res = false
match std.wait(pid)
- | `std.Wfailure: std.put("FAIL\n")
- | `std.Wsignalled: std.put("CRASH\n")
+ | `std.Wfailure: mbldput("FAIL\n")
+ | `std.Wsignalled: mbldput("CRASH\n")
| `std.Wsuccess:
res = true
/* if we have subtests, we've already printed the output */
match sub
| `std.Some r: res = r
- | `std.None: std.put("PASS\n")
+ | `std.None: mbldput("PASS\n")
;;
- | `std.Waiterror: std.put("failed waiting for pid {}\n", pid)
+ | `std.Waiterror: mbldput("failed waiting for pid {}\n", pid)
;;
if !res
p = std.pathcat(b.curdir, cmd[0])
diff --git a/mbld/util.myr b/mbld/util.myr
index c9efa06..7054ac5 100644
--- a/mbld/util.myr
+++ b/mbld/util.myr
@@ -5,7 +5,8 @@ use "types"
pkg bld =
const run : (cmd : byte[:][:] -> bool)
- const printcmd
+ const printcmd : (cmd : byte[:][:] -> void)
+ const mbldput : (fmt : byte[:], args : ... -> void)
const srcsplit : (src : byte[:] -> (byte[:], byte[:], byte[:]))
const swapsuffix : (f : byte[:], suff : byte[:], newsuff : byte[:] -> byte[:])
const srcswapsuffix : (f : byte[:], newsuff : byte[:] -> byte[:])
@@ -37,15 +38,24 @@ const run = {cmd
;;
}
+const mbldput = {fmt, args
+ var ap
+
+ if !opt_silent
+ ap = std.vastart(&args)
+ std.putv(fmt, &ap)
+ ;;
+}
+
const printcmd = {lst
if lst.len > 0
- std.put("\t")
- std.put("{}\t", lst[0])
+ mbldput("\t")
+ mbldput("{}\t", lst[0])
for l in lst[1:]
- std.put("{} ", l)
+ mbldput("{} ", l)
;;
;;
- std.put("\n")
+ mbldput("\n")
}
const srcsplit = {src