aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2015-01-03 03:14:35 +0100
committerTharre <tharre3@gmail.com>2015-01-03 03:49:30 +0100
commit74ec249cc047a5ea6ced84fb301de638f55c6e2c (patch)
tree198a2b4f04d354a1e8f818779de896e7b9f13282
parentd56e6f8cf7cab9740fb3ce3d94c859678e6a2b69 (diff)
downloadredo-74ec249cc047a5ea6ced84fb301de638f55c6e2c.tar.gz
redo-74ec249cc047a5ea6ced84fb301de638f55c6e2c.tar.xz
redo-74ec249cc047a5ea6ced84fb301de638f55c6e2c.zip
Remember sources and don't rebuild missing ones
-rw-r--r--src/build.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/build.c b/src/build.c
index fbfca22..e4a7c6b 100644
--- a/src/build.c
+++ b/src/build.c
@@ -40,6 +40,8 @@ typedef struct dep_info {
char *path;
unsigned int magic;
unsigned char hash[20];
+ int32_t flags;
+#define DEP_SOURCE (1 << 1)
} dep_info;
static do_attr *get_dofiles(const char *target);
@@ -60,6 +62,7 @@ int build_target(const char *target) {
dep.path = get_dep_path(target);
dep.magic = atoi(getenv("REDO_MAGIC"));
+ dep.flags = 0;
/* get the do-file which we are going to execute */
do_attr *dofiles = get_dofiles(target);
@@ -67,6 +70,7 @@ int build_target(const char *target) {
if (fexists(target)) {
/* if our target file has no do file associated but exists,
then we treat it as a source */
+ dep.flags |= DEP_SOURCE;
hash_file(target, dep.hash);
write_dep_info(&dep);
goto exit;
@@ -173,6 +177,7 @@ int build_target(const char *target) {
free(dep.path);
/* depend on the do-file */
+ dep.flags = 0;
dep.path = get_dep_path(dofiles->chosen);
if (!fexists(dep.path)) {
hash_file(dofiles->chosen, dep.hash);
@@ -422,9 +427,6 @@ int update_target(const char *target, int ident) {
}
static int handle_c(const char *target) {
- if (!fexists(target))
- return build_target(target);
-
char *dep_path = get_dep_path(target);
FILE *fp = fopen(dep_path, "rb");
@@ -446,6 +448,15 @@ static int handle_c(const char *target) {
free(dep_path);
dep_info *dep = (dep_info*) (buf-offsetof(dep_info, magic));
+
+ if (!fexists(target)) {
+ if (dep->flags & DEP_SOURCE)
+ /* target is a source and must not be rebuild */
+ return 1;
+ else
+ return build_target(target);
+ }
+
if (dep->magic == (unsigned) atoi(getenv("REDO_MAGIC")))
/* magic number matches */
return 1;