Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-12-18 12:27:08 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-12-18 12:27:08 +0300
commit7bc0fa99aed667e63226be2ab081709313ce5db5 (patch)
treef07050200fc87a6abe8063ed8f521da2f62d430e /source/blender/makesrna/intern/makesrna.c
parentb31b63bd728010603681752ecdd4057bf9f8aa92 (diff)
workaround for build system dependency hell, fixed for cmake + makefiles (probably other buildsystems too).
makesrna was often generating source every build, but not updating the files because the contents wasn't changed. this happened because makefiles would check makesrna.c and rna_*.c files were newer then rna_*_gen.c and force a re-generation. Now ensure updating the files even if they dont change when makesrna.c or rna_*.c are newer then rna_*_gen.c files. Another solution for this would be to run makesrna program for each C file for finer grained deps. or remove file comparison checks but that would mean a change to any rna_*.c file would rebuild all.
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r--source/blender/makesrna/intern/makesrna.c59
1 files changed, 55 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index f454cb8f231..f4479885676 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -47,7 +47,20 @@
/* Replace if different */
#define TMP_EXT ".tmp"
-static int replace_if_different(char *tmpfile)
+
+/* copied from BLI_file_older */
+#include <sys/stat.h>
+static int file_older(const char *file1, const char *file2)
+{
+ struct stat st1, st2;
+
+ if(stat(file1, &st1)) return 0;
+ if(stat(file2, &st2)) return 0;
+
+ return (st1.st_mtime < st2.st_mtime);
+}
+
+static int replace_if_different(char *tmpfile, const char *dep_files[])
{
// return 0; // use for testing had edited rna
@@ -78,6 +91,38 @@ static int replace_if_different(char *tmpfile)
REN_IF_DIFF;
}
+
+ /* XXX, trick to work around dependancy problem
+ * assumes dep_files is in the same dir as makesrna.c, which is true for now. */
+
+ if(1) {
+ /* first check if makesrna.c is newer then generated files
+ * for development on makesrna.c you may want to disable this */
+ if(file_older(orgfile, __FILE__)) {
+ REN_IF_DIFF;
+ }
+
+ /* now check if any files we depend on are newer then any generated files */
+ if(dep_files) {
+ int pass;
+ for(pass=0; dep_files[pass]; pass++) {
+ char from_path[4096]= __FILE__;
+ char *p1, *p2;
+
+ /* dir only */
+ p1= strrchr(from_path, '/');
+ p2= strrchr(from_path, '\\');
+ strcpy((p1 > p2 ? p1 : p2)+1, dep_files[pass]);
+ /* account for build deps, if makesrna.c (this file) is newer */
+ if(file_older(orgfile, from_path)) {
+ REN_IF_DIFF;
+ }
+ }
+ }
+ }
+ /* XXX end dep trick */
+
+
fp_new= fopen(tmpfile, "rb");
if(fp_new==NULL) {
@@ -2615,6 +2660,7 @@ static int rna_preprocess(char *outfile)
FILE *file;
char deffile[4096];
int i, status;
+ const char *deps[3]; /* expand as needed */
/* define rna */
brna= RNA_create();
@@ -2655,7 +2701,7 @@ static int rna_preprocess(char *outfile)
}
}
- replace_if_different(deffile);
+ replace_if_different(deffile, NULL);
rna_sort(brna);
@@ -2683,7 +2729,12 @@ static int rna_preprocess(char *outfile)
}
}
- replace_if_different(deffile);
+ /* avoid unneeded rebuilds */
+ deps[0]= PROCESS_ITEMS[i].filename;
+ deps[1]= PROCESS_ITEMS[i].api_filename;
+ deps[2]= NULL;
+
+ replace_if_different(deffile, deps);
}
/* create RNA_blender.h */
@@ -2707,7 +2758,7 @@ static int rna_preprocess(char *outfile)
}
}
- replace_if_different(deffile);
+ replace_if_different(deffile, NULL);
/* free RNA */
RNA_define_free(brna);