summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bld.proj1
-rw-r--r--libstd/fmt.myr12
-rw-r--r--libstd/optparse.myr2
-rw-r--r--libstd/spork.myr6
-rw-r--r--libstd/try.myr2
-rw-r--r--mbld/build.myr18
-rw-r--r--mbld/deps.myr18
-rw-r--r--mbld/fsel.myr10
-rw-r--r--mbld/install.myr6
-rw-r--r--mbld/main.myr4
-rw-r--r--mbld/opts.myr4
-rw-r--r--mbld/parse.myr14
-rw-r--r--mbld/test.myr2
-rw-r--r--mbld/util.myr16
-rwxr-xr-xmbldwrap.sh10
-rw-r--r--test/matchargstr.myr10
16 files changed, 70 insertions, 65 deletions
diff --git a/bld.proj b/bld.proj
index 1f23b30..f188846 100644
--- a/bld.proj
+++ b/bld.proj
@@ -3,5 +3,6 @@ sub =
libstd
libbio
libregex
+ test
;;
diff --git a/libstd/fmt.myr b/libstd/fmt.myr
index 9092cd1..bb2cf91 100644
--- a/libstd/fmt.myr
+++ b/libstd/fmt.myr
@@ -37,8 +37,8 @@ pkg std =
const bfmt : (buf : byte[:], fmt : byte[:], args : ... -> byte[:])
const bfmtv : (buf : byte[:], fmt : byte[:], ap : valist -> byte[:])
- $noret const fatal : (status : int, fmt : byte[:], args : ... -> void)
- $noret const fatalv : (status : int, fmt : byte[:], ap : valist -> void)
+ $noret const fatal : (fmt : byte[:], args : ... -> void)
+ $noret const fatalv : (fmt : byte[:], ap : valist -> void)
;;
/* Writes a string of text up to 2 kb in size to stdout */
@@ -63,15 +63,15 @@ const fputv = {fd, fmt, ap
}
/* same as 'put', but exits the program after printing */
-const fatal = {status, fmt, args
+const fatal = {fmt, args
putv(fmt, vastart(&args))
- exit(status)
+ exit(1)
}
/* same as 'putv', but exits the program after printing */
-const fatalv = {status, fmt, ap
+const fatalv = {fmt, ap
putv(fmt, ap)
- exit(status)
+ exit(1)
}
/* formats a string, allocating the slice. FIXME: calculate the
diff --git a/libstd/optparse.myr b/libstd/optparse.myr
index a043263..4f454b5 100644
--- a/libstd/optparse.myr
+++ b/libstd/optparse.myr
@@ -97,7 +97,7 @@ const optnext = {ctx
optusage(ctx.optargs[0], ctx.optdef)
exit(0)
else
- fatal(1, "unexpected argument '%c'\n", c)
+ fatal("unexpected argument '%c'\n", c)
;;
| `Some (true, needed):
/* -arg => '-a' 'rg' */
diff --git a/libstd/spork.myr b/libstd/spork.myr
index 1778037..f728768 100644
--- a/libstd/spork.myr
+++ b/libstd/spork.myr
@@ -45,15 +45,15 @@ const sporkfd = {cmd, infd, outfd
elif pid == 0
/* stdin/stdout for our communication. */
if dup2(infd castto(fd), 0) != 0
- fatal(1, "unable to set stdin\n")
+ fatal("unable to set stdin\n")
;;
if dup2(outfd castto(fd), 1) != 1
- fatal(1, "unable to set stdout\n")
+ fatal("unable to set stdout\n")
;;
close(infd)
close(outfd)
execvp(cmd[0], cmd) < 0
- fatal(1, "failed to exec %s\n")
+ fatal("failed to exec %s\n")
/* parent */
else
-> `Ok pid
diff --git a/libstd/try.myr b/libstd/try.myr
index 1539a98..2997143 100644
--- a/libstd/try.myr
+++ b/libstd/try.myr
@@ -8,6 +8,6 @@ pkg std =
generic try = {v
match v
| `Some x: -> x
- | `None: fatal(1, "expected `Some @a, got `None\n")
+ | `None: fatal("expected `Some @a, got `None\n")
;;
}
diff --git a/mbld/build.myr b/mbld/build.myr
index b7dfb0f..c154129 100644
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -52,7 +52,7 @@ const build = {b, targ
| `std.Some (`Gen gt): runin(b, gt.cmd, gt.dir)
| `std.Some (`Cmd ct): runin(b, ct.cmd, ct.dir)
| `std.Some (`Man mt): /* nothing needed */
- | `std.None: std.fatal(1, "invalid target %s\n", targ)
+ | `std.None: std.fatal("invalid target %s\n", targ)
;;
-> true
}
@@ -70,7 +70,7 @@ const buildbin = {b, targ, addsrc
std.put("%s...\n", targ.name)
dg = myrdeps(b, targ, false, addsrc)
if !std.hthas(dg.deps, targ.name)
- std.fatal(1, "no input files for %s\n", targ.name)
+ std.fatal("no input files for %s\n", targ.name)
;;
if builddep(b, dg, targ.name, targ.incpath) || !freshlibs(targ, dg.libs)
src = std.htkeys(dg.sources)
@@ -92,7 +92,7 @@ const buildlib = {b, targ
archive = std.fmt("lib%s.a", lib)
dg = myrdeps(b, targ, false, false)
if !std.hthas(dg.deps, lib)
- std.fatal(1, "no target declared for %s\n", lib)
+ std.fatal("no target declared for %s\n", lib)
;;
u = builddep(b, dg, targ.name, targ.incpath)
l = builddep(b, dg, archive, targ.incpath)
@@ -155,7 +155,7 @@ const builddep = {b, dg, out, incs
;;
| `std.None:
if !std.fexists(d)
- std.fatal(1, "no input file %s\n", d)
+ std.fatal("no input file %s\n", d)
;;
;;
if !isfresh(d, out)
@@ -204,7 +204,7 @@ const compile = {src, incs
run(cmd)
std.slfree(o)
else
- std.fatal(1, "Unknown file type for %s\n", src)
+ std.fatal("Unknown file type for %s\n", src)
;;
}
@@ -277,7 +277,7 @@ const mergeuse = {dg, lib, files, incs
if std.hassuffix(f, ".myr")
cmd = std.slpush(cmd, srcswapsuffix(f, ".use"))
elif !std.hassuffix(f, ".s")
- std.fatal(1, "unknown file type for %s\n", f)
+ std.fatal("unknown file type for %s\n", f)
;;
;;
run(cmd)
@@ -311,7 +311,7 @@ const addlibs = {cmd, libgraph, incs
const visit = {cmd, head, g, lib, looped, marked, incs
if std.hthas(looped, lib)
- std.fatal(1, "cycle in library graph involving \"%s\"\n", lib)
+ std.fatal("cycle in library graph involving \"%s\"\n", lib)
elif std.hthas(marked, lib)
-> cmd
;;
@@ -331,7 +331,7 @@ const putlib = {cmd, head, lib, incs
else
match findlib(lib, incs)
| `std.None:
- std.fatal(1, "could not find library lib%s.a\n", lib)
+ std.fatal("could not find library lib%s.a\n", lib)
| `std.Some p:
-> std.slput(cmd, head, p)
;;
@@ -401,7 +401,7 @@ const isfresh = {src, dst
*/
match std.fmtime(src)
| `std.Some mt: srcmt = mt
- | `std.None: std.fatal(1, "could not stat %s\n", src)
+ | `std.None: std.fatal("could not stat %s\n", src)
;;
match std.fmtime(dst)
| `std.Some mt: dstmt = mt
diff --git a/mbld/deps.myr b/mbld/deps.myr
index d714d40..4321f2b 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -144,7 +144,7 @@ const srcdeps = {b, ds, g, path, obj, usefile
;;
| `Local (l, lnum):
if !std.hassuffix(l, ".use")
- std.fatal(1, "%s:%s: local dependency \"%s\" should end with .use\n", path, lnum, l)
+ std.fatal("%s:%s: local dependency \"%s\" should end with .use\n", path, lnum, l)
;;
if obj.len != 0
pushdep(g, l, obj)
@@ -177,7 +177,7 @@ const addusedep = {b, ds, g, f, usefile, line
if ds.addsrc
std.htput(g.sources, src, true)
elif !std.hthas(g.input, usefile)
- std.fatal(1, "%s:%i: source file %s not listed in bldfile\n", f, line, src)
+ std.fatal("%s:%i: source file %s not listed in bldfile\n", f, line, src)
;;
;;
pushdep(g, src, usefile)
@@ -194,12 +194,12 @@ const getdeps = {b, ds, path
if !std.fexists(path)
match std.htget(b.gensrc, path)
| `std.Some gt: run(gt.cmd)
- | `std.None: std.fatal(1, "no input file %s\n", path)
+ | `std.None: std.fatal("no input file %s\n", path)
;;
;;
match bio.open(path, bio.Rd)
| `std.Some fd: f = fd
- | `std.None: std.fatal(1, "could not open %s\n", path)
+ | `std.None: std.fatal("could not open %s\n", path)
;;
lnum = 0
@@ -230,14 +230,14 @@ const scrapelibs = {dg, lib, incs
f = openlib(lib, incs)
match bio.getc(f)
| `std.Some 'U': /* nothing */
- | `std.Some _: std.fatal(1, "library %s: corrupt or invalid usefile\n", lib)
- | `std.None: std.fatal(1, "library %s: could not read usefile\n", lib)
+ | `std.Some _: std.fatal("library %s: corrupt or invalid usefile\n", lib)
+ | `std.None: std.fatal("library %s: could not read usefile\n", lib)
;;
match bio.getbe32(f)
| `std.Some 1: /* nothing: version matches. */
| `std.Some 0: std.fput(1, "library %s: warning: old usefile version\n", lib)
- | `std.Some _: std.fatal(1, "library %s: usefile version unknown\n", lib)
- | `std.None: std.fatal(1, "library %s: corrutpt or invalid usefile\n", lib)
+ | `std.Some _: std.fatal("library %s: usefile version unknown\n", lib)
+ | `std.None: std.fatal("library %s: corrutpt or invalid usefile\n", lib)
;;
std.slfree(rdstr(f))
done = false
@@ -276,7 +276,7 @@ const openlib = {lib, incs
| `std.None:
/* nothing */
;;
- std.fatal(1, "could not find library %s.\n", lib)
+ std.fatal("could not find library %s.\n", lib)
}
const depname = {deps, ln, lnum
diff --git a/mbld/fsel.myr b/mbld/fsel.myr
index bdd0103..e40d16c 100644
--- a/mbld/fsel.myr
+++ b/mbld/fsel.myr
@@ -35,11 +35,11 @@ const fseladd = {fsel, f
basename = f[:i]
match std.strrfind(f[i+1:], ".")
| `std.Some j: attrs = f[i+1:][:j]
- | `std.None: std.fatal(1, "unrecognized type for file %s\n", f)
+ | `std.None: std.fatal("unrecognized type for file %s\n", f)
;;
| `std.None:
match std.strrfind(f, ".")
- | `std.None: std.fatal(1, "unrecognized type for file %s\n", f)
+ | `std.None: std.fatal("unrecognized type for file %s\n", f)
| `std.Some i:
basename = f[:i]
attrs = ""
@@ -72,7 +72,7 @@ const fselfin = {fsel
for k in keys
nmatch = std.htgetv(fsel._match, k, -1)
if nmatch == -1
- std.fatal(1, "no applicable file for '%s'\n", k)
+ std.fatal("no applicable file for '%s'\n", k)
;;
ret = std.slpush(ret, std.htgetv(fsel._best, k, ""))
;;
@@ -89,7 +89,7 @@ const addsysattrs = {sa
| "osx": attrs = ["osx", "posixy"][:]
| "linux": attrs = ["linux", "posixy"][:]
| "plan9": attrs = ["plan9"][:]
- | unknown: std.fatal(1, "unknown system \"%s\"\n", unknown)
+ | unknown: std.fatal("unknown system \"%s\"\n", unknown)
;;
for a in attrs
std.htput(sa, a, true)
@@ -97,7 +97,7 @@ const addsysattrs = {sa
match opt_arch
| "x64": attrs = ["x64"][:]
- | unknown: std.fatal(1, "unknown arch %s\n", unknown)
+ | unknown: std.fatal("unknown arch %s\n", unknown)
;;
for a in attrs
std.htput(sa, a, true)
diff --git a/mbld/install.myr b/mbld/install.myr
index 0cf6d1f..8d6fbeb 100644
--- a/mbld/install.myr
+++ b/mbld/install.myr
@@ -68,7 +68,7 @@ const movefile = {b, rm, dir, file, prefix, perm
std.put("\t%s => %s\n", file, path)
std.remove(path)
match std.slurp(file)
- | `std.Fail m: std.fatal(1, "Could not open %s for reading\n", file)
+ | `std.Fail m: std.fatal("Could not open %s for reading\n", file)
| `std.Ok buf:
if !std.blat(path, buf, perm)
std.put("Could not write %s\n", file)
@@ -84,11 +84,11 @@ const moveman = {b, rm, dir, man
match std.strrfind(man, ".")
| `std.None:
- std.fatal(1, "manpage %s has no section\n", man)
+ std.fatal("manpage %s has no section\n", man)
| `std.Some s:
sect = s + 1
if s + 1 == man.len
- std.fatal(1, "manpage %s missing suffix\n", man)
+ std.fatal("manpage %s missing suffix\n", man)
;;
;;
diff --git a/mbld/main.myr b/mbld/main.myr
index 7fbf996..af1517a 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -75,7 +75,7 @@ const main = {args : byte[:][:]
match regex.compile("^\\s*use\\s+((\\<\\S+\\>)|(\"(\\S+)\")).*")
| `std.Ok re: bld.usepat = re
- | `std.Fail f: std.fatal(1, "Failed to compile use pattern regex\n")
+ | `std.Fail f: std.fatal("Failed to compile use pattern regex\n")
;;
b = mkbuild()
@@ -133,7 +133,7 @@ const mkbuild = {
const findproj = {b, bldfile
if !findbase(b, bldfile) || !std.chdir(b.basedir)
- std.fatal(1, "could not find %s\n", bldfile)
+ std.fatal("could not find %s\n", bldfile)
;;
bld.setdir(b, "")
}
diff --git a/mbld/opts.myr b/mbld/opts.myr
index bef9aca..7c4f0f2 100644
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -56,13 +56,13 @@ const initopts = {
| "Darwin": opt_sys = "osx"
| "FreeBSD": opt_sys = "freebsd"
| "Plan9": opt_sys = "plan9"
- | unknown: std.fatal(1, "unknown system \"%s\"\n", unknown)
+ | unknown: std.fatal("unknown system \"%s\"\n", unknown)
;;
match si.arch
| "x86_64": opt_arch = "x64"
| "amd64": opt_arch = "x64"
- | unknown: std.fatal(1, "unknown architecture \"%s\"\n", unknown)
+ | unknown: std.fatal("unknown architecture \"%s\"\n", unknown)
;;
opt_incpaths = [][:]
diff --git a/mbld/parse.myr b/mbld/parse.myr
index 7bd10d7..e572cd3 100644
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -59,7 +59,7 @@ const loadall = {b, path, dir
loadall(b, subproj, subpath)
b.basedir = curbase
else
- std.fatal(1, "could not open %s or %s \n", subbld, subproj)
+ std.fatal("could not open %s or %s \n", subbld, subproj)
;;
std.slfree(subbld)
std.slfree(subproj)
@@ -91,7 +91,7 @@ const sortdeps = {b
const visit = {all, b, targ, looped, marked
if std.hthas(looped, targ)
- std.fatal(1, "cycle in build depgraph involving %s\n", targ)
+ std.fatal("cycle in build depgraph involving %s\n", targ)
elif std.hthas(marked, targ)
-> all
;;
@@ -109,7 +109,7 @@ const getdeps = {targ
match targ
| `Bin t: -> t.libdeps
| `Lib t: -> t.libdeps
- | _: std.fatal(1, "depending on non-library target")
+ | _: std.fatal("depending on non-library target")
;;
}
@@ -123,7 +123,7 @@ const mkparser = {path, dir, basedir
p.basedir = std.sldup(basedir)
match std.slurp(path)
| `std.Ok d: p.data = d
- | `std.Fail _: std.fatal(1, "could not open '%s'\n", path)
+ | `std.Fail _: std.fatal("could not open '%s'\n", path)
;;
p.rest = p.data
-> p
@@ -353,7 +353,7 @@ const myrtarget = {p, targ
| ("noinst", ""): inst = false
| ("sys", tags): systags = std.slpush(systags, tags)
| (invalid, _):
- std.fatal(1, "%s: got invalid attr '%s'\n", targ, invalid)
+ std.fatal("%s: got invalid attr '%s'\n", targ, invalid)
;;
;;
for inc in bld.opt_incpaths
@@ -614,7 +614,7 @@ const libpath = {p, libpath
targ = std.fmt("%s:%s", p.fdir, lib)
| `std.Some idx:
if idx == libpath.len
- std.fatal(1, "libdep %s missing library after ':'\n")
+ std.fatal("libdep %s missing library after ':'\n")
;;
/* absolute path */
if std.hasprefix(libpath, "@/") || std.hasprefix(libpath, "@:")
@@ -627,7 +627,7 @@ const libpath = {p, libpath
lib = std.sldup(libpath[idx+1:])
targ = std.pathcat(p.fdir, libpath)
if std.hasprefix(targ, "../")
- std.fatal(1, "library %s outside of project\n", libpath)
+ std.fatal("library %s outside of project\n", libpath)
;;
;;
;;
diff --git a/mbld/test.myr b/mbld/test.myr
index aebf27e..ae603a0 100644
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -125,7 +125,7 @@ const runtest = {bin
log = std.strcat(bin, ".log")
match std.spork([bin][:])
| `std.Fail m:
- std.fatal(1, "unable to run test: %s\n", m)
+ std.fatal("unable to run test: %s\n", m)
| `std.Ok (pid, infd, outfd):
match std.fslurp(outfd)
| `std.Ok "": /* empty output; nothing to log */
diff --git a/mbld/util.myr b/mbld/util.myr
index 29e325c..9e11a35 100644
--- a/mbld/util.myr
+++ b/mbld/util.myr
@@ -20,17 +20,17 @@ const run = {cmd
printcmd(cmd)
pid = std.fork()
if pid == -1
- std.fatal(1, "could not fork command\n")
+ std.fatal("could not fork command\n")
elif pid == 0
if std.execvp(cmd[0], cmd) < 0
- std.fatal(1, "failed to exec %s\n", cmd[0])
+ std.fatal("failed to exec %s\n", cmd[0])
;;
else
match std.wait(pid)
| `std.Wsuccess: /* nothing */
- | `std.Wfailure: std.fatal(1, "FAIL: \"%s\"\n", std.strjoin(cmd, " "))
- | `std.Wsignalled: std.fatal(1, "CRASH: \"%s\"\n", std.strjoin(cmd, " "))
- | `std.Waiterror: std.fatal(1, "WAT: \"%s\"\n", std.strjoin(cmd, " "))
+ | `std.Wfailure: std.fatal("FAIL: \"%s\"\n", std.strjoin(cmd, " "))
+ | `std.Wsignalled: std.fatal("CRASH: \"%s\"\n", std.strjoin(cmd, " "))
+ | `std.Waiterror: std.fatal("WAT: \"%s\"\n", std.strjoin(cmd, " "))
;;
;;
}
@@ -85,7 +85,7 @@ const srcswapsuffix = {src, new
elif std.sleq(suff, ".s")
-> std.strcat(base, new)
else
- std.fatal(1, "unrecognized source %s\n", src)
+ std.fatal("unrecognized source %s\n", src)
;;
}
@@ -98,7 +98,7 @@ const strlistfree = {sl
const gettarg = {tab, n
match std.htget(tab, n)
- | `std.None: std.fatal(1, "internal: nonexistent %s\n", n)
+ | `std.None: std.fatal("internal: nonexistent %s\n", n)
| `std.Some t: -> t
;;
}
@@ -114,7 +114,7 @@ const setdir = {b, dir
std.put("Entering directory '%s'\n", dir)
if !std.chdir(p)
- std.fatal(1, "could not cd into %s\n", p)
+ std.fatal("could not cd into %s\n", p)
;;
b.curdir = dir
std.slfree(p)
diff --git a/mbldwrap.sh b/mbldwrap.sh
index d922acb..620fb70 100755
--- a/mbldwrap.sh
+++ b/mbldwrap.sh
@@ -2,16 +2,20 @@
# this should be a bourne compatible shell script.
if test `uname` = Plan9; then
- echo "PLAN 9 BOOTSTRAP"
export MYR_MUSE=../muse/$O.out
export MYR_MC=../$O/$O.out
export MYR_RT=../rt/_myrrt.$O
BOOT="./mk/bootstrap/bootstrap+`uname -s`-`uname -m`.sh"
else
- echo "POSIX BOOTSTRAP"
export MYR_MUSE=../muse/muse
export MYR_MC=../6/6m
export MYR_RT=../rt/_myrrt.o
BOOT="./mk/bootstrap/bootstrap+`uname -s`-`uname -m`.sh"
fi
-mbld $@ || ./mbld/mbld $@ || $BOOT
+
+if [ -z "$@" ]; then
+ mbld || ./mbld/mbld || $BOOT
+else
+ mbld $@ || ./mbld/mbld $@ || \
+ (echo "Unable to run mbld $@; have you build successfully"; false)
+fi
diff --git a/test/matchargstr.myr b/test/matchargstr.myr
index 50d539b..0d8cf4e 100644
--- a/test/matchargstr.myr
+++ b/test/matchargstr.myr
@@ -12,12 +12,12 @@ const main = {
v = `Str "asdf"
match v
- | `Int 127: std.fatal(1, "wrong match `Int 127\n")
- | `Str "foo": std.fatal(1, "Wrong match `Str \"foo\"\n")
- | `Str "fsda": std.fatal(1, "Wrong match `Str \"fsda\"\n")
+ | `Int 127: std.fatal("wrong match `Int 127\n")
+ | `Str "foo": std.fatal("Wrong match `Str \"foo\"\n")
+ | `Str "fsda": std.fatal("Wrong match `Str \"fsda\"\n")
| `Str "asdf": std.put("Correct `Str \"asdf\"!\n")
- | `Nil: std.fatal(1, "Wrong match `Str \"fsda\"\n")
- | _: std.fatal(1, "Impossible failed match\n")
+ | `Nil: std.fatal("Wrong match `Str \"fsda\"\n")
+ | _: std.fatal("Impossible failed match\n")
;;
}