Browse Source

Only generate prototypes when out of date.

Beoran 7 years ago
parent
commit
0d1ede8abc
1 changed files with 14 additions and 4 deletions
  1. 14 4
      bin/runcprotoall

+ 14 - 4
bin/runcprotoall

@@ -19,16 +19,26 @@ do
   then 
     mkdir -p "$hdir"
     temp=$(mktemp)
+    if [ -e "$hfile" ]
+    then
+      if [ "$each" -ot "$hfile" ]
+      then
+        printf "Skipping file: $hfile: up to date.\n" 
+        continue
+      fi
+    else  
+      # create file if it doesn't exist to avoid chicken and egg problems. 
+      touch "$hfile" 
+    fi
     printf "Generating $hfile from $each. ${CPROTO_PATH} \n"
-    # create file if it doesn't exist to avoid chicken and egg problems. 
-    touch "$hfile" 
-    
+
     printf "/* This file was generated by runcprotoall */\n" > "$temp"
     printf "\n#ifndef CPROTO /* Needed to protect cproto from itself. */\n#ifndef ${guard}\n" >> "$temp"
     if cproto $CPROTO_FLAGS -I"$hdir" "$each" >> "$temp" 
     then
       printf "\n#endif /* ${guard} */ \n#endif /* CPROTO */" >> "$temp"
-      mv -f "$temp" "$hfile" 
+      mv -f "$temp" "$hfile"
+      git add "$hfile" 
     else
       printf "cproto failed\n"
       exit 1