ref: b06b47d44926600403d5fc102fe44c058e9b02a6
parent: fe519fb71154e67252f085fff5e016328c83983a
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Jan 5 18:00:51 EST 2015
Don't scrape libs when cleaning. If a library is on the include path when cleaning, this can cause a clean failure when the library gets removed.
--- a/build.myr
+++ b/build.myr
@@ -101,7 +101,7 @@
;;
;;
std.put("%s...\n", targ.name)
- if !myrdeps(p, &dg, targ.name, targ.inputs, targ.incpath, false)
+ if !myrdeps(p, targ, false, false, &dg)
std.fatal(1, "Could not load dependencies for %s\n", targ.name)
;;
if !std.hthas(dg.deps, targ.name)
@@ -134,7 +134,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, targ.incpath, true)
+ if !myrdeps(p, targ, true, false, &dg)
std.fatal(1, "Could not load dependencies for %s\n", lib)
;;
if !std.hthas(dg.deps, lib)
--- a/clean.myr
+++ b/clean.myr
@@ -58,7 +58,7 @@
var keys
var dg
- if !myrdeps(p, &dg, targ.name, leaves, targ.incpath, islib)
+ if !myrdeps(p, targ, islib, true, &dg)
std.fatal(1, "Could not load dependencies for %s\n", targ.name)
;;
mchammer_files = std.mkht(std.strhash, std.streq)
--- 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[:][:], incs : byte[:][:], islib : bool -> bool)
+ const myrdeps : (p : parser#, mt : myrtarg#, islib : bool, isclean : bool, dg : depgraph# -> bool)
/* a bit ugly: initialized from main() */
@@ -22,10 +22,10 @@
`Lib byte[:]
;;
-const myrdeps = {p, dg, targ, srcs, incs, islib
+const myrdeps = {p, mt, islib, isclean, dg
+ var objs, uses, srcs, incs
var seentab, donetab
var out, useout
- var objs, uses
var i
dg.deps = std.mkht(std.strhash, std.streq)
@@ -36,12 +36,14 @@
donetab = std.mkht(std.strhash, std.streq)
/* direct dependencies of binary */
if islib
- out = std.fmt("lib%s.a", targ)
- useout = std.sldup(targ)
+ out = std.fmt("lib%s.a", mt.name)
+ useout = std.sldup(mt.name)
else
- out = std.sldup(targ)
+ out = std.sldup(mt.name)
useout = ""
;;
+ srcs = mt.inputs
+ incs = mt.incpath
objs = swapall(srcs, config.Objsuffix)
uses = swapall(srcs, ".use")
for i = 0; i < srcs.len; i++
@@ -59,7 +61,7 @@
;;
;;
for i = 0; i < srcs.len; i++
- srcdeps(p, dg, seentab, donetab, srcs[i], objs[i], uses[i], incs)
+ srcdeps(p, dg, seentab, donetab, srcs[i], objs[i], uses[i], incs, isclean)
;;
dumpgraph(dg)
std.htfree(seentab)
@@ -93,7 +95,7 @@
std.put("}\n")
}
-const srcdeps = {p, g, seen, done, path, obj, usefile, incs
+const srcdeps = {p, g, seen, done, path, obj, usefile, incs, isclean
var deps
if std.hthas(done, path)
@@ -107,7 +109,13 @@
for d in deps
match d
| `Lib lib:
- scrapelibs(g, lib, incs)
+ /*
+ If we're cleaning, we don't care about libraries; at best, this does nothing. At
+ worst, this will cause failure if the library is a local library that gets cleand.
+ */
+ if !isclean
+ scrapelibs(g, lib, incs)
+ ;;
| `Local l:
if !std.hassuffix(l, ".use")
std.fatal(1, "local dependency \"%s\" of \"%s\" should end with .use\n", l, path)
@@ -118,7 +126,7 @@
if usefile.len != 0
pushdep(g, l, usefile)
;;
- addusedep(p, g, seen, done, l, incs)
+ addusedep(p, g, seen, done, l, incs, isclean)
;;
;;
std.htput(seen, path, false)
@@ -125,7 +133,7 @@
std.htput(done, path, true)
}
-const addusedep = {p, g, seen, done, usefile, incs
+const addusedep = {p, g, seen, done, usefile, incs, isclean
var src
if std.hthas(done, usefile)
@@ -142,7 +150,7 @@
;;
pushdep(g, src, usefile)
std.htput(g.sources, usefile, src)
- srcdeps(p, g, seen, done, src, "", usefile, incs)
+ srcdeps(p, g, seen, done, src, "", usefile, incs, isclean)
std.htput(done, usefile, true)
}