summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.myr10
-rw-r--r--clean.myr4
-rw-r--r--deps.myr20
-rw-r--r--install.myr4
-rw-r--r--main.myr46
-rw-r--r--parse.myr20
-rw-r--r--subdir.myr2
-rw-r--r--test.myr2
-rw-r--r--types.myr2
9 files changed, 53 insertions, 57 deletions
diff --git a/build.myr b/build.myr
index d3cb10b..7090671 100644
--- a/build.myr
+++ b/build.myr
@@ -9,11 +9,11 @@ use "util.use"
use "subdir.use"
pkg bld =
- const buildall : (p : parser# -> bool)
- const genall : (p : parser# -> bool)
- const build : (p : parser#, target : byte[:] -> bool)
- const buildbin : (p : parser#, bt : myrtarg#, addsrc : bool -> void)
- const buildlib : (p : parser#, lt : myrtarg# -> void)
+ const buildall : (p : build# -> bool)
+ const genall : (p : build# -> bool)
+ const build : (p : build#, target : byte[:] -> bool)
+ const buildbin : (p : build#, bt : myrtarg#, addsrc : bool -> void)
+ const buildlib : (p : build#, lt : myrtarg# -> void)
;;
const buildall = {p
diff --git a/clean.myr b/clean.myr
index 60ecf57..acb3fef 100644
--- a/clean.myr
+++ b/clean.myr
@@ -8,8 +8,8 @@ use "subdir.use"
use "types.use"
pkg bld =
- const cleanall : (p : parser# -> bool)
- const clean : (p : parser#, targ : byte[:] -> bool)
+ const cleanall : (p : build# -> bool)
+ const clean : (p : build#, targ : byte[:] -> bool)
;;
const cleanall = {p
diff --git a/deps.myr b/deps.myr
index 6cd120d..0303913 100644
--- a/deps.myr
+++ b/deps.myr
@@ -8,7 +8,7 @@ use "types.use"
use "util.use"
pkg bld =
- const myrdeps : (p : parser#, mt : myrtarg#, islib : bool, isclean : bool, addsrc : bool, dg : depgraph# -> bool)
+ const myrdeps : (b : build#, mt : myrtarg#, islib : bool, isclean : bool, addsrc : bool, dg : depgraph# -> bool)
/* a bit ugly: initialized from main() */
var usepat : regex.regex#
@@ -21,7 +21,7 @@ type dep = union
`Lib byte[:]
;;
-const myrdeps = {p, mt, islib, isclean, addsrc, dg
+const myrdeps = {b, mt, islib, isclean, addsrc, dg
var objs, uses, srcs, incs
var out, useout, depstk
var i
@@ -66,7 +66,7 @@ const myrdeps = {p, mt, islib, isclean, addsrc, dg
for i = 0; i < srcs.len; i++
depstk = [][:]
- srcdeps(p, dg, srcs[i], objs[i], uses[i], incs, &depstk, isclean, addsrc)
+ srcdeps(b, dg, srcs[i], objs[i], uses[i], incs, &depstk, isclean, addsrc)
std.slfree(depstk)
;;
dumpgraph(dg)
@@ -99,7 +99,7 @@ const dumpgraph = {dg
std.put("}\n")
}
-const srcdeps = {p, g, path, obj, usefile, incs, depstk, isclean, addsrc
+const srcdeps = {b, g, path, obj, usefile, incs, depstk, isclean, addsrc
var deps
if std.hthas(g.done, path)
@@ -114,7 +114,7 @@ const srcdeps = {p, g, path, obj, usefile, incs, depstk, isclean, addsrc
;;
std.exit(1)
;;
- deps = getdeps(p, path)
+ deps = getdeps(b, path)
std.htput(g.seen, path, true)
for d in deps
match d
@@ -136,7 +136,7 @@ const srcdeps = {p, g, path, obj, usefile, incs, depstk, isclean, addsrc
if usefile.len != 0
pushdep(g, l, usefile)
;;
- addusedep(p, g, path, l, incs, depstk, isclean, addsrc)
+ addusedep(b, g, path, l, incs, depstk, isclean, addsrc)
;;
;;
depstk# = std.slgrow(depstk#, depstk#.len - 1)
@@ -144,7 +144,7 @@ const srcdeps = {p, g, path, obj, usefile, incs, depstk, isclean, addsrc
std.htput(g.done, path, true)
}
-const addusedep = {p, g, f, usefile, incs, depstk, isclean, addsrc
+const addusedep = {b, g, f, usefile, incs, depstk, isclean, addsrc
var src
if std.hthas(g.done, usefile)
@@ -166,17 +166,17 @@ const addusedep = {p, g, f, usefile, incs, depstk, isclean, addsrc
;;
pushdep(g, src, usefile)
std.htput(g.input, usefile, src)
- srcdeps(p, g, src, "", usefile, incs, depstk, isclean, addsrc)
+ srcdeps(b, g, src, "", usefile, incs, depstk, isclean, addsrc)
std.htput(g.done, usefile, true)
}
-const getdeps = {p, path
+const getdeps = {b, path
var f
var deps : dep[:]
deps = [][:]
if !std.fexists(path)
- match std.htget(p.gensrc, path)
+ match std.htget(b.gensrc, path)
| `std.Some gt: run(gt.cmd, "")
| `std.None: std.fatal(1, "no input file %s\n", path)
;;
diff --git a/install.myr b/install.myr
index 764bb09..6af3d1c 100644
--- a/install.myr
+++ b/install.myr
@@ -10,8 +10,8 @@ use "util.use"
use "build.use"
pkg bld =
- const install : (p : parser# -> bool)
- const uninstall : (p : parser# -> bool)
+ const install : (p : build# -> bool)
+ const uninstall : (p : build# -> bool)
;;
const install = {p
diff --git a/main.myr b/main.myr
index efe1f4b..38e5290 100644
--- a/main.myr
+++ b/main.myr
@@ -12,7 +12,7 @@ use "test.use"
use "types.use"
const main = {args : byte[:][:]
- var p : bld.parser#
+ var b : bld.build#
var mt : bld.myrtarg
var targname
var bintarg
@@ -65,51 +65,37 @@ const main = {args : byte[:][:]
.ldscript=bld.opt_ldscript,
.libdeps=[][:]
]
- p = mkparser("cli")
+ b = mkbuild("cli")
if bintarg
- bld.buildbin(p, &mt, true)
+ bld.buildbin(b, &mt, true)
else
- bld.buildlib(p, &mt)
+ bld.buildlib(b, &mt)
;;
- std.free(p)
+ std.free(b)
else
- p = loadbuild(bld.opt_bldfile)
- p.cmd = args
+ b = mkbuild(bld.opt_bldfile)
+ bld.load(b, bld.opt_bldfile)
/*bld.configure()*/
/* default: buildall */
if optctx.args.len == 0
- bld.buildall(p)
+ bld.buildall(b)
else
for cmd in optctx.args
match cmd
- | "all": bld.buildall(p)
- | "gen": bld.genall(p)
- | "clean": bld.cleanall(p)
- | "install": bld.install(p)
- | "uninstall": bld.uninstall(p)
- | "test": bld.test(p)
- | target: bld.build(p, target)
+ | "all": bld.buildall(b)
+ | "gen": bld.genall(b)
+ | "clean": bld.cleanall(b)
+ | "install": bld.install(b)
+ | "uninstall": bld.uninstall(b)
+ | "test": bld.test(b)
+ | target: bld.build(b, target)
;;
;;
;;
;;
}
-const loadbuild = {path
- var p
-
- p = mkparser(path)
- match std.slurp(path)
- | `std.Ok d: p.data = d
- | `std.Fail _: std.fatal(1, "could not open file 'bldfile'\n")
- ;;
- p.rest = p.data
- bld.parse(p)
-
- -> p
-}
-
-const mkparser = {path
+const mkbuild = {path
var p
p = std.zalloc()
diff --git a/parse.myr b/parse.myr
index acbbe1e..06a8e79 100644
--- a/parse.myr
+++ b/parse.myr
@@ -6,10 +6,20 @@ use "opts.use"
use "fsel.use"
pkg bld =
- const parse : (p : parser# -> bool)
+ const load : (b : build#, path : byte[:] -> bool)
;;
-const failparse = {p : parser#, msg, args : ...
+const load = {b, path
+ match std.slurp(path)
+ | `std.Ok d: b.data = d
+ | `std.Fail _: std.fatal(1, "could not open file 'bldfile'\n")
+ ;;
+ b.rest = b.data
+ -> bld.parse(b)
+}
+
+
+const failparse = {p, msg, args : ...
var buf : byte[1024]
var ap
var sl
@@ -36,7 +46,7 @@ const parse = {p
;;
}
-const target = {p : parser#
+const target = {p
match word(p)
| `std.Some "bin": bintarget(p)
| `std.Some "test": testtarget(p)
@@ -320,7 +330,7 @@ const wordlist = {p
}
/* word: /wordchar*/
-const word = {p : parser#
+const word = {p
var c, n
var start
@@ -371,7 +381,7 @@ const wordchar = {c
c == '+'
}
-const skipspace = {p : parser#
+const skipspace = {p
var c, r
r = p.rest
diff --git a/subdir.myr b/subdir.myr
index 6196269..210064c 100644
--- a/subdir.myr
+++ b/subdir.myr
@@ -4,7 +4,7 @@ use "types.use"
use "util.use"
pkg bld =
- const subdirs : (p : parser#, subs : byte[:][:], targ : std.option(byte[:]) -> void)
+ const subdirs : (p : build#, subs : byte[:][:], targ : std.option(byte[:]) -> void)
;;
const subdirs = {p, subs, targ
diff --git a/test.myr b/test.myr
index e8ac4e4..5dd6651 100644
--- a/test.myr
+++ b/test.myr
@@ -12,7 +12,7 @@ use "subdir.use"
use "config.use"
pkg bld =
- const test : (p : parser# -> void)
+ const test : (p : build# -> void)
;;
const test = {p
diff --git a/types.myr b/types.myr
index 6928fd1..ec72aae 100644
--- a/types.myr
+++ b/types.myr
@@ -1,7 +1,7 @@
use std
pkg bld =
- type parser = struct
+ type build = struct
cmd : byte[:][:]
/* parse input */
data : byte[:]