diff options
author | Ori Bernstein <ori@eigenstate.org> | 2013-09-05 13:00:33 -0400 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2013-09-05 13:00:33 -0400 |
commit | de4bc34a527fc33a86e862d7462ab9c8f02ddfcb (patch) | |
tree | 7cb9620e55c25d829f74dc1236bf8a79ce797b30 /myrbuild | |
parent | ff6e3444ff9cb3f8877f9d4c2653236609bae4f2 (diff) | |
download | mc-de4bc34a527fc33a86e862d7462ab9c8f02ddfcb.tar.gz |
Add basic loop detection to myrbuild.
Diffstat (limited to 'myrbuild')
-rw-r--r-- | myrbuild/myrbuild.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/myrbuild/myrbuild.c b/myrbuild/myrbuild.c index 9220764..b9fa9b1 100644 --- a/myrbuild/myrbuild.c +++ b/myrbuild/myrbuild.c @@ -43,6 +43,7 @@ char *sysname; regex_t usepat; Htab *compiled; +Htab *loopdetect; static void usage(char *prog) { @@ -198,6 +199,9 @@ void compile(char *file) if (hthas(compiled, file)) return; + if (hthas(loopdetect, file)) + die("Cycle in dependency graph, involving %s\n", file); + htput(loopdetect, file, file); if (hassuffix(file, ".myr")) { swapsuffix(use, sizeof use, file, ".myr", ".use"); swapsuffix(obj, sizeof obj, file, ".myr", ".o"); @@ -212,9 +216,9 @@ void compile(char *file) } } if (isfresh(file, use)) - return; + goto done; if (isfresh(file, obj)) - return; + goto done; gencmd(&cmd, &ncmd, muse, file, NULL, 0); run(cmd); @@ -223,13 +227,15 @@ void compile(char *file) } else if (hassuffix(file, ".s")) { swapsuffix(obj, sizeof obj, file, ".s", ".o"); if (isfresh(file, obj)) - return; + goto done; extra[2] = obj; gencmd(&cmd, &ncmd, as, file, extra, 3); run(cmd); } +done: s = strdup(file); htput(compiled, s, s); + htdel(loopdetect, file); } void mergeuse(char **files, size_t nfiles) @@ -390,6 +396,7 @@ int main(int argc, char **argv) die("Can't specify both library and binary names"); compiled = mkht(strhash, streq); + loopdetect = mkht(strhash, streq); regcomp(&usepat, "^[[:space:]]*use[[:space:]]+([^[:space:]]+)", REG_EXTENDED); for (i = optind; i < argc; i++) compile(argv[i]); |