ref: f2cd39cd142e19a1ac47be058c259f799a14f9ef
parent: 2db38b46d3d206c951e305ccb24e07d6e6e9cd6a
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Sep 28 15:06:47 EDT 2014
Add output -> src mapping. Right now, 1:1.
--- a/build.myr
+++ b/build.myr
@@ -77,7 +77,7 @@
| `std.Some deps:
built = false
for d in deps
- if builddep(&dg, d, bin)
+ if builddep(&dg, d)
built = true
;;
;;
@@ -101,7 +101,7 @@
| `std.Some deps:
built = false
for d in deps
- if builddep(&dg, d, lib)
+ if builddep(&dg, d)
built = true
;;
;;
@@ -114,39 +114,45 @@
;;
}
-const builddep = {dg, dep, out
- -> builddep_(dg, dep, out, 0)
-}
+const builddep = {dg, out
+ var stale
-const builddep_ = {dg, src, out, indent
- var staledep
- var stalesrc
-
- staledep = false
- stalesrc = !isfresh(src, out)
- if stalesrc
- std.put("%s -> %s was stale\n", src, out)
- ;;
- match std.htget(dg.deps, src)
+ std.put("Target: %s:", out)
+ stale = false
+ match std.htget(dg.deps, out)
| `std.Some deps:
for d in deps
- if builddep_(dg, d, out, indent + 1)
- staledep = true
+ std.put("%s ", d)
+ ;;
+ std.put("\n")
+ for d in deps
+ if builddep(dg, d) || !isfresh(d, out)
+ if !isfresh(d, out)
+ std.put("\t\tstale: %s->%s\n", d, out)
+ ;;
+ stale = true
;;
;;
| `std.None:
+ std.put("\n")
;;
- if (staledep || stalesrc) && std.hassuffix(src, ".myr")
- if std.htgetv(dg.built, src, false)
- std.put("fresh (%s, %s): staledeps:%t, stalesrc:%t\n", \
- src, out, staledep, stalesrc)
- std.die("Double built!\n")
+ if stale
+ match std.htget(dg.sources, out)
+ | `std.Some src:
+ if std.hassuffix(src, ".myr")
+ run(["6m", src][:], "")
+ elif std.hassuffix(src, ".myr")
+ run(["as", src][:], "")
+ else
+ std.fatal(1, "Unknown file type for %s\n", src)
+ ;;
+ std.htput(dg.updated, src, true)
+ | `std.None:
+ std.fatal(1, "No source for %s\n", out)
;;
- run(["6m", src][:], "")
- std.htput(dg.built, src, true)
;;
- -> staledep || stalesrc
+ -> stale
}
const linkbin = {dg, bin, srcfiles, ldscript, rt
--- a/clean.myr
+++ b/clean.myr
@@ -50,6 +50,7 @@
var mchammer_files /* cant touch this */
var keys
var dg
+ var sb
if !myrdeps(&dg, out, leaves, islib)
std.fatal(1, "Could not load dependencies for %s\n", out)
@@ -61,7 +62,7 @@
keys = std.htkeys(dg.deps)
for k in keys
- if !std.htgetv(mchammer_files, k, false)
+ if !std.htgetv(mchammer_files, k, false) && std.stat(k, &sb) == 0
std.put("\tclean %s\n", k)
std.unlink(k)
;;
--- a/types.myr
+++ b/types.myr
@@ -20,6 +20,7 @@
roots : byte[:][:]
deps : std.htab(byte[:], byte[:][:])#
libs : std.htab(byte[:], byte[:][:])#
+ sources : std.htab(byte[:], byte[:])#
updated : std.htab(byte[:], bool)#
;;