summaryrefslogtreecommitdiff
path: root/myrbuild
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2013-06-05 11:19:57 -0400
committerOri Bernstein <ori@eigenstate.org>2013-06-05 11:19:57 -0400
commit3aac04fb7bef769b7d3fc6389c7dd76ea196fdc0 (patch)
tree8bf3e519636d22dfbc37453f7905f54f5ae7e64e /myrbuild
parentc2f922830897fb3dee6c271860a28985726d7c0f (diff)
downloadmc-3aac04fb7bef769b7d3fc6389c7dd76ea196fdc0.tar.gz
Read far fewer dependencies over and over.
Check for freshness before scanning.
Diffstat (limited to 'myrbuild')
-rw-r--r--myrbuild/myrbuild.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/myrbuild/myrbuild.c b/myrbuild/myrbuild.c
index c486e75..f6e8da7 100644
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -139,9 +139,9 @@ int isfresh(char *from, char *to)
if (stat(from, &from_sb))
err(1, "Could not find %s", from);
if (stat(to, &to_sb) == -1)
- return 1;
+ return 0;
- return from_sb.st_mtime >= to_sb.st_mtime;
+ return from_sb.st_mtime <= to_sb.st_mtime;
}
int inlist(char **list, size_t sz, char *str)
@@ -190,10 +190,17 @@ void compile(char *file)
size_t ncmd;
char *localdep;
char *deps[512];
- char buf[1024];
+ char use[1024];
+ char obj[1024];
char *extra[] = {"-g", "-o", "" /* filename */};
if (hassuffix(file, ".myr")) {
+ swapsuffix(use, sizeof use, file, ".myr", ".use");
+ swapsuffix(obj, sizeof obj, file, ".myr", ".o");
+ if (isfresh(file, use))
+ return;
+ if (isfresh(file, obj))
+ return;
getdeps(file, deps, 512, &ndeps);
for (i = 0; i < ndeps; i++) {
if (isquoted(deps[i])) {
@@ -204,24 +211,18 @@ void compile(char *file)
lappend(&libs, &nlibs, deps[i]);
}
}
- swapsuffix(buf, sizeof buf, file, ".myr", ".use");
- if (isfresh(file, buf)) {
- gencmd(&cmd, &ncmd, muse, file, NULL, 0);
- run(cmd);
- }
+ gencmd(&cmd, &ncmd, muse, file, NULL, 0);
+ run(cmd);
- swapsuffix(buf, sizeof buf, file, ".myr", ".o");
- if (isfresh(file, buf)) {
- gencmd(&cmd, &ncmd, mc, file, NULL, 0);
- run(cmd);
- }
+ gencmd(&cmd, &ncmd, mc, file, NULL, 0);
+ run(cmd);
} else if (hassuffix(file, ".s")) {
- swapsuffix(buf, sizeof buf, file, ".s", ".o");
- if (isfresh(file, buf)) {
- extra[2] = buf;
- gencmd(&cmd, &ncmd, as, file, extra, 3);
- run(cmd);
- }
+ swapsuffix(obj, sizeof obj, file, ".s", ".o");
+ if (isfresh(file, obj))
+ return;
+ extra[2] = obj;
+ gencmd(&cmd, &ncmd, as, file, extra, 3);
+ run(cmd);
}
}