shithub: mc

Download patch

ref: f756e0926ef4b94848ad8b7963cf85f088b81621
parent: af33941e4a225c62914d5929983fb2c93176f14c
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Sep 24 07:53:01 EDT 2014

Prepare to implement build attributes.

    Support for this syntax:

        bin mybinary {noinstall, ldscript=...} =
            source.myr
            list.myr
        ;

--- a/build.myr
+++ b/build.myr
@@ -17,10 +17,10 @@
 const buildall = {p
 	for t in p.targs
 		match t
-		| `Bin (b, leaves):
-			buildbin(b, leaves)
-		| `Lib (l, leaves):
-			buildlib(l, leaves)
+		| `Bin [.name=bin, .inputs=leaves]:
+			buildbin(bin, leaves)
+		| `Lib [.name=lib, .inputs=leaves]:
+			buildlib(lib, leaves)
 		| `Sub subs:
 			for s in subs
 				dosub(s)
@@ -43,14 +43,14 @@
 	built = false
 	for t in p.targs
 		match t
-		| `Bin (b, leaves):
-			if std.sleq(b, targ)
-				buildbin(b, leaves)
+		| `Bin [.name=bin, .inputs=leaves]:
+			if std.sleq(bin, targ)
+				buildbin(bin, leaves)
 				built = true
 			;;
-		| `Lib (l, leaves):
-			if std.sleq(l, targ)
-				buildlib(l, leaves)
+		| `Lib [.name=lib, .inputs=leaves]:
+			if std.sleq(lib, targ)
+				buildlib(lib, leaves)
 				built = true
 			;;
 		| `Sub subs:
--- a/clean.myr
+++ b/clean.myr
@@ -13,9 +13,9 @@
 const cleanall = {p
 	for t in p.targs
 		match t
-		| `Bin (bin, leaves):
+		| `Bin [.name=bin, .inputs=leaves]:
 			cleanup(bin, leaves, true)
-		| `Lib (lib, leaves):
+		| `Lib [.name=lib, .inputs=leaves]:
 			cleanup(lib, leaves, true)
 		| `Sub subs:
 		| `Man m:
@@ -27,11 +27,11 @@
 const clean = {p, targ
 	for t in p.targs
 		match t
-		| `Bin (bin, leaves):
+		| `Bin [.name=bin, .inputs=leaves]:
 			if std.sleq(bin, targ)
 				cleanup(bin, leaves, true)
 			;;
-		| `Lib (lib, leaves):
+		| `Lib [.name=lib, .inputs=leaves]:
 			if std.sleq(lib, targ)
 				cleanup(lib, leaves, true)
 			;;
--- a/install.myr
+++ b/install.myr
@@ -24,9 +24,9 @@
 
 	for t in p.targs
 		match t
-		| `Bin (bin, leaves):
+		| `Bin [.name=bin, .inputs=leaves, .install=true]:
 			movefile(delete, bin, opt_instroot, opt_destdir, "bin")
-		| `Lib (lib, leaves):
+		| `Lib [.name=lib, .inputs=leaves, .install=true]:
 			movefile(delete, lib, opt_instroot, opt_destdir, "lib/myr")
 			libarchive = std.fmt("lib%s.a", lib)
 			movefile(delete, libarchive, opt_instroot, opt_destdir, "lib/myr")
--- a/parse.myr
+++ b/parse.myr
@@ -15,9 +15,17 @@
 		arch	: byte[:]
 	;;
 
+	type myrtarg = struct
+		name	: byte[:]
+		inputs	: byte[:][:]
+		install	: bool
+		ldscript	: byte[:]
+		runtime	: byte[:]
+	;;
+
 	type target = union
-		`Bin	(byte[:], byte[:][:])
-		`Lib	(byte[:], byte[:][:])
+		`Bin	myrtarg
+		`Lib	myrtarg
 		`Sub	byte[:][:]
 		`Man	byte[:][:]
 	;;
@@ -65,11 +73,11 @@
 }
 
 const bintarget = {p
-	p.targs = std.slpush(p.targs, `Bin nametarget(p, "bin"))
+	p.targs = std.slpush(p.targs, `Bin myrtarget(p, "bin"))
 }
 
 const libtarget = {p
-	p.targs = std.slpush(p.targs, `Lib nametarget(p, "lib"))
+	p.targs = std.slpush(p.targs, `Lib myrtarget(p, "lib"))
 }
 
 const subtarget = {p
@@ -80,7 +88,7 @@
 	p.targs = std.slpush(p.targs, `Man anontarget(p, "man"))
 
 }
-const nametarget = {p, targ
+const myrtarget = {p, targ
 	var name, inputs
 
 	match word(p)
@@ -100,7 +108,7 @@
 	if !matchc(p, ';')
 		failparse(p, "expected ';' terminating input list, got %c\n", peekc(p))
 	;;
-	-> (name, inputs)
+	-> [.name=name, .inputs=inputs, .install=true, .ldscript=[][:], .runtime=[][:]]
 }
 
 const anontarget = {p, targ