ref: 14d657bd447f9384130ba321324052d94a420ca1
parent: 8a92415ad8220c1f651b0ed6338efb072e848d5c
author: Ori Bernstein <ori@markovcorp.com>
date: Wed Jan 11 06:24:31 EST 2017
Suppress prints when doing '-R'
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -122,7 +122,7 @@
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 @@
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 @@
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)
--- a/mbld/clean.myr
+++ b/mbld/clean.myr
@@ -23,7 +23,7 @@
| `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 @@
| `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 @@
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)
;;
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -124,13 +124,13 @@
-> 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 @@
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 @@
var sl
if opt_debug
- std.put("{} <= {}\n", dst, src)
+ mbldput("{} <= {}\n", dst, src)
;;
sl = std.htgetv(dg.deps, dst, [][:])
std.slpush(&sl, src)
--- a/mbld/install.myr
+++ b/mbld/install.myr
@@ -72,9 +72,9 @@
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 @@
| `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)
;;
;;
;;
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -90,6 +90,7 @@
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 @@
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 @@
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
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -13,6 +13,7 @@
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_ld = "ld"
var opt_ar = "ar"
var opt_genasm = false
+var opt_silent = false
const initopts = {
var si
--- a/mbld/subtest.myr
+++ b/mbld/subtest.myr
@@ -3,6 +3,7 @@
use regex
use "types"
+use "util"
pkg bld =
const showsub : (b : build#, cmd : byte[:], \
@@ -67,13 +68,13 @@
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 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 @@
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 @@
;;
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)
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -78,9 +78,9 @@
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 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 @@
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 @@
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])
--- a/mbld/util.myr
+++ b/mbld/util.myr
@@ -5,7 +5,8 @@
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 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