shithub: mc

Download patch

ref: 5932f72977cd3eec1d0e575d10bbae9709608278
parent: 2cecb2f0578cc0893fbb147dcc3d174f6643baac
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Sep 10 21:53:51 EDT 2015

Add dependencies for building named targets.

--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -10,7 +10,7 @@
 pkg bld =
 	const buildall	: (b : build# -> bool)
 	const genall	: (b : build# -> bool)
-	const build	: (b : build#, target : byte[:] -> bool)
+	const buildtarg	: (b : build#, target : byte[:] -> bool)
 	const buildbin	: (b : build#, bt : myrtarg#, addsrc : bool -> void)
 	const buildlib	: (b : build#, lt : myrtarg# -> void)
 ;;
@@ -31,6 +31,54 @@
 		;;
 	;;
 	-> true
+}
+
+const buildtarg = {b, targ
+	var depset
+
+	depset = std.mkht(std.strhash, std.streq)
+	addeps(b, targ, depset)
+	for tn in b.all
+		if std.hthas(b.built, tn)
+			continue
+		;;
+		if !std.hthas(depset, tn)
+			continue
+		;;
+		std.htput(b.built, tn, true)
+		match gettarg(b.targs, tn)
+		| `Bin bt:	buildbin(b, bt, false)
+		| `Lib lt:	buildlib(b, lt)
+		| `Test tt:	/* build on 'mbld test' by default */
+		| `Gen gt:	genfiles(b, gt)
+		| `Man mt:	/* nothing needed */
+		| `Cmd ct:	/* these are for manual commands */
+		;;
+		if std.sleq(tn, targ)
+			break
+		;;
+	;;
+	std.htfree(depset)
+	-> true
+}
+
+const addeps = {b, targ, depset
+	if std.hthas(depset, targ)
+		->
+	;;
+	std.put("#### Adding dep {}\n", targ)
+	std.htput(depset, targ, true)
+	match gettarg(b.targs, targ)
+	| `Bin bt:
+		for (dir, lib, targname) in bt.libdeps
+			addeps(b, targname, depset)
+		;;
+	| `Lib lt:
+		for (dir, lib, targname) in lt.libdeps
+			addeps(b, targname, depset)
+		;;
+	| _:
+	;;
 }
 
 const genall = {b
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -115,7 +115,7 @@
 				| "install":	bld.install(b)
 				| "uninstall":	bld.uninstall(b)
 				| "test":	bld.test(b)
-				| target:	bld.build(b, target)
+				| target:	bld.buildtarg(b, target)
 				;;
 			;;
 		;;
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -10,7 +10,7 @@
 
 function build {
     rm -f $1 $1.o $1.s $1.use
-    mbld -b $1 -C../6/6m -M../muse/muse -I../libstd -r../rt/_myrrt.o $1.myr
+    mbld -b $1 -C../6/6m -M../muse/muse -I../lib/std -I../lib/sys -r../rt/_myrrt.o $1.myr
 }
 
 function pass {