summaryrefslogtreecommitdiff
path: root/mbld
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-04-21 01:28:52 -0700
committerOri Bernstein <ori@eigenstate.org>2017-04-21 01:54:28 -0700
commit0391facef2fc8f8704fcfb5150b9381876c3aebd (patch)
treed24ade7ef01b0c4f8a1bc48bc49fc81e641cfcf6 /mbld
parentac53b78d88d7f460ada21633fb1dc8ee96b53a36 (diff)
downloadmc-0391facef2fc8f8704fcfb5150b9381876c3aebd.tar.gz
bld.proj files are no longer order dependent.
Diffstat (limited to 'mbld')
-rw-r--r--mbld/parse.myr69
-rw-r--r--mbld/types.myr8
2 files changed, 50 insertions, 27 deletions
diff --git a/mbld/parse.myr b/mbld/parse.myr
index b49e800..a8efbf1 100644
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -18,13 +18,15 @@ type parser = struct
basedir : byte[:]
line : int
+ /* all targets */
+ targs : targ[:]
+
/* default parameter values */
incpath : byte[:][:]
libdeps : byte[:][:]
tstdeps : byte[:][:]
runtime : byte[:]
ldscript: byte[:]
- istest : bool
install : bool
/* extracted data for further parsing */
@@ -59,6 +61,10 @@ const loadall = {b, path, dir, sel
p = mkparser(path, dir, b.basedir, sel)
ok = bld.parse(b, p, "")
+ for t in p.targs
+ setopts(p, t)
+ ;;
+
for sub in p.subdirs
subbld = std.pathcat(sub, "bld.sub")
subproj = std.pathcat(sub, "bld.proj")
@@ -88,6 +94,36 @@ const loadall = {b, path, dir, sel
-> ok
}
+const setopts = {p, targ
+ match targ
+ | `Bin t: setmyropt(p, t)
+ | `Lib t: setmyropt(p, t)
+ | _: /* only myr targets have settable defaults so far */
+ ;;
+}
+
+const setmyropt = {p, t
+ var libdep, tstdep
+
+ t.install = t.install && p.install
+ if t.runtime.len == 0
+ t.runtime = p.runtime
+ ;;
+ if t.ldscript.len == 0
+ t.ldscript = p.ldscript
+ ;;
+
+ std.sljoin(&t.incpath, p.incpath)
+ for l in p.libdeps
+ libdep = libpath(p, l)
+ std.slpush(&t.libdeps, libdep)
+ ;;
+ for l in p.tstdeps
+ tstdep = libpath(p, l)
+ std.slpush(&t.tstdeps, tstdep)
+ ;;
+}
+
const mkparser = {path, dir, basedir, sel
var p
@@ -102,7 +138,6 @@ const mkparser = {path, dir, basedir, sel
.tstdeps = [][:],
.runtime = "",
.ldscript = "",
- .istest = false,
.install = true,
])
match std.slurp(path)
@@ -375,7 +410,7 @@ myrtarget: name '=' inputlist ';;'
*/
const myrtarget = {b, p, targ
var ldscript, runtime, install, incpath, tags
- var libdeps, libdep, tstdeps, tstdep
+ var libdeps, tstdeps
var name, inputs, attrs
var istest
var fsel
@@ -417,24 +452,13 @@ const myrtarget = {b, p, targ
failparse(p, "expected ';;' terminating input list, got {}\n", peekc(p))
;;
- install = p.install
- istest = p.istest
- runtime = p.runtime
- ldscript = p.ldscript
+ install = true
+ ldscript = ""
+ runtime = ""
incpath = [][:]
- std.sljoin(&incpath, p.incpath)
- for l in p.libdeps
- libdep = libpath(p, l)
- std.slpush(&libdeps, libdep)
- ;;
-
- tstdeps = [][:]
- for l in p.tstdeps
- tstdep = libpath(p, l)
- std.slpush(&tstdeps, tstdep)
- ;;
-
tags = [][:]
+ istest = false
+ tstdeps = [][:]
for elt in attrs
match elt
| ("ldscript", lds): ldscript = std.sldup(lds)
@@ -445,10 +469,8 @@ const myrtarget = {b, p, targ
| ("noinst", ""): install = false
| ("test", ""): istest = true
| ("notest", ""): istest = false
- | (invalid, ""):
- std.fatal("{}: got invalid attr '{}'\n", targ, invalid)
- | (invalid, attr):
- std.fatal("{}: got invalid attr '{} = {}'\n", targ, invalid, attr)
+ | (invalid, ""): std.fatal("{}: got invalid attr '{}'\n", targ, invalid)
+ | (invalid, attr): std.fatal("{}: got invalid attr '{} = {}'\n", targ, invalid, attr)
;;
;;
std.sljoin(&incpath, bld.opt_incpaths)
@@ -750,6 +772,7 @@ const addtarg = {p, b, name, tags, targ
tn = std.fmt("{}:{}", p.fdir, name)
sysseladdlist(p.targsel, tn, tags, (tn, targ))
+ std.slpush(&p.targs, targ)
}
const libpath = {p, libpath
diff --git a/mbld/types.myr b/mbld/types.myr
index e5cba64..1c9e3b6 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -10,10 +10,10 @@ pkg bld =
sysattrs : std.htab(byte[:], bool)# /* set of tags that identify a system */
/* build params */
- all : byte[:][:] /* all targets, in reverse topological order */
- targs : std.htab(byte[:], targ)# /* dir => target mapping */
- tdeps : std.htab(byte[:], byte[:][:]) /* targname => depname[:] mapping */
- gensrc : std.htab(byte[:], cmdtarg#)# /* generated src => generating target mapping */
+ all : byte[:][:] /* targets in reverse topological order */
+ targs : std.htab(byte[:], targ)# /* name => target mapping */
+ tdeps : std.htab(byte[:], byte[:][:]) /* targname => depname[:][:] */
+ gensrc : std.htab(byte[:], cmdtarg#)# /* generated => generator mapping */
prefix : byte[:]
system : byte[:]
arch : byte[:]