shithub: mc

Download patch

ref: 3de952510eb2a23350d24ed926f19c0cf72a12f2
parent: 8b110be262c4839c498c09b2bd803f24a8b8e9b7
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Aug 26 08:08:38 EDT 2015

Give better errors for poorly specified deps.

--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -35,11 +35,11 @@
 		b.all = std.slpush(b.all, name)
 		std.htput(b.targs, name, targ)
 	;;
-	std.slfree(targs)
 
 	if ok
 		ok = sortdeps(b)
 	;;
+	std.slfree(targs)
 	-> ok
 }
 
@@ -107,8 +107,8 @@
 	marked = std.mkht(std.strhash, std.streq)
 	for dep in b.all
 		match gettarg(b.targs, dep)
-		| `Bin _:	all = visit(all, b, dep, looped, marked)
-		| `Lib _:	all = visit(all, b, dep, looped, marked)
+		| `Bin _:	all = visit(all, b, "all", dep, looped, marked)
+		| `Lib _:	all = visit(all, b, "all", dep, looped, marked)
 		| targ:		all = std.slpush(all, dep)
 		;;
 	;;
@@ -117,7 +117,7 @@
 	-> true
 }
 
-const visit = {all, b, targ, looped, marked
+const visit = {all, b, parent, targ, looped, marked
 	if std.hthas(looped, targ)
 		std.fatal("cycle in build depgraph involving {}\n", targ)
 	elif std.hthas(marked, targ)
@@ -125,8 +125,8 @@
 	;;
 
 	std.htput(looped, targ, true)
-	for (dir, lib, dep) in getdeps(gettarg(b.targs, targ))
-		all = visit(all, b, dep, looped, marked)
+	for (dir, lib, dep) in getdeps(b, parent, targ)
+		all = visit(all, b, targ, dep, looped, marked)
 	;;
 	std.htdel(looped, targ)
 	std.htput(marked, targ, true)
@@ -133,11 +133,16 @@
 	-> std.slpush(all, targ)
 }
 
-const getdeps = {targ
-	match targ
-	| `Bin t:	-> t.libdeps
-	| `Lib t:	-> t.libdeps
-	| _:	std.fatal("depending on non-library target")
+const getdeps = {b, parent, targname
+	match std.htget(b.targs, targname)
+	| `std.Some targ:
+		match targ
+		| `Bin t:	-> t.libdeps
+		| `Lib t:	-> t.libdeps
+		| _:	std.fatal("{} depends on non-library target", parent)
+		;;
+	| `std.None:
+		std.fatal("{}: could not find dependency {}\n", parent, targname)
 	;;
 }
 
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -28,6 +28,9 @@
 	;;
 
 	type myrtarg = struct
+		file	: byte[:]
+		line	: int
+
 		islib	: bool
 		dir	: byte[:]
 		name	: byte[:]