summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure1
-rw-r--r--mbld/build.myr13
-rw-r--r--mbld/clean.myr10
-rw-r--r--mbld/config+plan9-x64.myr1
-rw-r--r--mbld/install.myr10
-rw-r--r--mbld/parse.myr87
-rw-r--r--mbld/types.myr14
7 files changed, 110 insertions, 26 deletions
diff --git a/configure b/configure
index 3fa1910..3e5892a 100755
--- a/configure
+++ b/configure
@@ -54,6 +54,7 @@ echo "const Directlib = false" >> mbld/config.myr
echo "const Runtime = \"_myrrt.o\"" >> mbld/config.myr
# paths to install to
echo "const Manpath = \"share/man/man\"" >> mbld/config.myr
+echo "const Sharepath = \"share\"" >> mbld/config.myr
echo "const Binpath = \"bin\"" >> mbld/config.myr
echo "const Libpath = \"lib/myr\"" >> mbld/config.myr
case $OS in
diff --git a/mbld/build.myr b/mbld/build.myr
index 64f01c9..ad633e1 100644
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -28,8 +28,9 @@ const buildall = {b
;;
| `Lib lt: buildlib(b, lt)
| `Gen gt: genfiles(b, gt)
- | `Man mt: /* nothing needed */
- | `Cmd ct: /* these are for manual commands or tests */
+ | `Data _: /* nothing needed */
+ | `Man _: /* nothing needed */
+ | `Cmd _: /* these are for manual commands or tests */
;;
;;
setdir(b, "")
@@ -56,8 +57,9 @@ const buildtarg = {b, targ
;;
| `Lib lt: buildlib(b, lt)
| `Gen gt: genfiles(b, gt)
- | `Man mt: /* nothing needed */
- | `Cmd ct: /* these are for manual commands or tests */
+ | `Data _: /* nothing needed */
+ | `Man _: /* nothing needed */
+ | `Cmd _: /* these are for manual commands or tests */
;;
;;
build(b, targ)
@@ -101,7 +103,8 @@ const build = {b, targ
| `std.Some (`Lib lt): buildlib(b, lt)
| `std.Some (`Gen gt): runin(b, gt.cmd, gt.dir)
| `std.Some (`Cmd ct): runin(b, ct.cmd, ct.dir)
- | `std.Some (`Man mt): /* nothing needed */
+ | `std.Some (`Data _): /* nothing needed */
+ | `std.Some (`Man _): /* nothing needed */
| `std.None: std.fatal("invalid target {}\n", targ)
;;
-> true
diff --git a/mbld/clean.myr b/mbld/clean.myr
index 0aa6c50..f60123a 100644
--- a/mbld/clean.myr
+++ b/mbld/clean.myr
@@ -26,8 +26,9 @@ const cleanall = {b
std.put("\tclean {}\n", f)
;;
;;
- | `Cmd ct: /* nothing to do */
- | `Man mt: /* nothing to do */
+ | `Data _: /* nothing to do */
+ | `Cmd _: /* nothing to do */
+ | `Man _: /* nothing to do */
;;
;;
-> true
@@ -50,8 +51,9 @@ const clean = {b, targ
std.put("\tclean {}\n", f)
;;
;;
- | `Cmd ct:
- | `Man mt:
+ | `Data _: /* nothing to do */
+ | `Cmd _: /* nothing to do */
+ | `Man _: /* nothing to do */
;;
;;
-> true
diff --git a/mbld/config+plan9-x64.myr b/mbld/config+plan9-x64.myr
index d6e56b0..1fef2ef 100644
--- a/mbld/config+plan9-x64.myr
+++ b/mbld/config+plan9-x64.myr
@@ -11,4 +11,5 @@ pkg config =
const Manpath = "sys/man/"
const Binpath = "amd64/bin"
const Libpath = "amd64/lib/myr"
+ const Sharepath = "lib"
;;
diff --git a/mbld/install.myr b/mbld/install.myr
index e8c368e..c5917e5 100644
--- a/mbld/install.myr
+++ b/mbld/install.myr
@@ -24,6 +24,7 @@ const uninstall = {b
const movetargs = {b, rm
var libarchive
+ var pfx
for tn in b.all
match gettarg(b.targs, tn)
@@ -38,6 +39,15 @@ const movetargs = {b, rm
movefile(b, rm, lt.dir, libarchive, config.Libpath, 0o644)
std.slfree(libarchive)
;;
+ | `Data dt:
+ for blob in dt.blobs
+ if dt.base.len == 0
+ pfx = config.Sharepath
+ else
+ pfx = dt.base
+ ;;
+ movefile(b, rm, dt.dir, blob, pfx, 0o644)
+ ;;
| `Gen gt:
/* nothing to do */
| `Cmd ct:
diff --git a/mbld/parse.myr b/mbld/parse.myr
index 8c02775..78f6fc3 100644
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -201,6 +201,7 @@ const target = {b, p
| `std.Some "test": testtarget(b, p)
| `std.Some "gen": cmdtarget(b, p, "gen", false)
| `std.Some "cmd": cmdtarget(b, p, "cmd", true)
+ | `std.Some "data": datatarget(b, p, "data")
| `std.Some "man": mantarget(b, p)
| `std.Some "sub": subtarget(b, p)
/* global attributes */
@@ -242,7 +243,7 @@ const expectword = {b, p, attr
const bintarget = {b, p
var t
t = myrtarget(b, p, "bin")
- addtarg(p, b, t.name, t.systags, `Bin t)
+ addtarg(p, b, t.name, t.tags, `Bin t)
}
/* libtarget: myrtarget */
@@ -250,7 +251,7 @@ const libtarget = {b, p
var t
t = myrtarget(b, p, "lib")
t.islib = true
- addtarg(p, b, t.name, t.systags, `Lib t)
+ addtarg(p, b, t.name, t.tags, `Lib t)
}
/* testtarget: myrtarget */
@@ -259,7 +260,7 @@ const testtarget = {b, p
t = myrtarget(b, p, "test")
t.istest = true
t.install = false
- addtarg(p, b, t.name, t.systags, `Bin t)
+ addtarg(p, b, t.name, t.tags, `Bin t)
}
/* mantarget: anontarget */
@@ -285,7 +286,7 @@ const subtarget = {b, p
/* gentarget: wordlist {attrs} = wordlist ;; */
const cmdtarget = {b, p, cmd, iscmd
- var outlist, deplist, cmdlist, systags
+ var outlist, deplist, cmdlist, tags
var durable, istest
var attrs
var gt
@@ -327,14 +328,14 @@ const cmdtarget = {b, p, cmd, iscmd
durable = false
istest = false
deplist = [][:]
- systags = [][:]
+ tags = [][:]
for elt in attrs
match elt
| ("durable", ""): durable = true
| ("test", ""): istest = true
| ("notest", ""): istest = false
| ("dep", depname): deplist = std.slpush(deplist, depname)
- | ("tag", tag): systags = std.slpush(systags, tag)
+ | ("tag", tag): tags = std.slpush(tags, tag)
| (attr, ""):
failparse(p, "attribute {} not valid on {} targets\n", attr, cmd)
| (attr, val):
@@ -349,14 +350,14 @@ const cmdtarget = {b, p, cmd, iscmd
.istest=istest,
.deps=deplist,
.cmd=cmdlist,
- .systags=systags,
+ .tags=tags,
])
for o in outlist
if iscmd
- addtarg(p, b, o, gt.systags, `Cmd gt)
+ addtarg(p, b, o, gt.tags, `Cmd gt)
else
std.htput(b.gensrc, o, gt)
- addtarg(p, b, o, gt.systags, `Gen gt)
+ addtarg(p, b, o, gt.tags, `Gen gt)
;;
;;
}
@@ -366,7 +367,7 @@ myrtarget: name '=' inputlist ';;'
| name attrlist = inputlist ';;'
*/
const myrtarget = {b, p, targ
- var ldscript, runtime, install, incpath, systags
+ var ldscript, runtime, install, incpath, tags
var name, inputs, libdeps, attrs
var istest
var fsel
@@ -416,13 +417,13 @@ const myrtarget = {b, p, targ
for path in p.incpath
incpath = std.slpush(incpath, path)
;;
- systags = [][:]
+ tags = [][:]
for elt in attrs
match elt
| ("ldscript", lds): ldscript = std.sldup(lds)
| ("runtime", rt): runtime = std.sldup(rt)
| ("inc", path): incpath = std.slpush(incpath, std.sldup(path))
- | ("tag", tag): systags = std.slpush(systags, tag)
+ | ("tag", tag): tags = std.slpush(tags, tag)
| ("inst", ""): install = true
| ("noinst", ""): install = false
| ("test", ""): istest = true
@@ -445,7 +446,7 @@ const myrtarget = {b, p, targ
.islib=false,
.istest=istest,
/* attrs */
- .systags=systags,
+ .tags=tags,
.install=install,
.ldscript=ldscript,
.runtime=runtime,
@@ -453,6 +454,62 @@ const myrtarget = {b, p, targ
])
}
+const datatarget = {b, p, targ
+ var name, attrs, blobs
+ var tags, base
+
+ match word(p)
+ | `std.Some n: name = n
+ | `std.None: failparse(p, "expected target name after '{}'\n", targ)
+ ;;
+
+ skipspace(p)
+ if matchc(p, '{')
+ match attrlist(p)
+ | `std.Some al: attrs = al
+ | `std.None: failparse(p, "invalid attr list for {} {}\n", targ, name)
+ ;;
+ else
+ attrs = [][:]
+ ;;
+
+ skipspace(p)
+ if !matchc(p, '=')
+ failparse(p, "expected '=' after '{} {}'\n", targ, name)
+ ;;
+
+ match wordlist(p)
+ | `std.Some wl:
+ blobs = wl
+ | `std.None: failparse(p, "expected list of file names after '{} {}'\n", targ, name)
+ ;;
+
+ skipspace(p)
+ if !matchc(p, ';') || !matchc(p, ';')
+ failparse(p, "expected ';;' terminating input list, got {}\n", peekc(p))
+ ;;
+
+ tags = [][:]
+ for elt in attrs
+ match elt
+ | ("tag", tag): tags = std.slpush(tags, tag)
+ | ("base", basedir): base = basedir
+ | (invalid, ""):
+ std.fatal("{}: got invalid attr '{}'\n", targ, invalid)
+ | (invalid, attr):
+ std.fatal("{}: got invalid attr '{} = {}'\n", targ, invalid, attr)
+ ;;
+ ;;
+
+ addtarg(p, b, name, tags, `Data std.mk([
+ .dir=std.sldup(p.fdir),
+ .name=name,
+ .tags=tags,
+ .base=base,
+ .blobs=blobs,
+ ]))
+}
+
/* anontarget: '=' wordlist ';;' */
const anontarget = {p, targ
var inputs
@@ -671,11 +728,11 @@ const getc = {p
-> c
}
-const addtarg = {p, b, name, systags, targ
+const addtarg = {p, b, name, tags, targ
var tn
tn = std.fmt("{}:{}", p.fdir, name)
- sysseladdlist(p.targsel, tn, systags, (tn, targ))
+ sysseladdlist(p.targsel, tn, tags, (tn, targ))
}
const libpath = {p, libpath
diff --git a/mbld/types.myr b/mbld/types.myr
index b4f9e7a..545eb36 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -25,6 +25,7 @@ pkg bld =
`Gen cmdtarg#
`Cmd cmdtarg#
`Man mantarg#
+ `Data datatarg#
;;
type myrtarg = struct
@@ -40,7 +41,7 @@ pkg bld =
install : bool
runtime : byte[:]
incpath : byte[:][:]
- systags : byte[:][:]
+ tags : byte[:][:]
ldscript : byte[:]
;;
@@ -49,7 +50,7 @@ pkg bld =
out : byte[:][:]
cmd : byte[:][:]
deps : byte[:][:]
- systags : byte[:][:]
+ tags : byte[:][:]
durable : bool
/* we can have multiple outputs, but we only want to run once for each */
done : bool
@@ -58,9 +59,18 @@ pkg bld =
type mantarg = struct
dir : byte[:]
+ tags : byte[:][:]
pages : byte[:][:]
;;
+ type datatarg = struct
+ dir : byte[:]
+ name : byte[:]
+ tags : byte[:][:]
+ base : byte[:]
+ blobs : byte[:][:]
+ ;;
+
type depgraph = struct
deps : std.htab(byte[:], byte[:][:])#
libs : std.htab(byte[:], byte[:][:])#