summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-05-10 20:44:34 -0700
committerOri Bernstein <ori@eigenstate.org>2018-05-10 20:44:34 -0700
commitc04458301871d82ebe0e0e7bc8fa8b11d917f84b (patch)
treee97dfd8840e7325ada71d35fc59a1e901b22e16c
parent34aa8c1dd116b9148c469c992ee7f21d39d99c3c (diff)
downloadmc-c04458301871d82ebe0e0e7bc8fa8b11d917f84b.tar.gz
Rebuild if the toolchain was updated.
-rw-r--r--mbld/build.myr1
-rw-r--r--mbld/deps.myr1
-rw-r--r--mbld/main.myr33
-rw-r--r--mbld/types.myr1
4 files changed, 36 insertions, 0 deletions
diff --git a/mbld/build.myr b/mbld/build.myr
index 7dfec99..0725aa2 100644
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -126,6 +126,7 @@ const stale = {b, n
var staletime
staletime = n.deptime
+ staletime = std.max(staletime, b.tctime)
for d : n.ndep
staletime = std.max(staletime, d.mtime)
;;
diff --git a/mbld/deps.myr b/mbld/deps.myr
index 53b5a8f..b2ad492 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -651,3 +651,4 @@ const node = {g, lbl
std.slpush(&g.nodes, nod)
-> nod
}
+
diff --git a/mbld/main.myr b/mbld/main.myr
index 3ca9b07..d54eb4f 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -152,10 +152,43 @@ const mkbuild = {tags
.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
diff --git a/mbld/types.myr b/mbld/types.myr
index 03bb151..4e6901e 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -7,6 +7,7 @@ pkg bld =
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#[:]