ref: b769b88bbc3e0ddcef7991e73b2582d472f08d89
parent: d6882e116c61b3ec3a79c29ceabbafe36196235f
author: Ori Bernstein <[email protected]>
date: Sat May 2 20:20:34 EDT 2015
Add support for 'cmd' args.
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -26,7 +26,8 @@
| `Lib lt: buildlib(b, lt)
| `Test tt: /* build on 'mbld test' by default */
| `Gen gt: genfiles(b, gt)
- | `Man m: /* nothing needed */
+ | `Man mt: /* nothing needed */
+ | `Cmd ct: /* these are for manual commands */
;;
;;
-> true
@@ -49,7 +50,8 @@
| `std.Some (`Lib lt): buildlib(b, lt)
| `std.Some (`Test tt): buildbin(b, tt, false)
| `std.Some (`Gen gt): run(gt.cmd)
- | `std.Some (`Man m): /* nothing needed */
+ | `std.Some (`Cmd ct): run(ct.cmd)
+ | `std.Some (`Man mt): /* nothing needed */
| `std.None: std.fatal(1, "invalid target %s\n", targ)
;;
-> true
--- a/mbld/clean.myr
+++ b/mbld/clean.myr
@@ -27,7 +27,8 @@
std.put("\tclean %s\n", f)
;;
;;
- | `Man m:
+ | `Cmd ct: /* nothing to do */
+ | `Man mt: /* nothing to do */
;;
;;
-> true
@@ -54,7 +55,8 @@
std.put("\tclean %s\n", f)
;;
;;
- | `Man m:
+ | `Cmd ct:
+ | `Man mt:
;;
;;
-> true
--- a/mbld/install.myr
+++ b/mbld/install.myr
@@ -35,7 +35,9 @@
movefile(b, delete, lt.dir, libarchive, opt_instroot, opt_destdir, "lib/myr", 0o644)
std.slfree(libarchive)
| `Gen gt:
- /* nothing to do (?) */
+ /* nothing to do */
+ | `Cmd ct:
+ /* nothing to do */
| `Man mt:
/* FIXME: figure out man section by number */
for m in mt.pages
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -169,7 +169,8 @@
| `std.Some "bin": bintarget(b, p)
| `std.Some "test": testtarget(b, p)
| `std.Some "lib": libtarget(b, p)
- | `std.Some "gen": gentarget(b, p)
+ | `std.Some "gen": cmdtarget(b, p, false)
+ | `std.Some "cmd": cmdtarget(b, p, true)
| `std.Some "man": mantarget(b, p)
| `std.Some "sub": subtarget(b, p)
| `std.Some targtype: failparse(p, "unknown targtype type %s\n", targtype)
@@ -221,9 +222,8 @@
;;
}
-
/* gentarget: wordlist {attrs} = wordlist ;; */
-const gentarget = {b, p
+const cmdtarget = {b, p, isgen
var outlist, deplist, cmdlist
var durable
var attrs
@@ -232,11 +232,14 @@
match wordlist(p)
| `std.None: failparse(p, "gen target missing output files\n")
| `std.Some out:
+ if isgen && out.len != 1
+ failparse(p, "gen target takes one name\n")
+ ;;
outlist = out
;;
skipspace(p)
- if matchc(p, '{')
+ if !isgen && matchc(p, '{')
match attrlist(p)
| `std.Some al: attrs = al
| `std.None: failparse(p, "invalid attr list for %s\n", outlist[0])
@@ -251,7 +254,7 @@
;;
match wordlist(p)
- | `std.None: failparse(p, "gen target missing command\n")
+ | `std.None: failparse(p, "target missing command\n")
| `std.Some cmd:
cmdlist = cmd
;;
@@ -278,9 +281,11 @@
.deps=deplist,
.cmd=cmdlist
])
- for o in outlist
- std.htput(b.gensrc, o, gt)
- addtarg(p, b, o, `Gen gt)
+ if !isgen
+ for o in outlist
+ std.htput(b.gensrc, o, gt)
+ addtarg(p, b, o, `Gen gt)
+ ;;
;;
}
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -12,7 +12,7 @@
all : byte[:][:] /* all targets, in reverse topological order */
targs : std.htab(byte[:], targ)# /* dir => target mapping */
tdeps : std.htab(byte[:], byte[:][:]) /* targname => depname[:] mapping */
- gensrc : std.htab(byte[:], gentarg#)# /* generated src => generating target mapping */
+ gensrc : std.htab(byte[:], cmdtarg#)# /* generated src => generating target mapping */
prefix : byte[:]
system : byte[:]
arch : byte[:]
@@ -22,7 +22,8 @@
`Bin myrtarg#
`Lib myrtarg#
`Test myrtarg#
- `Gen gentarg#
+ `Gen cmdtarg#
+ `Cmd cmdtarg#
`Man mantarg#
;;
@@ -38,7 +39,7 @@
ldscript : byte[:]
;;
- type gentarg = struct
+ type cmdtarg = struct
dir : byte[:]
out : byte[:][:]
cmd : byte[:][:]