ref: 38e821efbd3e37e5dd588bd78c9948bffec85582
parent: dbefa9ea41036f4ca1d2e6a0527572c52698a398
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Mar 10 08:28:35 EDT 2015
Allow durable attribute on gen files.
--- a/bldfile
+++ b/bldfile
@@ -16,5 +16,7 @@
util.myr
;;
+gen config.myr {durable} = ./configure ;;
+
man = mbld.1;;
--- a/clean.myr
+++ b/clean.myr
@@ -23,7 +23,7 @@
cleanup(p, tt, tt.inputs, true)
| `Gen gt:
for f in gt.out
- if std.remove(f)
+ if !gt.durable && std.remove(f)
std.put("\tclean %s\n", f)
;;
;;
--- a/opts.myr
+++ b/opts.myr
@@ -12,6 +12,7 @@
var opt_instroot : byte[:]
var opt_manpath : byte[:]
var opt_destdir : byte[:]
+ var opt_outdir : byte[:]
var opt_bldfile : byte[:]
var opt_debug : bool
--- a/parse.myr
+++ b/parse.myr
@@ -78,6 +78,8 @@
/* gentarget: wordlist = wordlist ;; */
const gentarget = {p
var outlist, cmdlist
+ var durable
+ var attrs
var gt
match wordlist(p)
@@ -87,6 +89,16 @@
;;
skipspace(p)
+ if matchc(p, '{')
+ match attrlist(p)
+ | `std.Some al: attrs = al
+ | `std.None: failparse(p, "invalid attr list for %s\n", outlist[0])
+ ;;
+ else
+ attrs = [][:]
+ ;;
+
+ skipspace(p)
if !matchc(p, '=')
failparse(p, "expected '=' after '%s %s'\n", cmdlist, outlist[outlist.len-1])
;;
@@ -101,7 +113,19 @@
failparse(p, "expected ';;' terminating genfile command, got %c\n", peekc(p))
;;
- gt = std.mk([.out = outlist, .cmd=cmdlist])
+ durable = false
+ for elt in attrs
+ match elt
+ | ("durable", ""): durable = true
+ | ("durable", val): failparse(p, "durable attr does not take argument\n")
+ ;;
+ ;;
+
+ gt = std.mk([
+ .out=outlist,
+ .durable=durable,
+ .cmd=cmdlist
+ ])
for o in outlist
std.htput(p.gensrc, o, gt)
;;
@@ -163,19 +187,18 @@
| ("ldscript", lds): ldscript = std.sldup(lds)
| ("runtime", rt): runtime = std.sldup(rt)
| ("inc", path): incpath = std.slpush(incpath, std.sldup(path))
- | ("noinst", val):
- if val.len != 0
- failparse(p, "noinst attr does not take argument\n")
- ;;
- inst = false
+ | ("noinst", ""): inst = false
+ | ("noinst", val): failparse(p, "noinst attr does not take argument\n")
| (invalid, _):
- std.fatal(1, "got invalid attr '%s'\n", invalid)
+ std.fatal(1, "%s: got invalid attr '%s'\n", targ, invalid)
;;
;;
-> std.mk([
+ /* target */
.name=name,
.inputs=inputs,
.libdeps=libdeps,
+ /* attrs */
.install=inst,
.ldscript=ldscript,
.runtime=runtime,
--- a/types.myr
+++ b/types.myr
@@ -42,6 +42,7 @@
type gentarg = struct
out : byte[:][:]
cmd : byte[:][:]
+ durable : bool
;;
type targ = union