ref: e1f5c300e0985422ef62acf841b43614fd58937b
parent: f81bd2d4d92e1c09f4111536ae0e45cdd21e1ff3
author: Ori Bernstein <ori@eigenstate.org>
date: Wed May 31 08:55:53 EDT 2017
Groundwork for tag versions.
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -170,7 +170,7 @@
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
}
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -5,6 +5,7 @@
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 @@
var sysstr : byte[:]
const initopts : (-> void)
+ const parseversion : (v : byte[:] -> (int, int, int))
;;
var opt_arch = ""
@@ -33,6 +35,7 @@
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 @@
| unknown: std.fatal("unknown systemy \"{}\"\n", unknown)
;;
+ opt_sysvers = parseversion(si.release)
+
match si.arch
| "x86_64": opt_arch = "x64"
| "amd64": opt_arch = "x64"
@@ -71,4 +76,22 @@
if opt_runtime.len == 0
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])
}
--- a/mbld/syssel.myr
+++ b/mbld/syssel.myr
@@ -8,7 +8,7 @@
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 @@
.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 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 @@
;;
}
+const newenough = {syssel, attr, vers
+ -> true
+}
+
generic sysselfin = {syssel
var keys, nmatch, ret
@@ -99,20 +113,20 @@
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 @@
(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 tag = {sa, tags
for t in tags
- std.htput(sa, t, true)
+ std.htput(sa, t, (-1, -1, -1))
;;
}
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -7,7 +7,7 @@
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 */