shithub: mc

Download patch

ref: c04458301871d82ebe0e0e7bc8fa8b11d917f84b
parent: 34aa8c1dd116b9148c469c992ee7f21d39d99c3c
author: Ori Bernstein <ori@eigenstate.org>
date: Thu May 10 16:44:34 EDT 2018

Rebuild if the toolchain was updated.

--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -126,6 +126,7 @@
 	var staletime
 
 	staletime = n.deptime
+	staletime = std.max(staletime, b.tctime)
 	for d : n.ndep
 		staletime = std.max(staletime, d.mtime)
 	;;
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -651,3 +651,4 @@
 	std.slpush(&g.nodes, nod)
 	-> nod
 }
+
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -152,9 +152,42 @@
 		.leaves = [][:],
 		.nodes = [][:],
 	])
+	b.tctime = tctime()
 	bld.addsysattrs(b, tags)
 	-> b
 }
+
+const tctime = {
+	var path : byte[1024]
+	var tm
+
+	tm = 0
+	for bin : [bld.opt_muse, bld.opt_mc][:]
+		match which(path[:], bin)
+		| `std.None:
+		| `std.Some p:
+			match std.fmtime(p)
+			| `std.Ok t:	tm = std.max(tm, t)
+			| `std.Err e:	tm = std.now()
+			;;
+		;;
+	;;
+	-> tm
+}
+
+const which = {buf, name
+	var path, f
+
+	path = std.getenvv("PATH", "/bin")
+	for p : std.bysplit(path, ":")
+		f = std.bfmt(buf, "{}/{}", p, name)
+		if std.fexists(f)
+			-> `std.Some f
+		;;
+	;;
+	-> `std.None
+}
+
 
 const findproj = {b
 	var dir
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -7,6 +7,7 @@
 		tags	: std.htab(byte[:], (int, int, int))#
 		libs	: std.htab(byte[:], libdep#)#
 		deps	: depgraph#
+		tctime	: std.time	/* time the toolchain was updated */
 
 		/* in flight builds */
 		queue	: node#[:]