ref: 5f46919fc6a471d9a75bb25fae64aecefc9ec864
parent: e11b9bf807b4579823305419db7c7682e4f7a1d5
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Dec 28 12:49:30 EST 2015
Add 'cleanfirst' option.
--- a/mbld/clean.myr
+++ b/mbld/clean.myr
@@ -10,6 +10,7 @@
pkg bld =
const cleanall : (b : build# -> bool)
const clean : (b : build#, targ : byte[:] -> bool)
+ const cleanmyr : (b : build#, mt : myrtarg# -> void)
;;
const cleanall = {b
@@ -54,6 +55,10 @@
;;
;;
-> true
+}
+
+const cleanmyr = {b, targ
+ cleanup(b, targ, targ.inputs)
}
const cleanup = {b, targ, leaves
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -16,6 +16,7 @@
const main = {args : byte[:][:]
var b : bld.build#
var mt : bld.myrtarg
+ var cleanfirst
var dumponly
var targname
var bintarg
@@ -23,9 +24,11 @@
var tags
dumponly = false
+ cleanfirst = false
cmd = std.optparse(args, &[
.argdesc = "[inputs...]",
.opts = [
+ [.opt='c', .desc="clean before building"],
[.opt='T', .desc="list all available targets"],
[.opt='t', .arg="tag", .desc="build with specified systag"],
[.opt='S', .desc="generate assembly when building"],
@@ -47,6 +50,7 @@
match opt
| ('T', ""): dumponly = true
| ('S', ""): bld.opt_genasm = true
+ | ('c', ""): cleanfirst = true
| ('I', arg): bld.opt_incpaths = std.slpush(bld.opt_incpaths, arg)
| ('R', arg): bld.opt_instroot = arg
| ('t', tag): tags = std.slpush(tags, tag)
@@ -83,6 +87,9 @@
.incpath=bld.opt_incpaths,
.libdeps=[][:]
]
+ if cleanfirst
+ bld.cleanmyr(b, &mt)
+ ;;
if bintarg
bld.buildbin(b, &mt, true)
else
@@ -99,6 +106,9 @@
bld.load(b)
/*bld.configure()*/
/* default: buildall */
+ if cleanfirst
+ bld.cleanall(b)
+ ;;
if cmd.args.len == 0
bld.buildall(b)
else