about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-09-04 18:55:28 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-09-04 18:55:28 +0200
commit1b2ea59777bc7170556a91ce19675e80dca5690f (patch)
tree298137233a9df0dffa6fb71eec619e7a30106ef0
parente8bec32e3d7be5818da89051fd64297f8679c1a0 (diff)
downloadredo-c-1b2ea59777bc7170556a91ce19675e80dca5690f.tar.gz
redo-c-1b2ea59777bc7170556a91ce19675e80dca5690f.tar.xz
redo-c-1b2ea59777bc7170556a91ce19675e80dca5690f.zip
Actually recurse into dependencies when checking them >_<
Thanks to @erlehmann for pointing this out.
-rw-r--r--redo.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/redo.c b/redo.c
index d7080be..4afb05c 100644
--- a/redo.c
+++ b/redo.c
@@ -346,16 +346,24 @@ targetchdir(char *target) {
 	}
 }
 
-static char * targetdep(char *target) {
+static char *
+targetdep(char *target) {
 	static char dep[1024];
 	snprintf(dep, sizeof dep, ".%s.dep", target);
 	return dep;
 }
 
 static int
+sourcefile(char *target)
+{
+	target = targetchdir(target);
+	return access(target, F_OK) == 0 && access(targetdep(target), F_OK) != 0;
+}
+
+static int
 check_deps(char *target)
 {
-	char *depfile;
+	char *depfile, *filename;
 	FILE *f;
 	int ok = 1;
 	int fd;
@@ -380,7 +388,8 @@ check_deps(char *target)
 					ok = 0;
 				break;
 			case '=':  // compare hash
-				fd = open(line + 1 + 64 + 1, O_RDONLY);
+				filename = line + 1 + 64 + 1;
+				fd = open(filename, O_RDONLY);
 				if (fd < 0) {
 					ok = 0;
 				} else {
@@ -389,6 +398,10 @@ check_deps(char *target)
 						ok = 0;
 					close(fd);
 				}
+				// hash is good, recurse into dependencies
+				if (ok && strcmp(target, filename) != 0 &&
+				    !sourcefile(filename))
+					ok = check_deps(filename);
 				break;
 			case '!':  // always rebuild
 			default:  // dep file broken, lets recreate it
@@ -605,13 +618,6 @@ create_pool()
 	}
 }
 
-static int
-sourcefile(char *target)
-{
-	char *depfile = targetdep(target);
-	return access(target, F_OK) == 0 && access(depfile, F_OK) != 0;
-}
-
 static void
 redo_ifchange(int targetc, char *targetv[])
 {