shithub: mc

Download patch

ref: 8a57984a3b3102a30ca6210f7b73dc523f620377
parent: d3566a96838ddc2346fa57f8c4d908812bee6206
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Sep 17 07:24:12 EDT 2015

Load sys attrs once.

--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -11,6 +11,7 @@
 use "test.use"
 use "types.use"
 use "util.use"
+use "syssel.use"
 
 const main = {args : byte[:][:]
 	var b : bld.build#
@@ -129,6 +130,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)
+	bld.addsysattrs(b.sysattrs)
 	-> b
 }
 
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -27,7 +27,7 @@
 	var ok, sel
 	var targs
 
-	sel = mksyssel("mbld", 0, "mbld")
+	sel = mksyssel(b, "mbld", 0, "mbld")
 	ok = loadall(b, b.bldfile, "", sel)
 
 	targs = sysselfin(sel)
@@ -199,7 +199,7 @@
 /* bintarget: myrtarget */
 const bintarget = {b, p
 	var t
-	t = myrtarget(p, "bin")
+	t = myrtarget(b, p, "bin")
 	addtarg(p, b, t.name, t.systags, `Bin t)
 }
 
@@ -206,7 +206,7 @@
 /* libtarget: myrtarget */
 const libtarget = {b, p
 	var t
-	t = myrtarget(p, "lib")
+	t = myrtarget(b, p, "lib")
 	t.islib = true
 	addtarg(p, b, t.name, t.systags, `Lib t)
 }
@@ -214,7 +214,7 @@
 /* testtarget: myrtarget */
 const testtarget = {b, p
 	var t
-	t = myrtarget(p, "test")
+	t = myrtarget(b, p, "test")
 	t.istest = true
 	t.install = false
 	addtarg(p, b, t.name, t.systags, `Bin t)
@@ -322,7 +322,7 @@
 myrtarget: name '=' inputlist ';;'
 	| name attrlist = inputlist ';;'
 */
-const myrtarget = {p, targ
+const myrtarget = {b, p, targ
 	var ldscript, runtime, inst, incpath, systags
 	var name, inputs, libdeps, attrs
 	var istest
@@ -348,7 +348,7 @@
 		failparse(p, "expected '=' after '{} {}'\n", targ, name)
 	;;
 
-	fsel = mksyssel(p.fname, p.line, name)
+	fsel = mksyssel(b, p.fname, p.line, name)
 	match inputlist(p)
 	| `std.Some (wl, libs): 
 		libdeps = libs
--- a/mbld/syssel.myr
+++ b/mbld/syssel.myr
@@ -1,6 +1,7 @@
 use std
 
 use "opts.use"
+use "types.use"
 
 pkg bld =
 	type syssel(@a) = struct
@@ -12,13 +13,14 @@
 		_best	: std.htab(byte[:], @a)#
 	;;
 
-	generic mksyssel	: (f : byte[:], line : int, targ : byte[:] -> syssel(@a)#)
+	generic mksyssel	: (b : build#, f : byte[:], line : int, targ : byte[:] -> syssel(@a)#)
 	generic sysseladd	: (syssel : syssel(byte[:])#, file : byte[:] -> void)
 	generic sysseladdlist	: (syssel : syssel(@a)#, base : byte[:], attrs : byte[:][:], val : @a -> void)
 	generic sysselfin	: (syssel : syssel(@a)# -> @a[:])
+	const addsysattrs	: (sa : std.htab(byte[:], bool)# -> void)
 ;;
 
-generic mksyssel = {file, line, targ
+generic mksyssel = {b, file, line, targ
 	var syssel
 
 	syssel = std.mk([
@@ -27,9 +29,8 @@
 		.targ = targ,
 		._match = std.mkht(std.strhash, std.streq),
 		._best = std.mkht(std.strhash, std.streq),
-		.sysattrs = std.mkht(std.strhash, std.streq),
+		.sysattrs = b.sysattrs
 	])
-	addsysattrs(syssel.sysattrs)
 	-> syssel
 }
 
@@ -91,12 +92,12 @@
 	;;
 	std.htfree(syssel._match)
 	std.htfree(syssel._best)
-	std.htfree(syssel.sysattrs)
 	-> ret
 }
 
 const addsysattrs = {sa
 	var attrs
+
 	match opt_sys
 	| "freebsd":	attrs = ["freebsd", "posixy"][:]
 	| "osx":	attrs = ["osx", "posixy"][:]
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -7,6 +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 */
 
 		/* build params */
 		all	: byte[:][:]			/* all targets, in reverse topological order */