summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-04-13 01:23:15 -0700
committerOri Bernstein <ori@eigenstate.org>2015-04-13 01:23:15 -0700
commit2f5a88d9b79271f78ec71cf7f796ca5fb74de89e (patch)
tree47423dca71303b3d4baa43c66307e5760d275271
parentb612c54208eb92725f85f2521ba1a4be58fc7f44 (diff)
downloadmbld-2f5a88d9b79271f78ec71cf7f796ca5fb74de89e.tar.gz
Clean up some debug mess.
-rw-r--r--build.myr53
-rw-r--r--clean.myr4
-rw-r--r--install.myr2
-rw-r--r--main.myr4
-rw-r--r--parse.myr17
-rw-r--r--test.myr2
-rw-r--r--types.myr3
-rw-r--r--util.myr17
8 files changed, 60 insertions, 42 deletions
diff --git a/build.myr b/build.myr
index 2fa7725..74768db 100644
--- a/build.myr
+++ b/build.myr
@@ -17,7 +17,7 @@ pkg bld =
const buildall = {b
for tn in b.all
- match gettarg(b._targs, tn)
+ match gettarg(b.targs, tn)
| `Bin bt: buildbin(b, bt, false)
| `Lib lt: buildlib(b, lt)
| `Test tt: /* build on 'mbld test' by default */
@@ -30,7 +30,7 @@ const buildall = {b
const genall = {b
for tn in b.all
- match gettarg(b._targs, tn)
+ match gettarg(b.targs, tn)
| `Gen gt: run(gt.cmd)
| _: /* skip */
;;
@@ -40,7 +40,7 @@ const genall = {b
}
const build = {b, targ
- match std.htget(b._targs, targ)
+ match std.htget(b.targs, targ)
| `std.Some (`Bin bt): buildbin(b, bt, false)
| `std.Some (`Lib lt): buildlib(b, lt)
| `std.Some (`Test tt): buildbin(b, tt, false)
@@ -58,14 +58,8 @@ const buildbin = {b, targ, addsrc
->
;;
setdir(b, targ.dir)
- if targ.libdeps.len > 0
- for (inc, lib, subtarg) in targ.libdeps
- if !hasinc(targ.incpath, inc)
- targ.incpath = std.slpush(targ.incpath, inc)
- ;;
- build(b, subtarg)
- ;;
- ;;
+ addincludes(b, targ)
+ buildlibdeps(b, targ)
std.put("%s...\n", targ.name)
if !myrdeps(b, targ, false, false, addsrc, &dg)
std.fatal(1, "Could not load dependencies for %s\n", targ.name)
@@ -81,15 +75,6 @@ const buildbin = {b, targ, addsrc
targ.built = true
}
-const hasinc = {path, t
- for e in path
- if std.sleq(e, t)
- -> true
- ;;
- ;;
- -> false
-}
-
const buildlib = {b, targ
var archive
var u, l
@@ -100,6 +85,8 @@ const buildlib = {b, targ
->
;;
setdir(b, targ.dir)
+ addincludes(b, targ)
+ buildlibdeps(b, targ)
lib = targ.name
std.put("lib%s.a...\n", lib)
archive = std.fmt("lib%s.a", lib)
@@ -125,11 +112,35 @@ const genfiles = {b, gt
for f in gt.out
if !std.fexists(f)
run(gt.cmd)
- ->
+ break
;;
;;
}
+const addincludes = {b, targ
+ for (inc, lib, subtarg) in targ.libdeps
+ if !hasinc(targ.incpath, inc)
+ targ.incpath = std.slpush(targ.incpath, inc)
+ ;;
+ ;;
+}
+
+const buildlibdeps = {b, targ
+ for (inc, lib, subtarg) in targ.libdeps
+ build(b, subtarg)
+ ;;
+}
+
+const hasinc = {path, t
+ for e in path
+ if std.sleq(e, t)
+ -> true
+ ;;
+ ;;
+ -> false
+}
+
+
const builddep = {b, dg, out, incs
var stale
diff --git a/clean.myr b/clean.myr
index 5f37602..89e595b 100644
--- a/clean.myr
+++ b/clean.myr
@@ -15,7 +15,7 @@ pkg bld =
const cleanall = {b
for tn in b.all
- match gettarg(b._targs, tn)
+ match gettarg(b.targs, tn)
| `Bin bt:
cleanup(b, bt, bt.inputs, true)
| `Lib lt:
@@ -36,7 +36,7 @@ const cleanall = {b
const clean = {b, targ
for tn in b.all
- match gettarg(b._targs, tn)
+ match gettarg(b.targs, tn)
| `Bin bt:
if std.sleq(bt.name, targ)
cleanup(b, bt, bt.inputs, true)
diff --git a/install.myr b/install.myr
index e91011c..a895166 100644
--- a/install.myr
+++ b/install.myr
@@ -27,7 +27,7 @@ const movetargs = {b, delete
var libarchive
for tn in b.all
- match gettarg(b._targs, tn)
+ match gettarg(b.targs, tn)
| `Bin bt:
movefile(delete, bt.name, opt_instroot, opt_destdir, "bin", 0o755)
| `Lib lt:
diff --git a/main.myr b/main.myr
index cf2f9bb..caab00a 100644
--- a/main.myr
+++ b/main.myr
@@ -97,10 +97,10 @@ const mkbuild = {
var b
b = std.zalloc()
- b._targs = std.mkht(std.strhash, std.streq)
+ b.targs = std.mkht(std.strhash, std.streq)
b.gensrc = std.mkht(std.strhash, std.streq)
b.basedir = std.getcwd()
- std.put("base dir = %s\n", b.basedir)
+ b.curdir = ""
-> b
}
diff --git a/parse.myr b/parse.myr
index 3627533..75efe3d 100644
--- a/parse.myr
+++ b/parse.myr
@@ -363,7 +363,6 @@ const inputlist = {p
match word(p)
| `std.Some l:
(dir, lib, targ) = libpath(p, l)
- std.put("dir: %s, lib: %s, targ: %s\n", dir, lib, targ)
libs = std.slpush(libs, (dir, lib, targ))
| `std.None:
failparse(p, "expected lib name after 'lib'\n")
@@ -502,21 +501,21 @@ const addtarg = {p, b, name, targ
var tn
tn = std.fmt("%s:%s", p.fdir, name)
- if std.hthas(b._targs, tn)
+ if std.hthas(b.targs, tn)
failparse(p, "duplicate target %s\n", tn)
;;
b.all = std.slpush(b.all, tn)
- std.htput(b._targs, tn, targ)
+ std.htput(b.targs, tn, targ)
}
const libpath = {p, libpath
- var dir, lib_, targ
+ var dir, lib, targ
match(std.strrfind(libpath, ":"))
| `std.None:
dir = std.sldup(".")
- lib_ = std.sldup(libpath)
- targ = std.fmt("%s:%s", p.fdir, lib_)
+ lib = std.sldup(libpath)
+ targ = std.fmt("%s:%s", p.fdir, lib)
| `std.Some idx:
if idx == libpath.len
std.fatal(1, "libdep %s missing library after ':'\n")
@@ -524,17 +523,17 @@ const libpath = {p, libpath
/* absolute path */
if std.hasprefix(libpath, "@/") || std.hasprefix(libpath, "@:")
dir = std.pathcat(p.basedir, libpath[2:idx])
- lib_ = std.sldup(libpath[idx+1:])
+ lib = std.sldup(libpath[idx+1:])
targ = std.sldup(libpath[2:])
/* relative path */
else
dir = std.sldup(libpath[:idx])
- lib_ = std.sldup(libpath[idx+1:])
+ lib = std.sldup(libpath[idx+1:])
targ = std.pathcat(p.fdir, libpath)
if std.hasprefix(targ, "../")
std.fatal(1, "library %s outside of project\n", libpath)
;;
;;
;;
- -> (dir, lib_, targ)
+ -> (dir, lib, targ)
}
diff --git a/test.myr b/test.myr
index e13f261..77c6c25 100644
--- a/test.myr
+++ b/test.myr
@@ -22,7 +22,7 @@ const test = {b
ok = true
if std.fexists("test")
for tn in b.all
- match gettarg(b._targs, tn)
+ match gettarg(b.targs, tn)
| `Bin bt:
if !dotest(b, bt, ok)
ok = false
diff --git a/types.myr b/types.myr
index d9aa019..90d1d0c 100644
--- a/types.myr
+++ b/types.myr
@@ -5,9 +5,10 @@ pkg bld =
cmd : byte[:][:] /* command that we ran */
/* build state */
basedir : byte[:]
+ curdir : byte[:]
/* build params */
all : byte[:][:]
- _targs : std.htab(byte[:], targ)# /* dir => target mapping */
+ 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 */
prefix : byte[:]
diff --git a/util.myr b/util.myr
index 463c2c9..57872b1 100644
--- a/util.myr
+++ b/util.myr
@@ -106,11 +106,18 @@ const gettarg = {tab, n
const setdir = {b, dir
var p
- p = std.pathcat(b.basedir, dir)
- std.put("changing into '%s'\n", p)
- if !std.chdir(p)
- std.fatal(1, "could not cd into %s\n")
+ if !std.sleq(b.curdir, dir)
+ p = std.pathcat(b.basedir, dir)
+ if b.curdir.len != 0
+ std.put("Leaving directory %s\n", b.curdir)
+ ;;
+
+ std.put("Entering directory '%s'\n", dir)
+ if !std.chdir(p)
+ std.fatal(1, "could not cd into %s\n")
+ ;;
+ b.curdir = dir
+ std.slfree(p)
;;
- std.slfree(p)
}