diff options
| author | Tharre <tharre3@gmail.com> | 2014-08-12 17:18:20 +0200 | 
|---|---|---|
| committer | Tharre <tharre3@gmail.com> | 2014-08-12 17:18:20 +0200 | 
| commit | 325c8e3992bf7b73714d10a5d2202c89ddbac189 (patch) | |
| tree | 145bc56cd19144a43df0055e0a3623078031516c /src/redo.c | |
| parent | 575076fac483fca12a179dd40e15183b49cb6c8f (diff) | |
| download | redo-325c8e3992bf7b73714d10a5d2202c89ddbac189.tar.gz redo-325c8e3992bf7b73714d10a5d2202c89ddbac189.tar.xz redo-325c8e3992bf7b73714d10a5d2202c89ddbac189.zip | |
Add the magic number to the dependency record.
The magic number will be used later to determine if a target has already
been rebuild.
Diffstat (limited to 'src/redo.c')
| -rw-r--r-- | src/redo.c | 17 | 
1 files changed, 17 insertions, 0 deletions
| @@ -3,12 +3,18 @@  #include <stdlib.h>  #include <sys/stat.h>  #include <sys/types.h> +#include <time.h> +#include <math.h> +#include <limits.h>  #include <unistd.h>  #include "build.h"  #include "util.h"  #include "dbg.h" +static inline int digits(unsigned n) { +  return (int) log10(n) + 1; +}  int main(int argc, char *argv[]) {      /* create .redo directory */ @@ -26,6 +32,17 @@ int main(int argc, char *argv[]) {      free(cwd); +    srand(time(NULL)); /* TODO: error checking */ +    unsigned magic = rand(); + +    char magic_str[digits(UINT_MAX) + 1]; +    sprintf(magic_str, "%u", magic); + +    printf("MAGIC: %s\n", magic_str); + +    if (setenv("REDO_MAGIC", magic_str, 0)) +        fatal("setenv()"); +      if (argc < 2) {          build_target("all");      } else { | 
