summaryrefslogtreecommitdiff
path: root/myrbuild
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2013-01-18 14:09:18 -0500
committerOri Bernstein <orib@google.com>2013-01-18 14:09:30 -0500
commitbbf152c2fe0b743e8a85ff208f6b19a3d631c78a (patch)
treeba3f9535623f2159f92c378358a9b87cf38e17a2 /myrbuild
parent9fc485a80b9713c1581a3c734d2d2bbf347f80e7 (diff)
downloadmc-bbf152c2fe0b743e8a85ff208f6b19a3d631c78a.tar.gz
Be more careful about duplicated dependencies to build.
We would allow duplicated local deps in the dependency list before. Don't do that.
Diffstat (limited to 'myrbuild')
-rw-r--r--myrbuild/myrbuild.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/myrbuild/myrbuild.c b/myrbuild/myrbuild.c
index b69b019..da69e73 100644
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -133,6 +133,16 @@ int isfresh(char *from, char *to)
return from_sb.st_mtime >= to_sb.st_mtime;
}
+int inlist(char **list, size_t sz, char *str)
+{
+ size_t i;
+
+ for (i = 0; i < sz; i++)
+ if (!strcmp(list[i], str))
+ return 1;
+ return 0;
+}
+
void getdeps(char *file, char **deps, size_t depsz, size_t *ndeps)
{
char buf[2048]; /* if you hit this limit, shoot yourself */
@@ -140,6 +150,7 @@ void getdeps(char *file, char **deps, size_t depsz, size_t *ndeps)
regmatch_t m[2];
size_t i;
FILE *f;
+ char *dep;
f = fopen(file, "r");
if (!f)
@@ -151,21 +162,15 @@ void getdeps(char *file, char **deps, size_t depsz, size_t *ndeps)
continue;
if (i == depsz)
die("Too many deps for file %s", file);
- deps[i++] = strdupn(&buf[m[1].rm_so], m[1].rm_eo - m[1].rm_so);
+ dep = strdupn(&buf[m[1].rm_so], m[1].rm_eo - m[1].rm_so);
+ if (!inlist(deps, i, dep))
+ deps[i++] = dep;
+ else
+ free(dep);
}
*ndeps = i;
}
-int inlist(char **list, size_t sz, char *str)
-{
- size_t i;
-
- for (i = 0; i < sz; i++)
- if (!strcmp(list[i], str))
- return 1;
- return 0;
-}
-
void compile(char *file)
{
size_t i, ndeps;
@@ -183,7 +188,7 @@ void compile(char *file)
localdep = fromuse(deps[i]);
compile(localdep);
free(localdep);
- } else if (!inlist(libs, nlibs, deps[i])) {
+ } else {
lappend(&libs, &nlibs, deps[i]);
}
}