ref: 888092f5ced7d7e9b131e6131d74104fbc545f17
parent: ed81b7c463f443eada7b4c5dbcbed313a216fc97
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jan 3 21:01:17 EST 2015
Pass the target include path through. opt_includedirs isn't enough.
--- a/build.myr
+++ b/build.myr
@@ -92,7 +92,7 @@
if targ.built
->
;;
- if targ.libdeps.len > 0
+ if targ.libdeps.len > 0 && !hasinc(targ.incpath, ".")
targ.incpath = std.slpush(targ.incpath, ".")
for l in targ.libdeps
build(p, l)
@@ -99,7 +99,7 @@
;;
;;
std.put("%s...\n", targ.name)
- if !myrdeps(p, &dg, targ.name, targ.inputs, false)
+ if !myrdeps(p, &dg, targ.name, targ.inputs, targ.incpath, false)
std.fatal(1, "Could not load dependencies for %s\n", targ.name)
;;
if !std.hthas(dg.deps, targ.name)
@@ -111,6 +111,15 @@
targ.built = true
}
+const hasinc = {path, t
+ for e in path
+ if std.sleq(e, t)
+ -> true
+ ;;
+ ;;
+ -> false
+}
+
const buildlib = {p, targ
var archive
var u, l
@@ -123,7 +132,7 @@
lib = targ.name
std.put("lib%s.a...\n", lib)
archive = std.fmt("lib%s.a", lib)
- if !myrdeps(p, &dg, lib, targ.inputs, true)
+ if !myrdeps(p, &dg, lib, targ.inputs, targ.incpath, true)
std.fatal(1, "Could not load dependencies for %s\n", lib)
;;
if !std.hthas(dg.deps, lib)
--- a/clean.myr
+++ b/clean.myr
@@ -16,9 +16,9 @@
for t in p.targs
match t
| `Bin bt:
- cleanup(p, bt.name, bt.inputs, true)
+ cleanup(p, bt, bt.inputs, true)
| `Lib lt:
- cleanup(p, lt.name, lt.inputs, true)
+ cleanup(p, lt, lt.inputs, true)
| `Gen gt:
for f in gt.out
if std.remove(f)
@@ -38,11 +38,11 @@
match t
| `Bin bt:
if std.sleq(bt.name, targ)
- cleanup(p, bt.name, bt.inputs, true)
+ cleanup(p, bt, bt.inputs, true)
;;
| `Lib lt:
if std.sleq(lt.name, targ)
- cleanup(p, lt.name, lt.inputs, true)
+ cleanup(p, lt, lt.inputs, true)
;;
| `Gen gt:
| `Sub subs:
@@ -53,13 +53,13 @@
-> true
}
-const cleanup = {p, out, leaves, islib
+const cleanup = {p, targ, leaves, islib
var mchammer_files /* cant touch this */
var keys
var dg
- if !myrdeps(p, &dg, out, leaves, islib)
- std.fatal(1, "Could not load dependencies for %s\n", out)
+ if !myrdeps(p, &dg, targ.name, leaves, targ.incpath, islib)
+ std.fatal(1, "Could not load dependencies for %s\n", targ.name)
;;
mchammer_files = std.mkht(std.strhash, std.streq)
for l in leaves
--- a/deps.myr
+++ b/deps.myr
@@ -8,7 +8,7 @@
use "util.use"
pkg bld =
- const myrdeps : (p : parser#, dg : depgraph#, targ : byte[:], srcs : byte[:][:], islib : bool -> bool)
+ const myrdeps : (p : parser#, dg : depgraph#, targ : byte[:], srcs : byte[:][:], incs : byte[:][:], islib : bool -> bool)
/* a bit ugly: initialized from main() */
@@ -22,7 +22,7 @@
`Lib byte[:]
;;
-const myrdeps = {p, dg, targ, srcs, islib
+const myrdeps = {p, dg, targ, srcs, incs, islib
var seentab, donetab
var out, useout
var objs, uses
@@ -59,7 +59,7 @@
;;
;;
for i = 0; i < srcs.len; i++
- srcdeps(p, dg, seentab, donetab, srcs[i], objs[i], uses[i])
+ srcdeps(p, dg, seentab, donetab, srcs[i], objs[i], uses[i], incs)
;;
dumpgraph(dg)
std.htfree(seentab)
@@ -93,7 +93,7 @@
std.put("}\n")
}
-const srcdeps = {p, g, seen, done, path, obj, usefile
+const srcdeps = {p, g, seen, done, path, obj, usefile, incs
var deps
if std.hthas(done, path)
@@ -107,7 +107,7 @@
for d in deps
match d
| `Lib lib:
- scrapelibs(g, lib)
+ scrapelibs(g, lib, incs)
| `Local l:
if !std.hassuffix(l, ".use")
std.fatal(1, "usefile dependency \"%s\" of \"%s\" is not a usefile\n", l, path)
@@ -118,7 +118,7 @@
if usefile.len != 0
pushdep(g, l, usefile)
;;
- addusedep(p, g, seen, done, l)
+ addusedep(p, g, seen, done, l, incs)
;;
;;
std.htput(seen, path, false)
@@ -125,7 +125,7 @@
std.htput(done, path, true)
}
-const addusedep = {p, g, seen, done, usefile
+const addusedep = {p, g, seen, done, usefile, incs
var src
if std.hthas(done, usefile)
@@ -142,7 +142,7 @@
;;
pushdep(g, src, usefile)
std.htput(g.sources, usefile, src)
- srcdeps(p, g, seen, done, src, "", usefile)
+ srcdeps(p, g, seen, done, src, "", usefile, incs)
std.htput(done, usefile, true)
}
@@ -174,7 +174,7 @@
;;
}
-const scrapelibs = {dg, lib
+const scrapelibs = {dg, lib, incs
var deps, d
var f
var done
@@ -184,7 +184,7 @@
;;
deps = [][:]
- f = openlib(lib)
+ f = openlib(lib, incs)
match bio.getc(f)
| `std.Some 'U': /* nothing */
| `std.Some _: std.fatal(1, "library %s is not usefile\n", lib)
@@ -204,15 +204,15 @@
bio.close(f)
std.htput(dg.libs, lib, deps)
for dep in deps
- scrapelibs(dg, dep)
+ scrapelibs(dg, dep, incs)
;;
}
-const openlib = {lib
+const openlib = {lib, incs
var path
- for p in opt_incpaths
- path = std.pathjoin([p, "/lib/myr", lib][:])
+ for p in incs
+ path = std.pathjoin([p, lib][:])
match bio.open(path, bio.Rd)
| `std.Some file:
-> file
--- a/parse.myr
+++ b/parse.myr
@@ -166,6 +166,9 @@
std.fatal(1, "got invalid attr '%s'\n", invalid)
;;
;;
+ for i in incpath
+ std.put("incpath elt: %s\n", i)
+ ;;
-> std.mk([
.name=name,
.inputs=inputs,