shithub: mc

Download patch

ref: 08871fe6b8e6161e988e1aa52a59da792273ab4a
parent: b23b5b3f9a003382d092089ce00104be3cfddd9a
author: Ori Bernstein <ori@eigenstate.org>
date: Mon May 16 07:14:34 EDT 2016

Check freshness against the actual outputs.

--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -128,7 +128,7 @@
 	if !std.hthas(dg.deps, targ.name)
 		std.fatal("no input files for {}\n", targ.name)
 	;;
-	if builddep(b, dg, targ.name, targ.incpath) || !freshlibs(targ, dg.libs)
+	if builddep(b, dg, targ.name, targ.incpath) || !freshlibs(targ, targ.name, dg.libs)
 		src = std.htkeys(dg.sources)
 
 		incs = std.sldup(targ.incpath)
@@ -144,7 +144,7 @@
 }
 
 const buildlib = {b, targ
-	var archive
+	var archive, usefile
 	var u, l
 	var dg
 	var lib, src
@@ -154,13 +154,14 @@
 	lib = targ.name
 	std.put("{}/lib{}.a...\n", b.curdir, lib)
 	archive = std.fmt("lib{}.a", lib)
+	usefile = std.fmt("lib{}.use", lib)
 	dg = myrdeps(b, targ, false, false)
 	if !std.hthas(dg.deps, lib)
 		std.fatal("no target declared for {}\n", lib)
 	;;
-	u = builddep(b, dg, targ.name, targ.incpath)
+	u = builddep(b, dg, usefile, targ.incpath)
 	l = builddep(b, dg, archive, targ.incpath)
-	if  u || l || !freshlibs(targ, dg.libs)
+	if  u || l || !freshlibs(targ, usefile, dg.libs)
 		src = std.htkeys(dg.sources)
 		mergeuse(dg, lib, src, targ.incpath)
 		archivelib(dg, lib, src, targ.incpath)
@@ -459,7 +460,7 @@
 	-> `std.None
 }
 
-const freshlibs = {targ, libgraph
+const freshlibs = {targ, output, libgraph
 	var libs
 
 	libs = std.htkeys(libgraph)
@@ -466,7 +467,7 @@
 	for l in libs
 		match findlib(l, targ.incpath)
 		| `std.Some lib:
-			if !isfresh(lib, targ.name)
+			if !isfresh(lib, output)
 				std.slfree(lib)
 				-> false
 			;;