ref: 6bc97a3d153ba5bb77dc67c2cf7eb495ff277855
dir: /clean.myr/
use std use sys use "config.use" use "deps.use" use "opts.use" use "parse.use" use "subdir.use" use "types.use" pkg bld = const cleanall : (p : parser# -> bool) const clean : (p : parser#, targ : byte[:] -> bool) ;; const cleanall = {p for t in p.targs match t | `Bin [.name=bin, .inputs=leaves]: cleanup(bin, leaves, true) | `Lib [.name=lib, .inputs=leaves]: cleanup(lib, leaves, true) | `Sub subs: subdirs(p, subs, `std.None) | `Man m: ;; ;; -> true } const clean = {p, targ for t in p.targs match t | `Bin [.name=bin, .inputs=leaves]: if std.sleq(bin, targ) cleanup(bin, leaves, true) ;; | `Lib [.name=lib, .inputs=leaves]: if std.sleq(lib, targ) cleanup(lib, leaves, true) ;; | `Sub subs: subdirs(p, subs, `std.Some targ) | `Man m: ;; ;; -> true } const cleanup = {out, leaves, islib 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) ;; mchammer_files = std.mkht(std.strhash, std.streq) for l in leaves std.htput(mchammer_files, l, true) ;; keys = std.htkeys(dg.deps) for k in keys if !std.htgetv(mchammer_files, k, false) && sys.stat(k, &sb) == 0 std.put("\tclean %s\n", k) std.unlink(k) ;; ;; }