ref: 3a496c143eb8aad32c03c7067c54807256949c97
dir: /mbld/clean.myr/
use std use "config.use" use "deps.use" use "opts.use" use "parse.use" use "types.use" use "util.use" pkg bld = const cleanall : (b : build# -> bool) const clean : (b : build#, targ : byte[:] -> bool) const cleanmyr : (b : build#, mt : myrtarg# -> void) ;; const cleanall = {b for tn in b.all match gettarg(b.targs, tn) | `Bin bt: cleanup(b, bt, bt.inputs) | `Lib lt: cleanup(b, lt, lt.inputs) | `Gen gt: for f in gt.out if !gt.durable && std.remove(f) std.put("\tclean {}\n", f) ;; ;; | `Data _: /* nothing to do */ | `Cmd _: /* nothing to do */ | `Man _: /* nothing to do */ ;; ;; -> true } const clean = {b, targ for tn in b.all match gettarg(b.targs, tn) | `Bin bt: if std.sleq(bt.name, targ) cleanup(b, bt, bt.inputs) ;; | `Lib lt: if std.sleq(lt.name, targ) cleanup(b, lt, lt.inputs) ;; | `Gen gt: for f in gt.out if !gt.durable && std.remove(f) std.put("\tclean {}\n", f) ;; ;; | `Data _: /* nothing to do */ | `Cmd _: /* nothing to do */ | `Man _: /* nothing to do */ ;; ;; -> true } const cleanmyr = {b, targ cleanup(b, targ, targ.inputs) } const cleanup = {b, targ, leaves var mchammer_files /* cant touch this */ var keys, dg /* we want to automatically add 'clean' sources since otherwise, mbld won't be able to clean code after changing a build file. */ setdir(b, targ.dir) dg = myrdeps(b, targ, true, true) 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) && std.remove(k) std.put("\tclean {}\n", k) ;; ;; }