summaryrefslogtreecommitdiff
path: root/mbld
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-05-31 12:55:53 -0700
committerOri Bernstein <ori@eigenstate.org>2017-05-31 12:55:53 -0700
commite1f5c300e0985422ef62acf841b43614fd58937b (patch)
tree3a133e291cf3e193a49db6c2d8f37a73cc78f843 /mbld
parentf81bd2d4d92e1c09f4111536ae0e45cdd21e1ff3 (diff)
downloadmc-e1f5c300e0985422ef62acf841b43614fd58937b.tar.gz
Groundwork for tag versions.
Diffstat (limited to 'mbld')
-rw-r--r--mbld/main.myr2
-rw-r--r--mbld/opts.myr23
-rw-r--r--mbld/syssel.myr46
-rw-r--r--mbld/types.myr2
4 files changed, 55 insertions, 18 deletions
diff --git a/mbld/main.myr b/mbld/main.myr
index 0725080..0523faf 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -170,7 +170,7 @@ const mkbuild = {tags
b.targs = std.mkht(std.strhash, std.streq)
b.gensrc = std.mkht(std.strhash, std.streq)
b.built = std.mkht(std.strhash, std.streq)
- b.sysattrs = std.mkht(std.strhash, std.streq)
+ b.tags = std.mkht(std.strhash, std.streq)
bld.addsysattrs(b, tags)
-> b
}
diff --git a/mbld/opts.myr b/mbld/opts.myr
index 41918b3..e753dcf 100644
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -5,6 +5,7 @@ use "config"
pkg bld =
var opt_arch : byte[:]
var opt_sys : byte[:]
+ var opt_sysvers : (int, int, int)
var opt_runtime : byte[:]
var opt_genasm : bool
var opt_incpaths : byte[:][:]
@@ -23,6 +24,7 @@ pkg bld =
var sysstr : byte[:]
const initopts : (-> void)
+ const parseversion : (v : byte[:] -> (int, int, int))
;;
var opt_arch = ""
@@ -33,6 +35,7 @@ var opt_runtime = ""
var opt_incpaths /* FIXME: taking a constant slice is a nonconstant initializer */
var opt_instbase = ""
var opt_destdir = ""
+var opt_sysvers
var opt_debug = false
var opt_mc = "6m"
var opt_as = "as"
@@ -56,6 +59,8 @@ const initopts = {
| unknown: std.fatal("unknown systemy \"{}\"\n", unknown)
;;
+ opt_sysvers = parseversion(si.release)
+
match si.arch
| "x86_64": opt_arch = "x64"
| "amd64": opt_arch = "x64"
@@ -72,3 +77,21 @@ const initopts = {
opt_runtime = std.pathjoin([opt_instbase, config.Libpath, config.Runtime][:])
;;
}
+
+const parseversion = {v
+ var a
+ var i
+
+ i = 0
+ a = [0, 0, 0]
+ for e in std.bysplit(v, ".")
+ match std.intparse(e)
+ | `std.Some n: a[i++] = n
+ | `std.None: continue
+ ;;
+ if i == 3
+ break
+ ;;
+ ;;
+ -> (a[0], a[1], a[2])
+}
diff --git a/mbld/syssel.myr b/mbld/syssel.myr
index 741b029..06a4e62 100644
--- a/mbld/syssel.myr
+++ b/mbld/syssel.myr
@@ -8,7 +8,7 @@ pkg bld =
file : byte[:]
line : int
targ : byte[:]
- sysattrs : std.htab(byte[:], bool)#
+ sysattrs : std.htab(byte[:], (int, int, int))#
_match : std.htab(byte[:], int)#
_best : std.htab(byte[:], @a)#
;;
@@ -29,7 +29,7 @@ generic mksyssel = {b, file, line, targ
.targ = targ,
._match = std.mkht(std.strhash, std.streq),
._best = std.mkht(std.strhash, std.streq),
- .sysattrs = b.sysattrs
+ .sysattrs = b.tags
])
-> syssel
}
@@ -60,16 +60,26 @@ generic sysseladd = {syssel, f
}
generic sysseladdlist = {syssel, base, attrs, val
- var nmatch, curbest
+ var nmatch, curbest, n, v
nmatch = 0
for a in attrs
- if std.hthas(syssel.sysattrs, a)
- nmatch++
- else
+ match std.strfind(a, ":")
+ | `std.Some i:
+ n = a[:i]
+ v = parseversion(a[1:])
+ | `std.None:
+ n = a
+ v = (-1, -1, -1)
+ ;;
+
+ if !std.hthas(syssel.sysattrs, n)
nmatch = -1
break
;;
+ if newenough(syssel, a, v)
+ nmatch++
+ ;;
;;
curbest = std.htgetv(syssel._match, base, -1)
if curbest < nmatch
@@ -78,6 +88,10 @@ generic sysseladdlist = {syssel, base, attrs, val
;;
}
+const newenough = {syssel, attr, vers
+ -> true
+}
+
generic sysselfin = {syssel
var keys, nmatch, ret
@@ -99,20 +113,20 @@ const addsysattrs = {b, tags
var tagfile
match opt_sys
- | "freebsd": tag(b.sysattrs, ["freebsd", "posixy"][:])
- | "netbsd": tag(b.sysattrs, ["netbsd", "posixy"][:])
- | "openbsd": tag(b.sysattrs, ["openbsd", "posixy"][:])
- | "osx": tag(b.sysattrs, ["osx", "posixy"][:])
- | "linux": tag(b.sysattrs, ["linux", "posixy"][:])
- | "plan9": tag(b.sysattrs, ["plan9"][:])
+ | "freebsd": tag(b.tags, ["freebsd", "posixy"][:])
+ | "netbsd": tag(b.tags, ["netbsd", "posixy"][:])
+ | "openbsd": tag(b.tags, ["openbsd", "posixy"][:])
+ | "osx": tag(b.tags, ["osx", "posixy"][:])
+ | "linux": tag(b.tags, ["linux", "posixy"][:])
+ | "plan9": tag(b.tags, ["plan9"][:])
| unknown: std.fatal("unknown system \"{}\"\n", unknown)
;;
match opt_arch
- | "x64": tag(b.sysattrs, ["x64"][:])
+ | "x64": tag(b.tags, ["x64"][:])
| unknown: std.fatal("unknown architecture {}\n", unknown)
;;
- tag(b.sysattrs, tags)
+ tag(b.tags, tags)
tagfile = std.pathcat(b.basedir, "systags")
if std.fexists(tagfile)
@@ -130,7 +144,7 @@ const loadtagfile = {b, tagfile
(tag, data) = word(data)
match tag
| `std.Some w:
- std.htput(b.sysattrs, w, true)
+ std.htput(b.tags, w, (-1, -1, -1))
| `std.None:
if data.len > 0
std.fatal("junk character near '{}'\n", trailing(data, 10))
@@ -168,7 +182,7 @@ const word = {data
const tag = {sa, tags
for t in tags
- std.htput(sa, t, true)
+ std.htput(sa, t, (-1, -1, -1))
;;
}
diff --git a/mbld/types.myr b/mbld/types.myr
index 1c9e3b6..569b44f 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -7,7 +7,7 @@ pkg bld =
bldfile : byte[:]
curdir : byte[:]
built : std.htab(byte[:], bool)# /* set of targets built in this run */
- sysattrs : std.htab(byte[:], bool)# /* set of tags that identify a system */
+ tags : std.htab(byte[:], (int, int, int))#
/* build params */
all : byte[:][:] /* targets in reverse topological order */